Date: Mon, 7 May 2007 16:41:23 GMT From: Bruce M Simpson <bms@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 119428 for review Message-ID: <200705071641.l47GfNnM062738@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119428 Change 119428 by bms@bms_anglepoise on 2007/05/07 16:41:19 Call OS and arch independent cfe_init() routine before initializing low level console (CFE is used on some PPC and ARM boards also). Use CFE to discover memory regions rather than hardcoding them; thus preserving the CFE arena at runtime. Clean up locore<->cfe glue a little. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips/locore.S#18 edit .. //depot/projects/mips2/src/sys/mips/mips/machdep.c#31 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips/locore.S#18 (text+ko) ==== @@ -42,8 +42,6 @@ #endif #ifdef CFE /* assumes MIPS32 */ -GLOBAL(cfe_present) - .space 4 GLOBAL(cfe_handle) .space 4 GLOBAL(cfe_vector) @@ -126,8 +124,6 @@ */ li t1, 0x43464531 bne a3, t1, no_cfe /* Check for "CFE1" signature */ - li t1, 0x1 - sw t1, cfe_present sw a0, cfe_handle /* Firmware data segment */ sw a2, cfe_vector /* Firmware entry vector */ no_cfe: ==== //depot/projects/mips2/src/sys/mips/mips/machdep.c#31 (text+ko) ==== @@ -70,6 +70,10 @@ #include <machine/trap.h> #include <machine/vmparam.h> +#ifdef CFE +#include <dev/cfe/cfe_api.h> +#endif + #ifdef CPU_SENTRY5 /* XXX */ void sentry5_reset(void); @@ -79,6 +83,11 @@ #include <ddb/ddb.h> #endif +#ifdef CFE +extern uint32_t cfe_handle; +extern uint32_t cfe_vector; +#endif + int cold = 1; int clocks_running = 0; @@ -169,6 +178,38 @@ printf("entry: mips_init()\n"); bootverbose = 0; +#ifdef CFE + /* + * Query DRAM memory map from CFE. + */ + physmem = 0; + for (i = 0; i < 10; i += 2) { + int result; + uint64_t addr, len, type; + + result = cfe_enummem(i, 0, &addr, &len, &type); + if (result < 0) { + phys_avail[i] = phys_avail[i + 1] = 0; + break; + } + if (type != CFE_MI_AVAILABLE) + continue; + + phys_avail[i] = addr; + if (i == 0 && addr == 0) { + /* + * If this is the first physical memory segment probed + * from CFE, omit the region at the start of physical + * memory where the kernel has been loaded. + */ + phys_avail[i] += MIPS_KSEG0_TO_PHYS((vm_offset_t)&end); + } + phys_avail[i + 1] = addr + len; + physmem += len; + } + + realmem = btoc(physmem); +#else /* !CFE */ realmem = btoc(64 << 20); for (i = 0; i < 10; i++) { @@ -178,6 +219,8 @@ /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS((vm_offset_t)&end); phys_avail[1] = ctob(realmem); +#endif + physmem = realmem; init_param1(); @@ -486,7 +529,21 @@ kernend = round_page((vm_offset_t)&end); memset(&edata, 0, kernend - (vm_offset_t)(&edata)); +#ifdef CFE + /* + * Initialize CFE firmware trampolines before + * we initialize the low-level console. + */ + if (cfe_handle != 0) + cfe_init(cfe_handle, cfe_vector); +#endif cninit(); + +#ifdef CFE + if (cfe_handle == 0) + panic("CFE was not detected by locore.\n"); +#endif + mips_init(); tick_init_params(); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705071641.l47GfNnM062738>