Author: stepan Date: 2006-05-16 19:36:09 +0200 (Tue, 16 May 2006) New Revision: 19
Modified: openbios-devel/arch/sparc32/romvec.c openbios-devel/config/examples/cross-sparc32_config.xml openbios-devel/config/examples/sparc32_config.xml openbios-devel/drivers/esp.c openbios-devel/drivers/iommu.c Log: new sparc merge
Modified: openbios-devel/arch/sparc32/romvec.c =================================================================== --- openbios-devel/arch/sparc32/romvec.c 2006-05-15 08:17:51 UTC (rev 18) +++ openbios-devel/arch/sparc32/romvec.c 2006-05-16 17:36:09 UTC (rev 19) @@ -42,6 +42,8 @@ static int obp_getprop(int node, char *name, char *val); static int obp_setprop(int node, char *name, char *val, int len); static const char *obp_nextprop(int node, char *name); +static int obp_devread(int dev_desc, char *buf, int nbytes); +static int obp_devseek(int dev_desc, int hi, int lo);
static const struct linux_nodeops nodeops0 = { obp_nextnode, /* int (*no_nextnode)(int node); */ @@ -167,14 +169,36 @@
static const char *obp_nextprop(int node, char *name) { + char *ret; + int found; + if (!name || *name == '\0') { // NULL name means get first property - DPRINTF("obp_nextprop(%x, NULL)\n", node); - return 0; + push_str(""); + name = "NULL"; + } else { + push_str(name); } - DPRINTF("obp_nextprop(%x, %s)\n", node, name); + PUSH(node); + fword("next-property"); + found = POP(); + if (!found) { + DPRINTF("obp_nextprop(%x, %s) (not found)\n", node, name); + (void) POP(); + (void) POP();
- return 0; + return NULL; + } else { + int len; + char *str; + + len = POP(); + str = (char *) POP(); + + DPRINTF("obp_nextprop(%x, %s) = %s\n", node, name, str); + + return str; + } }
static int obp_nbgetchar(void) @@ -214,36 +238,41 @@ { int ret;
- DPRINTF("obp_devopen(%s)\n", str); - push_str(str); fword("open-dev"); ret = POP(); + DPRINTF("obp_devopen(%s) = 0x%x\n", str, ret);
return ret; }
-static int obp_devclose(__attribute__((unused)) int dev_desc) +static int obp_devclose(int dev_desc) { - DPRINTF("obp_devclose %x\n", dev_desc); + int ret;
- return 0; + PUSH(dev_desc); + fword("close-dev"); + ret = POP(); + + DPRINTF("obp_devclose(0x%x) = %d\n", dev_desc, ret); + + return ret; }
static int obp_rdblkdev(int dev_desc, int num_blks, int offset, char *buf) { - int ret; + int ret, hi, lo, bs;
- DPRINTF("obp_rdblkdev: fd %x, num_blks %d, offset %d, buf 0x%x\n", dev_desc, num_blks, offset, (int)buf); + bs = 512; // XXX: real blocksize? + hi = ((uint64_t)offset * bs) >> 32; + lo = ((uint64_t)offset * bs) & 0xffffffff;
- PUSH((int)buf); - PUSH(offset); - PUSH(num_blks); - push_str("read-blocks"); - PUSH(dev_desc); - fword("$call-method"); - ret = POP(); + ret = obp_devseek(dev_desc, hi, lo);
+ ret = obp_devread(dev_desc, buf, num_blks * bs) / bs; + + DPRINTF("obp_rdblkdev(fd %x, num_blks %d, offset %d (hi %d lo %d), buf 0x%x) = %d\n", dev_desc, num_blks, offset, hi, lo, (int)buf, ret); + return ret; }
@@ -277,30 +306,63 @@
static int obp_devread(int dev_desc, char *buf, int nbytes) { - DPRINTF("obp_devread: fd %d, nbytes %d\n", dev_desc, nbytes); + int ret;
- return 0; + PUSH((int)buf); + PUSH(nbytes); + push_str("read"); + PUSH(dev_desc); + fword("$call-method"); + ret = POP(); + + DPRINTF("obp_devread(fd 0x%x, buf 0x%x, nbytes %d) = %d\n", dev_desc, (int)buf, nbytes, ret); + + return ret; }
static int obp_devwrite(int dev_desc, char *buf, int nbytes) { - DPRINTF("obp_devwrite: fd %d, buf %s, nbytes %d\n", dev_desc, buf, nbytes); + int ret;
+ PUSH((int)buf); + PUSH(nbytes); + push_str("write"); + PUSH(dev_desc); + fword("$call-method"); + ret = POP(); + + DPRINTF("obp_devwrite(fd 0x%x, buf %s, nbytes %d) = %d\n", dev_desc, buf, nbytes, ret); + return nbytes; }
-static int obp_devseek(int dev_desc, __attribute__((unused)) int hi, int lo) +static int obp_devseek(int dev_desc, int hi, int lo) { - DPRINTF("obp_devseek: fd %d, hi %d, lo %d\n", dev_desc, hi, lo); + int ret;
- return 0; + PUSH(lo); + PUSH(hi); + push_str("seek"); + PUSH(dev_desc); + fword("$call-method"); + ret = POP(); + + DPRINTF("obp_devseek(fd 0x%x, hi %d, lo %d) = %d\n", dev_desc, hi, lo, ret); + + return ret; }
static int obp_inst2pkg(int dev_desc) { - DPRINTF("obp_inst2pkg: fd %d\n", dev_desc); + int ret;
- return 0; + PUSH(dev_desc); + fword("ihandle>phandle"); + ret = POP(); + + DPRINTF("obp_inst2pkg(fd 0x%x) = 0x%x\n", dev_desc, ret); + + return ret; }
static int obp_cpustart(unsigned int whichcpu, int ctxtbl_ptr, @@ -415,7 +477,7 @@ romvec0.pv_v2devops.v2_dev_write = obp_devwrite; romvec0.pv_v2devops.v2_dev_seek = obp_devseek; obp_arg.boot_dev_ctrl = 0; - obp_arg.boot_dev_unit = '0'; + obp_arg.boot_dev_unit = 0; obp_arg.argv[0] = "sd(0,0,0):d";
switch(boot_device) { @@ -444,6 +506,8 @@ romvec0.pv_v2bootargs.bootargs = &cmdline; romvec0.pv_v2bootargs.fd_stdin = &obp_fd_stdin; romvec0.pv_v2bootargs.fd_stdout = &obp_fd_stdout; + obp_stdin = PROMDEV_TTYA; + obp_stdout = PROMDEV_TTYA;
romvec0.v3_cpustart = obp_cpustart; romvec0.v3_cpustop = obp_cpustop;
Modified: openbios-devel/config/examples/cross-sparc32_config.xml =================================================================== --- openbios-devel/config/examples/cross-sparc32_config.xml 2006-05-15 08:17:51 UTC (rev 18) +++ openbios-devel/config/examples/cross-sparc32_config.xml 2006-05-16 17:36:09 UTC (rev 19) @@ -18,7 +18,7 @@
<!-- Kernel Debugging --> <option name="CONFIG_DEBUG" type="boolean" value="true"/> - <option name="CONFIG_DEBUG_BOOT" type="boolean" value="true"/> + <option name="CONFIG_DEBUG_BOOT" type="boolean" value="false"/> <option name="CONFIG_DEBUG_DSTACK" type="boolean" value="false"/> <option name="CONFIG_DEBUG_RSTACK" type="boolean" value="false"/> <option name="CONFIG_DEBUG_DICTIONARY" type="boolean" value="false"/> @@ -29,6 +29,7 @@ <option name="CONFIG_DEBUG_ESP" type="boolean" value="false"/> <option name="CONFIG_DEBUG_SUN_PARTS" type="boolean" value="false"/> <option name="CONFIG_DEBUG_OBP" type="boolean" value="false"/> + <option name="CONFIG_DEBUG_IOMMU" type="boolean" value="false"/> <option name="CONFIG_SERIAL_PORT" type="integer" value="0"/> <option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/>
Modified: openbios-devel/config/examples/sparc32_config.xml =================================================================== --- openbios-devel/config/examples/sparc32_config.xml 2006-05-15 08:17:51 UTC (rev 18) +++ openbios-devel/config/examples/sparc32_config.xml 2006-05-16 17:36:09 UTC (rev 19) @@ -18,7 +18,7 @@
<!-- Kernel Debugging --> <option name="CONFIG_DEBUG" type="boolean" value="true"/> - <option name="CONFIG_DEBUG_BOOT" type="boolean" value="true"/> + <option name="CONFIG_DEBUG_BOOT" type="boolean" value="false"/> <option name="CONFIG_DEBUG_DSTACK" type="boolean" value="false"/> <option name="CONFIG_DEBUG_RSTACK" type="boolean" value="false"/> <option name="CONFIG_DEBUG_DICTIONARY" type="boolean" value="false"/> @@ -29,6 +29,7 @@ <option name="CONFIG_DEBUG_ESP" type="boolean" value="false"/> <option name="CONFIG_DEBUG_SUN_PARTS" type="boolean" value="false"/> <option name="CONFIG_DEBUG_OBP" type="boolean" value="false"/> + <option name="CONFIG_DEBUG_IOMMU" type="boolean" value="false"/> <option name="CONFIG_SERIAL_PORT" type="integer" value="0"/> <option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/>
Modified: openbios-devel/drivers/esp.c =================================================================== --- openbios-devel/drivers/esp.c 2006-05-15 08:17:51 UTC (rev 18) +++ openbios-devel/drivers/esp.c 2006-05-16 17:36:09 UTC (rev 19) @@ -42,6 +42,13 @@ paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \ } while(0)
+#ifdef CONFIG_DEBUG_ESP +#define DPRINTF(fmt, args...) \ + do { printk(fmt , ##args); } while (0) +#else +#define DPRINTF(fmt, args...) +#endif + struct esp_dma { volatile struct sparc_dma_registers *regs; enum dvma_rev revision; @@ -134,9 +141,8 @@ static int ob_sd_read_sectors(esp_private_t *esp, sd_private_t *sd, int offset, void *dest, short len) { -#ifdef CONFIG_DEBUG_ESP - printk("ob_sd_read_sectors id %d %lx block=%d len=%d\n", sd->id, (unsigned long)dest, offset, len); -#endif + DPRINTF("ob_sd_read_sectors id %d %lx block=%d len=%d\n", sd->id, (unsigned long)dest, offset, len); + // Setup command = Read(10) memset(esp->buffer, 0, 10); esp->buffer[0] = 0x80; @@ -226,14 +232,12 @@ ucell blk = POP(); char *dest = (char*)POP();
-#ifdef CONFIG_DEBUG_ESP - printk("ob_sd_read_blocks id %d %lx block=%d n=%d\n", (*sd)->id, (unsigned long)dest, blk, n ); -#endif + DPRINTF("ob_sd_read_blocks id %d %lx block=%d n=%d\n", (*sd)->id, (unsigned long)dest, blk, n );
n *= (*sd)->bs / 512; while (n) { if (ob_sd_read_sectors(global_esp, *sd, blk, dest, 1)) { - printk("ob_ide_read_blocks: error\n"); + DPRINTF("ob_ide_read_blocks: error\n"); RET(0); } dest += (*sd)->bs; @@ -259,9 +263,8 @@ id = POP(); *sd = &global_esp->sd[id];
-#ifdef CONFIG_DEBUG_ESP - printk("opening drive %d\n", id); -#endif + DPRINTF("opening drive %d\n", id); + selfword("open-deblocker");
/* interpose disk-label */ @@ -294,45 +297,45 @@
/* Hardcode everything for MrCoffee. */ if ((p = (void *)map_io(PHYS_JJ_ESPDMA, 0x10)) == 0) { - printk("espdma_init: cannot map registers\n"); + DPRINTF("espdma_init: cannot map registers\n"); return -1; } espdma->regs = p;
- printk("dma1: "); + DPRINTF("dma1: ");
switch ((espdma->regs->cond_reg) & DMA_DEVICE_ID) { case DMA_VERS0: espdma->revision = dvmarev0; - printk("Revision 0 "); + DPRINTF("Revision 0 "); break; case DMA_ESCV1: espdma->revision = dvmaesc1; - printk("ESC Revision 1 "); + DPRINTF("ESC Revision 1 "); break; case DMA_VERS1: espdma->revision = dvmarev1; - printk("Revision 1 "); + DPRINTF("Revision 1 "); break; case DMA_VERS2: espdma->revision = dvmarev2; - printk("Revision 2 "); + DPRINTF("Revision 2 "); break; case DMA_VERHME: espdma->revision = dvmahme; - printk("HME DVMA gate array "); + DPRINTF("HME DVMA gate array "); break; case DMA_VERSPLUS: espdma->revision = dvmarevplus; - printk("Revision 1 PLUS "); + DPRINTF("Revision 1 PLUS "); break; default: - printk("unknown dma version %x", + DPRINTF("unknown dma version %x", (espdma->regs->cond_reg) & DMA_DEVICE_ID); /* espdma->allocated = 1; */ break; } - printk("\n"); + DPRINTF("\n");
return 0; } @@ -399,9 +402,7 @@ char nodebuff[256], aliasbuff[256]; esp_private_t *esp;
-#ifdef CONFIG_DEBUG_ESP - printk("Initializing SCSI..."); -#endif + DPRINTF("Initializing SCSI...");
esp = malloc(sizeof(esp_private_t)); global_esp = esp; @@ -412,23 +413,21 @@ /* Get the IO region */ esp->ll = (void *)map_io(PHYS_JJ_ESP, sizeof(struct esp_regs)); if (esp->ll == 0) { - printk("Can't map ESP registers\n"); + DPRINTF("Can't map ESP registers\n"); return -1; }
esp->buffer = (void *)dvma_alloc(BUFSIZE, &esp->buffer_dvma); if (!esp->buffer || !esp->buffer_dvma) { - printk("Can't get a DVMA buffer\n"); + DPRINTF("Can't get a DVMA buffer\n"); return -1; }
// Chip reset esp->ll->regs[ESP_CMD] = ESP_CMD_RC;
-#ifdef CONFIG_DEBUG_ESP - printk("done\n"); - printk("Initializing SCSI devices..."); -#endif + DPRINTF("done\n"); + DPRINTF("Initializing SCSI devices...");
for (id = 0; id < 8; id++) { esp->sd[id].id = id; @@ -475,12 +474,12 @@ add_alias(nodebuff, esp->sd[id].media_str); } sprintf(aliasbuff, "%s%d", esp->sd[id].media_str, *counter_ptr); - (*counter_ptr)++; add_alias(nodebuff, aliasbuff); + sprintf(aliasbuff, "sd(0,%d,0)", id); + add_alias(nodebuff, aliasbuff); + (*counter_ptr)++; } -#ifdef CONFIG_DEBUG_ESP - printk("done\n"); -#endif + DPRINTF("done\n");
return 0; }
Modified: openbios-devel/drivers/iommu.c =================================================================== --- openbios-devel/drivers/iommu.c 2006-05-15 08:17:51 UTC (rev 18) +++ openbios-devel/drivers/iommu.c 2006-05-16 17:36:09 UTC (rev 19) @@ -22,6 +22,14 @@ #define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) #define MKIOPTE(phys) (((((phys)>>4) & IOPTE_PAGE) | IOPERM) & ~IOPTE_WAZ) #define LOWMEMSZ 32 * 1024 * 1024 + +#ifdef CONFIG_DEBUG_IOMMU +#define DPRINTF(fmt, args...) \ + do { printk(fmt , ##args); } while (0) +#else +#define DPRINTF(fmt, args...) +#endif + /* * Allocatable memory chunk. */ @@ -70,12 +78,6 @@ t->curp = begin; }
-static void -mem_fini(struct mem *t) -{ - t->curp = 0; -} - void * mem_alloc(struct mem *t, int size, int align) { @@ -147,7 +149,7 @@ pte |= SRMMU_PRIV; /* Supervisor only access */ } *(uint32_t *)pa2va(pa) = pte; - //printk("map_page: va 0x%lx pa 0x%lx pte 0x%x\n", va, epa, pte); + DPRINTF("map_page: va 0x%lx pa 0x%lx pte 0x%x\n", va, epa, pte);
return 0;
@@ -177,7 +179,7 @@ return va;
mva = (unsigned int) va; - //printk("map_io: va 0x%p pa 0x%x off 0x%x npages %d\n", va, pa, off, npages); /* P3 */ + DPRINTF("map_io: va 0x%p pa 0x%x off 0x%x npages %d\n", va, pa, off, npages); /* P3 */ while (npages-- != 0) { map_page(mva, pa, 1); mva += PAGE_SIZE; @@ -313,7 +315,7 @@ unsigned int tmp;
if ((regs = map_io(PHYS_JJ_IOMMU, sizeof(struct iommu_regs))) == 0) { - printk("Cannot map IOMMU\n"); + DPRINTF("Cannot map IOMMU\n"); for (;;) { } } t->regs = regs; @@ -334,7 +336,7 @@ /* Thremendous alignment causes great waste... */ ptsize = (t->vasize/PAGE_SIZE) * sizeof(int); if ((ptab = mem_zalloc(&cmem, ptsize, ptsize)) == 0) { - printk("Cannot allocate IOMMU table [0x%x]\n", ptsize); + DPRINTF("Cannot allocate IOMMU table [0x%x]\n", ptsize); for (;;) { } } t->page_table = ptab; @@ -344,8 +346,8 @@ regs->base = ((unsigned int)va2pa((unsigned long)ptab)) >> 4; iommu_invalidate(regs);
- printk("IOMMU: impl %d vers %d page table at 0x%p of size %d bytes\n", - impl, vers, t->page_table, ptsize); + DPRINTF("IOMMU: impl %d vers %d page table at 0x%p of size %d bytes\n", + impl, vers, t->page_table, ptsize);
mem_init(&t->bmap, (char*)t->plow, (char *)0xfffff000); }