new sparc merge

git-svn-id: svn://coreboot.org/openbios/openbios-devel@19 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Stefan Reinauer
2006-05-16 17:36:09 +00:00
parent 1d33aa0ec0
commit 3b61f3011b
5 changed files with 141 additions and 74 deletions

View File

@@ -42,6 +42,8 @@ static int obp_proplen(int node, char *name);
static int obp_getprop(int node, char *name, char *val); static int obp_getprop(int node, char *name, char *val);
static int obp_setprop(int node, char *name, char *val, int len); static int obp_setprop(int node, char *name, char *val, int len);
static const char *obp_nextprop(int node, char *name); 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 = { static const struct linux_nodeops nodeops0 = {
obp_nextnode, /* int (*no_nextnode)(int node); */ obp_nextnode, /* int (*no_nextnode)(int node); */
@@ -167,14 +169,36 @@ static int obp_setprop(__attribute__((unused)) int node,
static const char *obp_nextprop(int node, char *name) static const char *obp_nextprop(int node, char *name)
{ {
char *ret;
int found;
if (!name || *name == '\0') { if (!name || *name == '\0') {
// NULL name means get first property // NULL name means get first property
DPRINTF("obp_nextprop(%x, NULL)\n", node); push_str("");
return 0; 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) static int obp_nbgetchar(void)
@@ -214,35 +238,40 @@ static int obp_devopen(char *str)
{ {
int ret; int ret;
DPRINTF("obp_devopen(%s)\n", str);
push_str(str); push_str(str);
fword("open-dev"); fword("open-dev");
ret = POP(); ret = POP();
DPRINTF("obp_devopen(%s) = 0x%x\n", str, ret);
return 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) 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); ret = obp_devseek(dev_desc, hi, lo);
PUSH(offset);
PUSH(num_blks); ret = obp_devread(dev_desc, buf, num_blks * bs) / bs;
push_str("read-blocks");
PUSH(dev_desc); 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);
fword("$call-method");
ret = POP();
return ret; return ret;
} }
@@ -277,30 +306,63 @@ static void obp_dumb_munmap(__attribute__((unused)) char *va,
static int obp_devread(int dev_desc, char *buf, int nbytes) 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) 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; 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) 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, static int obp_cpustart(unsigned int whichcpu, int ctxtbl_ptr,
@@ -415,7 +477,7 @@ init_openprom(unsigned long memsize, const char *cmdline, char boot_device)
romvec0.pv_v2devops.v2_dev_write = obp_devwrite; romvec0.pv_v2devops.v2_dev_write = obp_devwrite;
romvec0.pv_v2devops.v2_dev_seek = obp_devseek; romvec0.pv_v2devops.v2_dev_seek = obp_devseek;
obp_arg.boot_dev_ctrl = 0; 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"; obp_arg.argv[0] = "sd(0,0,0):d";
switch(boot_device) { switch(boot_device) {
@@ -444,6 +506,8 @@ init_openprom(unsigned long memsize, const char *cmdline, char boot_device)
romvec0.pv_v2bootargs.bootargs = &cmdline; romvec0.pv_v2bootargs.bootargs = &cmdline;
romvec0.pv_v2bootargs.fd_stdin = &obp_fd_stdin; romvec0.pv_v2bootargs.fd_stdin = &obp_fd_stdin;
romvec0.pv_v2bootargs.fd_stdout = &obp_fd_stdout; romvec0.pv_v2bootargs.fd_stdout = &obp_fd_stdout;
obp_stdin = PROMDEV_TTYA;
obp_stdout = PROMDEV_TTYA;
romvec0.v3_cpustart = obp_cpustart; romvec0.v3_cpustart = obp_cpustart;
romvec0.v3_cpustop = obp_cpustop; romvec0.v3_cpustop = obp_cpustop;

View File

@@ -18,7 +18,7 @@
<!-- Kernel Debugging --> <!-- Kernel Debugging -->
<option name="CONFIG_DEBUG" type="boolean" value="true"/> <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_DSTACK" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_RSTACK" type="boolean" value="false"/> <option name="CONFIG_DEBUG_RSTACK" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_DICTIONARY" 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_ESP" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_SUN_PARTS" 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_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_PORT" type="integer" value="0"/>
<option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/> <option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/>

View File

@@ -18,7 +18,7 @@
<!-- Kernel Debugging --> <!-- Kernel Debugging -->
<option name="CONFIG_DEBUG" type="boolean" value="true"/> <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_DSTACK" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_RSTACK" type="boolean" value="false"/> <option name="CONFIG_DEBUG_RSTACK" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_DICTIONARY" 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_ESP" type="boolean" value="false"/>
<option name="CONFIG_DEBUG_SUN_PARTS" 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_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_PORT" type="integer" value="0"/>
<option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/> <option name="CONFIG_SERIAL_SPEED" type="integer" value="115200"/>

View File

@@ -42,6 +42,13 @@
paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \ paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
} while(0) } 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 { struct esp_dma {
volatile struct sparc_dma_registers *regs; volatile struct sparc_dma_registers *regs;
enum dvma_rev revision; enum dvma_rev revision;
@@ -134,9 +141,8 @@ do_command(esp_private_t *esp, sd_private_t *sd, int cmdlen, int replylen)
static int static int
ob_sd_read_sectors(esp_private_t *esp, sd_private_t *sd, int offset, void *dest, short len) ob_sd_read_sectors(esp_private_t *esp, sd_private_t *sd, int offset, void *dest, short len)
{ {
#ifdef CONFIG_DEBUG_ESP DPRINTF("ob_sd_read_sectors id %d %lx block=%d len=%d\n", sd->id, (unsigned long)dest, offset, len);
printk("ob_sd_read_sectors id %d %lx block=%d len=%d\n", sd->id, (unsigned long)dest, offset, len);
#endif
// Setup command = Read(10) // Setup command = Read(10)
memset(esp->buffer, 0, 10); memset(esp->buffer, 0, 10);
esp->buffer[0] = 0x80; esp->buffer[0] = 0x80;
@@ -226,14 +232,12 @@ ob_sd_read_blocks(sd_private_t **sd)
ucell blk = POP(); ucell blk = POP();
char *dest = (char*)POP(); char *dest = (char*)POP();
#ifdef CONFIG_DEBUG_ESP DPRINTF("ob_sd_read_blocks id %d %lx block=%d n=%d\n", (*sd)->id, (unsigned long)dest, blk, n );
printk("ob_sd_read_blocks id %d %lx block=%d n=%d\n", (*sd)->id, (unsigned long)dest, blk, n );
#endif
n *= (*sd)->bs / 512; n *= (*sd)->bs / 512;
while (n) { while (n) {
if (ob_sd_read_sectors(global_esp, *sd, blk, dest, 1)) { 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); RET(0);
} }
dest += (*sd)->bs; dest += (*sd)->bs;
@@ -259,9 +263,8 @@ ob_sd_open(__attribute__((unused))sd_private_t **sd)
id = POP(); id = POP();
*sd = &global_esp->sd[id]; *sd = &global_esp->sd[id];
#ifdef CONFIG_DEBUG_ESP DPRINTF("opening drive %d\n", id);
printk("opening drive %d\n", id);
#endif
selfword("open-deblocker"); selfword("open-deblocker");
/* interpose disk-label */ /* interpose disk-label */
@@ -294,45 +297,45 @@ espdma_init(struct esp_dma *espdma)
/* Hardcode everything for MrCoffee. */ /* Hardcode everything for MrCoffee. */
if ((p = (void *)map_io(PHYS_JJ_ESPDMA, 0x10)) == 0) { 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; return -1;
} }
espdma->regs = p; espdma->regs = p;
printk("dma1: "); DPRINTF("dma1: ");
switch ((espdma->regs->cond_reg) & DMA_DEVICE_ID) { switch ((espdma->regs->cond_reg) & DMA_DEVICE_ID) {
case DMA_VERS0: case DMA_VERS0:
espdma->revision = dvmarev0; espdma->revision = dvmarev0;
printk("Revision 0 "); DPRINTF("Revision 0 ");
break; break;
case DMA_ESCV1: case DMA_ESCV1:
espdma->revision = dvmaesc1; espdma->revision = dvmaesc1;
printk("ESC Revision 1 "); DPRINTF("ESC Revision 1 ");
break; break;
case DMA_VERS1: case DMA_VERS1:
espdma->revision = dvmarev1; espdma->revision = dvmarev1;
printk("Revision 1 "); DPRINTF("Revision 1 ");
break; break;
case DMA_VERS2: case DMA_VERS2:
espdma->revision = dvmarev2; espdma->revision = dvmarev2;
printk("Revision 2 "); DPRINTF("Revision 2 ");
break; break;
case DMA_VERHME: case DMA_VERHME:
espdma->revision = dvmahme; espdma->revision = dvmahme;
printk("HME DVMA gate array "); DPRINTF("HME DVMA gate array ");
break; break;
case DMA_VERSPLUS: case DMA_VERSPLUS:
espdma->revision = dvmarevplus; espdma->revision = dvmarevplus;
printk("Revision 1 PLUS "); DPRINTF("Revision 1 PLUS ");
break; break;
default: default:
printk("unknown dma version %x", DPRINTF("unknown dma version %x",
(espdma->regs->cond_reg) & DMA_DEVICE_ID); (espdma->regs->cond_reg) & DMA_DEVICE_ID);
/* espdma->allocated = 1; */ /* espdma->allocated = 1; */
break; break;
} }
printk("\n"); DPRINTF("\n");
return 0; return 0;
} }
@@ -399,9 +402,7 @@ int ob_esp_init(void)
char nodebuff[256], aliasbuff[256]; char nodebuff[256], aliasbuff[256];
esp_private_t *esp; esp_private_t *esp;
#ifdef CONFIG_DEBUG_ESP DPRINTF("Initializing SCSI...");
printk("Initializing SCSI...");
#endif
esp = malloc(sizeof(esp_private_t)); esp = malloc(sizeof(esp_private_t));
global_esp = esp; global_esp = esp;
@@ -412,23 +413,21 @@ int ob_esp_init(void)
/* Get the IO region */ /* Get the IO region */
esp->ll = (void *)map_io(PHYS_JJ_ESP, sizeof(struct esp_regs)); esp->ll = (void *)map_io(PHYS_JJ_ESP, sizeof(struct esp_regs));
if (esp->ll == 0) { if (esp->ll == 0) {
printk("Can't map ESP registers\n"); DPRINTF("Can't map ESP registers\n");
return -1; return -1;
} }
esp->buffer = (void *)dvma_alloc(BUFSIZE, &esp->buffer_dvma); esp->buffer = (void *)dvma_alloc(BUFSIZE, &esp->buffer_dvma);
if (!esp->buffer || !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; return -1;
} }
// Chip reset // Chip reset
esp->ll->regs[ESP_CMD] = ESP_CMD_RC; esp->ll->regs[ESP_CMD] = ESP_CMD_RC;
#ifdef CONFIG_DEBUG_ESP DPRINTF("done\n");
printk("done\n"); DPRINTF("Initializing SCSI devices...");
printk("Initializing SCSI devices...");
#endif
for (id = 0; id < 8; id++) { for (id = 0; id < 8; id++) {
esp->sd[id].id = id; esp->sd[id].id = id;
@@ -475,12 +474,12 @@ int ob_esp_init(void)
add_alias(nodebuff, esp->sd[id].media_str); add_alias(nodebuff, esp->sd[id].media_str);
} }
sprintf(aliasbuff, "%s%d", esp->sd[id].media_str, *counter_ptr); sprintf(aliasbuff, "%s%d", esp->sd[id].media_str, *counter_ptr);
(*counter_ptr)++;
add_alias(nodebuff, aliasbuff); add_alias(nodebuff, aliasbuff);
sprintf(aliasbuff, "sd(0,%d,0)", id);
add_alias(nodebuff, aliasbuff);
(*counter_ptr)++;
} }
#ifdef CONFIG_DEBUG_ESP DPRINTF("done\n");
printk("done\n");
#endif
return 0; return 0;
} }

View File

@@ -22,6 +22,14 @@
#define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID) #define IOPERM (IOPTE_CACHE | IOPTE_WRITE | IOPTE_VALID)
#define MKIOPTE(phys) (((((phys)>>4) & IOPTE_PAGE) | IOPERM) & ~IOPTE_WAZ) #define MKIOPTE(phys) (((((phys)>>4) & IOPTE_PAGE) | IOPERM) & ~IOPTE_WAZ)
#define LOWMEMSZ 32 * 1024 * 1024 #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. * Allocatable memory chunk.
*/ */
@@ -70,12 +78,6 @@ mem_init(struct mem *t, char *begin, char *limit)
t->curp = begin; t->curp = begin;
} }
static void
mem_fini(struct mem *t)
{
t->curp = 0;
}
void * void *
mem_alloc(struct mem *t, int size, int align) mem_alloc(struct mem *t, int size, int align)
{ {
@@ -147,7 +149,7 @@ map_page(unsigned long va, unsigned long epa, int type)
pte |= SRMMU_PRIV; /* Supervisor only access */ pte |= SRMMU_PRIV; /* Supervisor only access */
} }
*(uint32_t *)pa2va(pa) = pte; *(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; return 0;
@@ -177,7 +179,7 @@ map_io(unsigned pa, int size)
return va; return va;
mva = (unsigned int) 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) { while (npages-- != 0) {
map_page(mva, pa, 1); map_page(mva, pa, 1);
mva += PAGE_SIZE; mva += PAGE_SIZE;
@@ -313,7 +315,7 @@ iommu_init(struct iommu *t)
unsigned int tmp; unsigned int tmp;
if ((regs = map_io(PHYS_JJ_IOMMU, sizeof(struct iommu_regs))) == 0) { if ((regs = map_io(PHYS_JJ_IOMMU, sizeof(struct iommu_regs))) == 0) {
printk("Cannot map IOMMU\n"); DPRINTF("Cannot map IOMMU\n");
for (;;) { } for (;;) { }
} }
t->regs = regs; t->regs = regs;
@@ -334,7 +336,7 @@ iommu_init(struct iommu *t)
/* Thremendous alignment causes great waste... */ /* Thremendous alignment causes great waste... */
ptsize = (t->vasize/PAGE_SIZE) * sizeof(int); ptsize = (t->vasize/PAGE_SIZE) * sizeof(int);
if ((ptab = mem_zalloc(&cmem, ptsize, ptsize)) == 0) { 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 (;;) { } for (;;) { }
} }
t->page_table = ptab; t->page_table = ptab;
@@ -344,7 +346,7 @@ iommu_init(struct iommu *t)
regs->base = ((unsigned int)va2pa((unsigned long)ptab)) >> 4; regs->base = ((unsigned int)va2pa((unsigned long)ptab)) >> 4;
iommu_invalidate(regs); iommu_invalidate(regs);
printk("IOMMU: impl %d vers %d page table at 0x%p of size %d bytes\n", DPRINTF("IOMMU: impl %d vers %d page table at 0x%p of size %d bytes\n",
impl, vers, t->page_table, ptsize); impl, vers, t->page_table, ptsize);
mem_init(&t->bmap, (char*)t->plow, (char *)0xfffff000); mem_init(&t->bmap, (char*)t->plow, (char *)0xfffff000);