Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/i386/i386/machdep.c,v retrieving revision 1.586.2.6 retrieving revision 1.587 diff -u -p -r1.586.2.6 -r1.587 --- src/sys/arch/i386/i386/machdep.c 2009/10/18 15:20:42 1.586.2.6 +++ src/sys/arch/i386/i386/machdep.c 2007/01/04 18:16:44 1.587 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.586.2.6 2009/10/18 15:20:42 bouyer Exp $ */ +/* $NetBSD: machdep.c,v 1.587 2007/01/04 18:16:44 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.586.2.6 2009/10/18 15:20:42 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.587 2007/01/04 18:16:44 jmcneill Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include "opt_realmem.h" #include "opt_user_ldt.h" #include "opt_vm86.h" +#include "opt_xbox.h" #include #include @@ -132,8 +133,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include -#include - #include #include #include @@ -162,6 +161,13 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #endif +#ifdef XBOX +#include + +int arch_i386_is_xbox = 0; +uint32_t arch_i386_xbox_memsize = 0; +#endif + #include "acpi.h" #include "apmbios.h" #include "bioscall.h" @@ -185,14 +191,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include "npx.h" #include "ksyms.h" -#include "cardbus.h" -#if NCARDBUS > 0 -/* For rbus_min_start hint. */ -#include -#include -#include -#endif - #include "mca.h" #if NMCA > 0 #include /* for mca_busprobe() */ @@ -250,11 +248,7 @@ int i386_has_sse2; int tmx86_has_longrun; vaddr_t msgbuf_vaddr; -struct { - paddr_t paddr; - psize_t sz; -} msgbuf_p_seg[VM_PHYSSEG_MAX]; -unsigned int msgbuf_p_cnt = 0; +paddr_t msgbuf_paddr; vaddr_t idt_vaddr; paddr_t idt_paddr; @@ -410,31 +404,25 @@ native_loader(int bl_boothowto, int bl_b void cpu_startup() { - int x, y; + int x; vaddr_t minaddr, maxaddr; - psize_t sz; char pbuf[9]; /* * Initialize error message buffer (et end of core). */ - if (msgbuf_p_cnt == 0) - panic("msgbuf paddr map has not been set up"); - for (x = 0, sz = 0; x < msgbuf_p_cnt; sz += msgbuf_p_seg[x++].sz) - continue; - msgbuf_vaddr = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_VAONLY); + msgbuf_vaddr = uvm_km_alloc(kernel_map, x86_round_page(MSGBUFSIZE), 0, + UVM_KMF_VAONLY); if (msgbuf_vaddr == 0) panic("failed to valloc msgbuf_vaddr"); /* msgbuf_paddr was init'd in pmap */ - for (y = 0, sz = 0; y < msgbuf_p_cnt; y++) { - for (x = 0; x < btoc(msgbuf_p_seg[y].sz); x++, sz += PAGE_SIZE) - pmap_kenter_pa((vaddr_t)msgbuf_vaddr + sz, - msgbuf_p_seg[y].paddr + x * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE); - } + for (x = 0; x < btoc(MSGBUFSIZE); x++) + pmap_kenter_pa((vaddr_t)msgbuf_vaddr + x * PAGE_SIZE, + msgbuf_paddr + x * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE); pmap_update(pmap_kernel()); - initmsgbuf((caddr_t)msgbuf_vaddr, sz); + initmsgbuf((caddr_t)msgbuf_vaddr, round_page(MSGBUFSIZE)); printf("%s%s", copyright, version); @@ -452,11 +440,6 @@ cpu_startup() format_bytes(pbuf, sizeof(pbuf), ptoa(physmem)); printf("total memory = %s\n", pbuf); -#if NCARDBUS > 0 - /* Tell RBUS how much RAM we have, so it can use heuristics. */ - rbus_min_start_hint(ptoa(physmem)); -#endif - minaddr = 0; /* @@ -484,7 +467,23 @@ cpu_startup() /* Safe for i/o port / memory space allocation to use malloc now. */ x86_bus_space_mallocok(); - x86_init(); +#ifdef XBOX +#define XBOX_NFORCE_NIC 0xfef00000 + /* XXX jmcneill: Hack to workaround Cromwell bugs, from FreeBSD */ + if (arch_i386_is_xbox) { + bus_space_handle_t h; + char *nicbase; + int rv; + + rv = bus_space_map(X86_BUS_SPACE_MEM, XBOX_NFORCE_NIC, + 0x400, 0, &h); + if (!rv) { + nicbase = bus_space_vaddr(X86_BUS_SPACE_MEM, h); + *(uint32_t *)(nicbase + 0x188) = 0; + bus_space_unmap(X86_BUS_SPACE_MEM, h, 0x400); + } + } +#endif } /* @@ -810,12 +809,6 @@ sendsig_siginfo(const ksiginfo_t *ksi, c buildcontext(l, sel, catcher, fp); -#if NNPX > 0 - /* make sure we get a clean FPU */ - npxsave_lwp(l, 0); - l->l_md.md_flags &= ~MDL_USEDFPU; -#endif - /* Remember that we're now on the signal stack. */ if (onstack) p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; @@ -909,6 +902,12 @@ haltsys: #endif if ((howto & RB_POWERDOWN) == RB_POWERDOWN) { +#ifdef XBOX + if (arch_i386_is_xbox) { + pic16l_poweroff(); + for (;;); + } +#endif #if NACPI > 0 if (acpi_softc != NULL) { delay(500000); @@ -1520,6 +1519,32 @@ init386(paddr_t first_avail) lwp0.l_addr = proc0paddr; cpu_info_primary.ci_curpcb = &lwp0.l_addr->u_pcb; +#ifdef XBOX + /* + * The following code queries the PCI ID of 0:0:0. For the XBOX, + * This should be 0x10de / 0x02a5. + * + * This is exactly what Linux does. + */ + outl(0xcf8, 0x80000000); + if (inl(0xcfc) == 0x02a510de) { + arch_i386_is_xbox = 1; + xbox_lcd_init(); + xbox_lcd_writetext("NetBSD/i386 "); + pic16l_setled(XBOX_LED_RED); + delay(500000); + pic16l_setled(XBOX_LED_GREEN); + + /* + * We are an XBOX, but we may have either 64MB or 128MB of + * memory. The PCI host bridge should be programmed for this, + * so we just query it. + */ + outl(0xcf8, 0x80000084); + arch_i386_xbox_memsize = (inl(0xcfc) == 0x7FFFFFF) ? 128 : 64; + } +#endif /* XBOX */ + x86_bus_space_init(); consinit(); /* XXX SHOULD NOT BE DONE HERE */ /* @@ -1622,13 +1647,6 @@ init386(paddr_t first_avail) } /* - * If the segment is smaller than a page, skip it. - */ - if (bim->entry[x].size < NBPG) { - continue; - } - - /* * Sanity check the entry. * XXX Need to handle uint64_t in extent code * XXX and 64-bit physical addresses in i386 @@ -1853,7 +1871,6 @@ init386(paddr_t first_avail) psize_t sz = round_page(MSGBUFSIZE); psize_t reqsz = sz; - search_again: for (x = 0; x < vm_nphysseg; x++) { vps = &vm_physmem[x]; if (ptoa(vps->avail_end) == avail_end) @@ -1868,8 +1885,7 @@ init386(paddr_t first_avail) vps->avail_end -= atop(sz); vps->end -= atop(sz); - msgbuf_p_seg[msgbuf_p_cnt].sz = sz; - msgbuf_p_seg[msgbuf_p_cnt++].paddr = ptoa(vps->avail_end); + msgbuf_paddr = ptoa(vps->avail_end); /* Remove the last segment if it now has no pages. */ if (vps->start == vps->end) { @@ -1883,17 +1899,10 @@ init386(paddr_t first_avail) avail_end = vm_physmem[x].avail_end; avail_end = ptoa(avail_end); - if (sz != reqsz) { - reqsz -= sz; - if (msgbuf_p_cnt != VM_PHYSSEG_MAX) { - /* if still segments available, get memory from next one ... */ - sz = reqsz; - goto search_again; - } /* Warn if the message buffer had to be shrunk. */ + if (sz != reqsz) printf("WARNING: %ld bytes not available for msgbuf " - "in last cluster (%ld used)\n", (long)MSGBUFSIZE, MSGBUFSIZE - reqsz); - } + "in last cluster (%ld used)\n", reqsz, sz); } /* @@ -2204,6 +2213,13 @@ cpu_reset() disable_intr(); +#ifdef XBOX + if (arch_i386_is_xbox) { + pic16l_reboot(); + for (;;); + } +#endif + /* * Ensure the NVRAM reset byte contains something vaguely sane. */