Author: blueswirl Date: 2007-07-11 21:48:31 +0200 (Wed, 11 Jul 2007) New Revision: 165
Modified: openbios-devel/arch/sparc64/openbios.c Log: NVRAM support (temporary location)
Modified: openbios-devel/arch/sparc64/openbios.c =================================================================== --- openbios-devel/arch/sparc64/openbios.c 2007-07-11 19:46:26 UTC (rev 164) +++ openbios-devel/arch/sparc64/openbios.c 2007-07-11 19:48:31 UTC (rev 165) @@ -21,17 +21,92 @@ static unsigned char intdict[256 * 1024];
// XXX -void arch_nvram_put() +#define NVRAM_SIZE 0x2000 +#define NVRAM_IDPROM 0x1fd0 +#define NVRAM_OB_OFFSET 256 +#define NVRAM_OB_SIZE ((NVRAM_IDPROM - NVRAM_OB_OFFSET) & ~15) + +static struct qemu_nvram_v1 { + char id_string[16]; + uint32_t version; + uint32_t nvram_size; // not used in Sun4m + char unused1[8]; + char arch[12]; + char curr_cpu; + char smp_cpus; + char unused2; + char nographic; + uint32_t ram_size; + char boot_device; + char unused3[3]; + uint32_t kernel_image; + uint32_t kernel_size; + uint32_t cmdline; + uint32_t cmdline_size; + uint32_t initrd_image; + uint32_t initrd_size; + uint32_t nvram_image; + uint16_t width; + uint16_t height; + uint16_t depth; + char unused4[158]; + uint16_t crc; +} nv_info; + +#define OBIO_CMDLINE_MAX 256 +static char obio_cmdline[OBIO_CMDLINE_MAX]; + +void arch_nvram_get(char *data) { + unsigned short i; + unsigned char *nvptr = &nv_info; + uint32_t size; + extern uint32_t kernel_image; + extern uint32_t kernel_size; + extern uint32_t cmdline; + extern uint32_t cmdline_size; + extern char boot_device; + + for (i = 0; i < sizeof(struct qemu_nvram_v1); i++) { + outb(i & 0xff, 0x74); + outb(i >> 8, 0x75); + *nvptr++ = inb(0x77); + } + + kernel_image = nv_info.kernel_image; + kernel_size = nv_info.kernel_size; + size = nv_info.cmdline_size; + if (size > OBIO_CMDLINE_MAX - 1) + size = OBIO_CMDLINE_MAX - 1; + memcpy(obio_cmdline, nv_info.cmdline, size); + obio_cmdline[size] = '\0'; + cmdline = obio_cmdline; + cmdline_size = size; + printk("kernel addr %x size %x\n", kernel_image, kernel_size); + if (size) + printk("kernel cmdline %s\n", obio_cmdline); + + for (i = 0; i < NVRAM_OB_SIZE; i++) { + outb((i + NVRAM_OB_OFFSET) & 0xff, 0x74); + outb((i + NVRAM_OB_OFFSET) >> 8, 0x75); + data[i] = inb(0x77); + } }
-void arch_nvram_get() +void arch_nvram_put(char *data) { + unsigned short i; + + for (i = 0; i < NVRAM_OB_SIZE; i++) { + outb((i + NVRAM_OB_OFFSET) & 0xff, 0x74); + outb((i + NVRAM_OB_OFFSET) >> 8, 0x75); + outb(data[i], 0x77); + } }
int arch_nvram_size() { - return 8192; + return NVRAM_OB_SIZE; }
void setup_timers() @@ -132,6 +207,9 @@
enterforth((xt_t)PC); arch_init(); // XXX + printk("force boot\n"); + push_str("/pci/isa/ide0/disk@0,0:a"); + boot(); // XXX printk("falling off...\n"); return 0; }