Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S264849AbTFCI6w (ORCPT ); Tue, 3 Jun 2003 04:58:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S264850AbTFCI6w (ORCPT ); Tue, 3 Jun 2003 04:58:52 -0400 Received: from h55p111.delphi.afb.lu.se ([130.235.187.184]:49568 "EHLO gagarin.0x63.nu") by vger.kernel.org with ESMTP id S264849AbTFCI55 (ORCPT ); Tue, 3 Jun 2003 04:57:57 -0400 Date: Tue, 3 Jun 2003 11:11:13 +0200 To: linux-kernel@vger.kernel.org Cc: Sam Ravnborg , mikpe@csd.uu.se, torvalds@transmeta.com Subject: [PATCH] Support for mach-xbox (updated) Message-ID: <20030603091113.GD13285@h55p111.delphi.afb.lu.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: Anders Gustafsson X-Scanner: exiscan *19N7p3-0004lp-00*VvDSeMa7H0o*0x63.nu Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 31974 Lines: 714 Updated according to Sam and Mikaels comments. This patch that adds a new subachitecture for the xbox gaming system. All it does outside the subarchitecture is adding posibility to blacklist pci-devices through an mach-hook. -- Anders Gustafsson - andersg@0x63.nu - http://0x63.nu/ You can import this changeset into BK by piping this whole message to: '| bk receive [path to repository]' or apply the patch as usual. =================================================================== ChangeSet 1.1266 03/06/03 10:14:24 andersg@0x63.nu +10 -0 Added XBOX subarch include/asm-i386/mach-xbox/mach_pci_blacklist.h 1.1 03/06/03 10:14:07 andersg@0x63.nu +6 -0 include/asm-i386/mach-default/mach_pci_blacklist.h 1.1 03/06/03 10:14:07 andersg@0x63.nu +6 -0 include/asm-i386/mach-xbox/mach_pci_blacklist.h 1.0 03/06/03 10:14:07 andersg@0x63.nu +0 -0 BitKeeper file /data/dev/kernel/bk/xbox-2.5/include/asm-i386/mach-xbox/mach_pci_blacklist.h include/asm-i386/mach-default/mach_pci_blacklist.h 1.0 03/06/03 10:14:07 andersg@0x63.nu +0 -0 BitKeeper file /data/dev/kernel/bk/xbox-2.5/include/asm-i386/mach-default/mach_pci_blacklist.h arch/i386/mach-xbox/setup.c 1.1 03/06/03 10:14:06 andersg@0x63.nu +79 -0 arch/i386/mach-xbox/reboot.c 1.1 03/06/03 10:14:06 andersg@0x63.nu +51 -0 arch/i386/mach-xbox/setup.c 1.0 03/06/03 10:14:06 andersg@0x63.nu +0 -0 BitKeeper file /data/dev/kernel/bk/xbox-2.5/arch/i386/mach-xbox/setup.c arch/i386/mach-xbox/reboot.c 1.0 03/06/03 10:14:06 andersg@0x63.nu +0 -0 BitKeeper file /data/dev/kernel/bk/xbox-2.5/arch/i386/mach-xbox/reboot.c arch/i386/mach-xbox/Makefile 1.1 03/06/03 10:14:05 andersg@0x63.nu +5 -0 include/asm-i386/timex.h 1.5 03/06/03 10:14:05 andersg@0x63.nu +9 -5 Added XBOX subarch arch/i386/pci/direct.c 1.15 03/06/03 10:14:05 andersg@0x63.nu +4 -0 Added XBOX subarch Added a mach-hook for blacklisting pci-devices. The xbox hangs solid if you touch some pci devices. arch/i386/mach-xbox/Makefile 1.0 03/06/03 10:14:05 andersg@0x63.nu +0 -0 BitKeeper file /data/dev/kernel/bk/xbox-2.5/arch/i386/mach-xbox/Makefile arch/i386/boot/compressed/Makefile 1.17 03/06/03 10:14:05 andersg@0x63.nu +5 -0 Added XBOX subarch There is some strange interaction when paging is off, that makes 1.1 xboxen crash while decompressing kernel, unless decompressor is compiled without optimization. arch/i386/Makefile 1.52 03/06/03 10:14:05 andersg@0x63.nu +4 -0 Added XBOX subarch arch/i386/Kconfig 1.58 03/06/03 10:14:05 andersg@0x63.nu +19 -2 Added XBOX subarch arch/i386/Kconfig | 21 +++++ arch/i386/Makefile | 4 + arch/i386/boot/compressed/Makefile | 5 + arch/i386/mach-xbox/Makefile | 5 + arch/i386/mach-xbox/reboot.c | 51 +++++++++++++ arch/i386/mach-xbox/setup.c | 79 +++++++++++++++++++++ arch/i386/pci/direct.c | 4 + include/asm-i386/mach-default/mach_pci_blacklist.h | 6 + include/asm-i386/mach-xbox/mach_pci_blacklist.h | 6 + include/asm-i386/timex.h | 14 ++- 10 files changed, 188 insertions(+), 7 deletions(-) diff -Nru a/arch/i386/Kconfig b/arch/i386/Kconfig --- a/arch/i386/Kconfig Tue Jun 3 10:17:30 2003 +++ b/arch/i386/Kconfig Tue Jun 3 10:17:30 2003 @@ -43,6 +43,22 @@ help Choose this option if your computer is a standard PC or compatible. +config X86_XBOX + bool "XBox Gaming System" + help + This option is needed to make Linux boot on XBox Gaming Systems. + + The XBox can be considered as a standard PC with a Coppermine-based Celeron 733 MHz, + IDE harddrive, DVD, Ethernet, USB and graphics. + + To boot the kernel you need "_romwell", either used as a replacement BIOS (cromwell) + or as a bootloader. + + For more information see http://xbox-linux.sourceforge.net/ + + If you do not specifically need a kernel for XBOX machine, + say N here otherwise the kernel you build will not be bootable. + config X86_VOYAGER bool "Voyager (NCR)" help @@ -395,6 +411,7 @@ Otherwise, say N. config SMP + depends on !X86_XBOX bool "Symmetric multi-processing support" ---help--- This enables support for systems with more than one CPU. If you have @@ -1090,7 +1107,7 @@ config MCA bool "MCA support" - depends on !(X86_VISWS || X86_VOYAGER) + depends on !(X86_VISWS || X86_VOYAGER || X86_XBOX) help MicroChannel Architecture is found in some IBM PS/2 machines and laptops. It is a bus system similar to PCI or ISA. See @@ -1571,7 +1588,7 @@ config X86_BIOS_REBOOT bool - depends on !(X86_VISWS || X86_VOYAGER) + depends on !(X86_VISWS || X86_VOYAGER || X86_XBOX) default y config X86_TRAMPOLINE diff -Nru a/arch/i386/Makefile b/arch/i386/Makefile --- a/arch/i386/Makefile Tue Jun 3 10:17:30 2003 +++ b/arch/i386/Makefile Tue Jun 3 10:17:30 2003 @@ -53,6 +53,10 @@ # Default subarch .c files mcore-y := mach-default +# Xbox subarch support +mflags-$(CONFIG_X86_XBOX) := -Iinclude/asm-i386/mach-xbox +mcore-$(CONFIG_X86_XBOX) := mach-xbox + # Voyager subarch support mflags-$(CONFIG_X86_VOYAGER) := -Iinclude/asm-i386/mach-voyager mcore-$(CONFIG_X86_VOYAGER) := mach-voyager diff -Nru a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile --- a/arch/i386/boot/compressed/Makefile Tue Jun 3 10:17:30 2003 +++ b/arch/i386/boot/compressed/Makefile Tue Jun 3 10:17:30 2003 @@ -5,6 +5,11 @@ # targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o +ifeq ($(CONFIG_X86_XBOX),y) +#XXX Compiling with optimization makes 1.1-xboxen +# crash while decompressing the kernel +CFLAGS_misc.o := -O0 +endif EXTRA_AFLAGS := -traditional LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 diff -Nru a/arch/i386/mach-xbox/Makefile b/arch/i386/mach-xbox/Makefile --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/mach-xbox/Makefile Tue Jun 3 10:17:30 2003 @@ -0,0 +1,5 @@ +# +# Makefile for the linux kernel. +# + +obj-y := setup.o reboot.o diff -Nru a/arch/i386/mach-xbox/reboot.c b/arch/i386/mach-xbox/reboot.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/mach-xbox/reboot.c Tue Jun 3 10:17:30 2003 @@ -0,0 +1,51 @@ +/* + * arch/i386/mach-xbox/reboot.c + * Olivier Fauchon + * Anders Gustafsson + * + */ + +#include + +/* we don't use any of those, but dmi_scan.c needs 'em */ +void (*pm_power_off)(void); +int reboot_thru_bios; + +#define XBOX_SMB_IO_BASE 0xC000 +#define XBOX_SMB_HOST_ADDRESS (0x4 + XBOX_SMB_IO_BASE) +#define XBOX_SMB_HOST_COMMAND (0x8 + XBOX_SMB_IO_BASE) +#define XBOX_SMB_HOST_DATA (0x6 + XBOX_SMB_IO_BASE) +#define XBOX_SMB_GLOBAL_ENABLE (0x2 + XBOX_SMB_IO_BASE) + +#define XBOX_PIC_ADDRESS 0x10 + +#define SMC_CMD_POWER 0x02 +#define SMC_SUBCMD_POWER_RESET 0x01 +#define SMC_SUBCMD_POWER_CYCLE 0x40 +#define SMC_SUBCMD_POWER_OFF 0x80 + + +static void xbox_pic_cmd(u8 command) +{ + outw_p(((XBOX_PIC_ADDRESS) << 1),XBOX_SMB_HOST_ADDRESS); + outb_p(SMC_CMD_POWER, XBOX_SMB_HOST_COMMAND); + outw_p(command, XBOX_SMB_HOST_DATA); + outw_p(inw(XBOX_SMB_IO_BASE),XBOX_SMB_IO_BASE); + outb_p(0x0a,XBOX_SMB_GLOBAL_ENABLE); +} + +void machine_restart(char * __unused) +{ + printk(KERN_INFO "Sending POWER_RESET to XBOX-PIC.\n"); + xbox_pic_cmd(SMC_SUBCMD_POWER_RESET); +} + +void machine_power_off(void) +{ + printk(KERN_INFO "Sending POWER_OFF to XBOX-PIC.\n"); + xbox_pic_cmd(SMC_SUBCMD_POWER_OFF); +} + +void machine_halt(void) +{ +} diff -Nru a/arch/i386/mach-xbox/setup.c b/arch/i386/mach-xbox/setup.c --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/arch/i386/mach-xbox/setup.c Tue Jun 3 10:17:30 2003 @@ -0,0 +1,79 @@ +/* + * Machine specific setup for xbox + */ + +#include +#include +#include +#include +#include +#include + +/** + * pre_intr_init_hook - initialisation prior to setting up interrupt vectors + * + * Description: + * Perform any necessary interrupt initialisation prior to setting up + * the "ordinary" interrupt call gates. For legacy reasons, the ISA + * interrupts should be initialised here if the machine emulates a PC + * in any way. + **/ +void __init pre_intr_init_hook(void) +{ + init_ISA_irqs(); +} + +/** + * intr_init_hook - post gate setup interrupt initialisation + * + * Description: + * Fill in any interrupts that may have been left out by the general + * init_IRQ() routine. interrupts having to do with the machine rather + * than the devices on the I/O bus (like APIC interrupts in intel MP + * systems) are started here. + **/ +void __init intr_init_hook(void) +{ +#ifdef CONFIG_X86_LOCAL_APIC + apic_intr_init(); +#endif + +} + +/** + * pre_setup_arch_hook - hook called prior to any setup_arch() execution + * + * Description: + * generally used to activate any machine specific identification + * routines that may be needed before setup_arch() runs. On VISWS + * this is used to get the board revision and type. + **/ +void __init pre_setup_arch_hook(void) +{ +} + +/** + * trap_init_hook - initialise system specific traps + * + * Description: + * Called as the final act of trap_init(). Used in VISWS to initialise + * the various board specific APIC traps. + **/ +void __init trap_init_hook(void) +{ +} + +static struct irqaction irq0 = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL}; + +/** + * time_init_hook - do any specific initialisations for the system timer. + * + * Description: + * Must plug the system timer interrupt source at HZ into the IRQ listed + * in irq_vectors.h:TIMER_IRQ + **/ +void __init time_init_hook(void) +{ + setup_irq(0, &irq0); +} + diff -Nru a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c --- a/arch/i386/pci/direct.c Tue Jun 3 10:17:30 2003 +++ b/arch/i386/pci/direct.c Tue Jun 3 10:17:30 2003 @@ -4,6 +4,7 @@ #include #include +#include "mach_pci_blacklist.h" #include "pci.h" /* @@ -20,6 +21,9 @@ if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255)) return -EINVAL; + if (mach_pci_is_blacklisted(bus,dev,fn)) + return -EINVAL; + spin_lock_irqsave(&pci_config_lock, flags); outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8); diff -Nru a/include/asm-i386/mach-default/mach_pci_blacklist.h b/include/asm-i386/mach-default/mach_pci_blacklist.h --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/include/asm-i386/mach-default/mach_pci_blacklist.h Tue Jun 3 10:17:30 2003 @@ -0,0 +1,6 @@ +#ifndef __ASM_MACH_PCI_BLACKLIST_H +#define __ASM_MACH_PCI_BLACKLIST_H + +#define mach_pci_is_blacklisted(bus,dev,fn) 0 + +#endif diff -Nru a/include/asm-i386/mach-xbox/mach_pci_blacklist.h b/include/asm-i386/mach-xbox/mach_pci_blacklist.h --- /dev/null Wed Dec 31 16:00:00 1969 +++ b/include/asm-i386/mach-xbox/mach_pci_blacklist.h Tue Jun 3 10:17:30 2003 @@ -0,0 +1,6 @@ +#ifndef __ASM_MACH_PCI_BLACKLIST_H +#define __ASM_MACH_PCI_BLACKLIST_H + +#define mach_pci_is_blacklisted(bus,dev,fn) ( (bus>1) || (bus&&(dev||fn)) || ((bus==0 && dev==0) && ((fn==1)||(fn==2))) ) + +#endif diff -Nru a/include/asm-i386/timex.h b/include/asm-i386/timex.h --- a/include/asm-i386/timex.h Tue Jun 3 10:17:30 2003 +++ b/include/asm-i386/timex.h Tue Jun 3 10:17:30 2003 @@ -12,11 +12,15 @@ #ifdef CONFIG_X86_PC9800 extern int CLOCK_TICK_RATE; #else -#ifdef CONFIG_MELAN -# define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */ -#else -# define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ -#endif +# ifdef CONFIG_MELAN +# define CLOCK_TICK_RATE 1189200 /* AMD Elan has different frequency! */ +# else +# ifdef CONFIG_X86_XBOX +# define CLOCK_TICK_RATE 1124998 /* so has the Xbox */ +# else +# define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ +# endif +# endif #endif #define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */ =================================================================== This BitKeeper patch contains the following changesets: 1.1266 ## Wrapped with uu ## M(R!5&)O>"TR+C4*"B,@4&%T8V@@=F5R&)O M>"]M86-H7W!C:5]B;&%C:VQI&)O>"]M86-H7W!C:5]B;&%C:VQI#8S+FYU?&%R8V@O:3,X-B]M86-H+7AB;W@O36%K M969I;&5\,C P,S V,#,P.#$T,#9\,#4R,S0*/B!T;W)V86QD&)O>"]S971U<"YC?#(P,#,P-C S,#@Q M-# V?#(R-# Y?#0Q,SAB,C1D,S@U-34U-&8@86YD97)S9T P>#8S+FYU?&%R M8V@O:3,X-B]M86-H+7AB;W@O"UM-CAK+F]R9UMT;W)V86QD"YH?#(P,#,P-C S,#@Q-# U?#8Q-38T"CX@86YD97)S9T P M>#8S+FYU?&%R8V@O:3,X-B]M86-H+7AB;W@O&)O>"]-86ME9FEL97PR,# S,#8P,S X,30P-7PS M,34T,WPX8S,X,CAE9#EA-3(Q,CDR"D0@,2XP(# S+S V+S S(#$P.C$T.C U M*S R.C P(&%N9&5R#8S+FYU("LU("TP"D(@=&]R=F%L9'- 871H M;&]N+G1R86YS;65T82YC;VU\0VAA;F=E4V5T?#(P,#(P,C U,3#@R,0HM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM M+2TM+2TM+2T*"@IA;F1E&)O M>"]R96)O;W0N8WPR,# S,#8P,S X,30P-GPT,S P,GPV-V0T,C@R,S1D-3AD M,SD*1" Q+C$@,#,O,#8O,#,@,3 Z,30Z,#8K,#(Z,# @86YD97)S9T P>#8S M+FYU("LU,2 M, I"('1O$,P M,# *(V1E9FEN92!80D]87U--0E](3U-47T%$1%)%4U,@(" @(" @*#!X-" K M(%A"3UA?4TU"7TE/7T)!4T4I"B-D969I;F4@6$)/6%]334)?2$]35%]#3TU- M04Y$(" @(" @("@P>#@@*R!80D]87U--0E])3U]"05-%*0HC9&5F:6YE(%A" M3UA?4TU"7TA/4U1?1$%402 @(" @(" @(" H,'@V("L@6$)/6%]334)?24]? M0D%312D*(V1E9FEN92!80D]87U--0E]'3$]"04Q?14Y!0DQ%(" @(" @("@P M>#(@*R!80D]87U--0E])3U]"05-%*0I<"B-D969I;F4@6$)/6%]024-?041$ M4D534R P>#$P"EP*(V1E9FEN92!334-?0TU$7U!/5T52(#!X,#(*(V1E9FEN M92!334-?4U5"0TU$7U!/5T527U)%4T54(#!X,#$*(V1E9FEN92!334-?4U5" M0TU$7U!/5T527T-90TQ%(#!X-# *(V1E9FEN92!334-?4U5"0TU$7U!/5T52 M7T]&1B P>#@P"EP*7 IS=&%T:6,@=F]I9"!X8F]X7W!I8U]C;60H=3@@8V]M M;6%N9"D*>PH);W5T=U]P*"@H6$)/6%]024-?041$4D534RD@/#P@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]M86-H7W!C:5]B;&%C M:VQI&)O>"TR+C4O:6YC;'5D M92]A&)O>"]M86-H M7W!C:5]B;&%C:VQI#8S+FYU("LT("TP"D(@ M=&]R=F%L9'- 871H;&]N+G1R86YS;65T82YC;VU\0VAA;F=E4V5T?#(P,#(P M,C U,36]U M('1O=6-H('-O;64@<&-I(&1E=FEC97,N"DL@-30S,3(*3R M#8S+FYU M("LT("TP"D(@=&]R=F%L9'- 871H;&]N+G1R86YS;65T82YC;VU\0VAA;F=E M4V5T?#(P,#(P,C U,3"!S=6)A#8S+FYU("LU("TP"D(@=&]R=F%L9'- 871H;&]N+G1R86YS;65T M82YC;VU\0VAA;F=E4V5T?#(P,#(P,C U,3&)O>&5N( HC(" @(&-R87-H('=H M:6QE(&1E8V]M<')E"YH?#(P,#(P,C U,3&]R9W5K+G5K=74N;W)G+G5K6W1O#8S+FYU("LY("TU M"D(@=&]R=F%L9'- 871H;&]N+G1R86YS;65T82YC;VU\0VAA;F=E4V5T?#(P M,#(P,C U,32$@*B\*(R @ M96QS90HC(" @(&EF9&5F($-/3D9)1U]8.#9?6$)/6 HC(" @(" @9&5F:6YE M($-,3T-+7U1)0TM?4D%412 Q,3(T.3DX("\J('-O(&AA" J M+PHC(" @(&5L6EN9R!(6B J+PHC(" @(&5N9&EF"B,@(&5N9&EF M"@H]/2!A"!'86UI;F<@4WES=&5M(@H):&5L< H)("!4:&ES(&]P=&EO M;B!I"!B;V]T(&]N(%A";W@@1V%M:6YG M(%-Y"!C86X@8F4@8V]NBP*"2 @241%(&AA6]U(&YE960@(E]R;VUW96QL(BP@96ET:&5R('5S960@87,@82!R97!L86-E M;65N="!"24]3("AC2!N965D(&$@:V5R;F5L(&9O2!.(&AE6]U(&)U:6QD('=I M;&P@;F]T(&)E(&)O;W1A8FQE+@I<"DDS.3<@,0H)9&5P96YD