#include <sys/param.h>
#include <lib/libsa/stand.h>
#include <lib/libkern/libkern.h>
#include <machine/promlib.h>
void prom_patch(void);
static const char *match_c5ip(void);
struct patch_entry {
const char *message;
const char *patch;
};
struct prom_patch {
const char *name;
int promvers;
const char *(*submatch)(void);
const struct patch_entry *patches;
};
static const struct patch_entry patch_js1_obp[] = {
{ "zs: renaming out of the way",
"\" /obio/zs@0,0\" find-device \" fakezs\" name"
" \" /obio/zs@0,100000\" find-device \" fakezs\" name "
" device-end"
},
{ "su: adding \"interrupts\"",
"\" /obio/su\" find-device"
" d# 13 \" interrupts\" integer-attribute"
" device-end"
},
{ "8042: creating node",
"0 0 0 0 \" /obio\" begin-package"
" \" 8042\" name"
" 300060 0 8 reg"
" d# 13 \" interrupts\" integer-attribute"
" end-package"
},
{ NULL, NULL }
};
static const struct patch_entry patch_js1_ofw[] = {
{ "cpu: creating node ",
"0 0 0 0 \" /\" begin-package"
" \" FMI,MB86904\" device-name"
" \" cpu\" device-type"
" 0 \" mid\" integer-property"
" 8 \" sparc-version\" integer-property"
" 4 \" version\" integer-property"
" 0 \" implementation\" integer-property"
" 4 \" psr-version\" integer-property"
" 0 \" psr-implementation\" integer-property"
" d# 100000000 \" clock-frequency\" integer-property"
" d# 4096 \" page-size\" integer-property"
" d# 256 \" mmu-nctx\" integer-property"
" 2 \" ncaches\" integer-property"
" d# 512 \" icache-nlines\" integer-property"
" d# 32 \" icache-line-size\" integer-property"
" 1 \" icache-associativity\" integer-property"
" d# 512 \" dcache-nlines\" integer-property"
" d# 16 \" dcache-line-size\" integer-property"
" 1 \" dcache-associativity\" integer-property"
" 0 0 \" cache-physical?\" property"
" 0 0 \" cache-coherence?\" property"
" end-package"
},
{ "eeprom: adding \"model\"",
"dev /obio/eeprom \" mk48t08\" model device-end"
},
{ "le: deleting bogus \"interrupts\"",
"dev /sbus/ledma/le \" interrupts\" delete-property device-end"
},
{ "su: adding \"interrupts\"",
"dev /obio/su d# 13 \" interrupts\" integer-property device-end"
},
{ "8042: adding \"interrupts\"",
"dev /obio/8042 d# 13 \" interrupts\" integer-property device-end"
},
{ NULL, NULL }
};
static const struct patch_entry patch_c5ip[] = {
{ "SUNW,CS4231: renaming out of the way",
"\" /iommu/sbus/SUNW,CS4231@3,c000000\" find-device \" fakeCS4231\" name"
" device-end"
},
{ NULL, NULL }
};
static const struct patch_entry patch_krups[] = {
{ "sound device node: ",
"\" /pci/ebus/sound\" ' find-device catch"
" 0= if"
" device-end"
" \" ok\""
" else"
" 0 0 0 0 \" /pci/ebus\" begin-package"
" \" sound\" name"
" 200000 1 600 reg"
" end-package"
" \" created\""
" then type"
},
{ NULL, NULL }
};
static const struct prom_patch prom_patch_tab[] = {
{ "SUNW,JavaStation-1", PROM_OBP_V3, NULL, patch_js1_obp },
{ "SUNW,JDM1", PROM_OPENFIRM, NULL, patch_js1_ofw },
{ "SUNW,SPARCstation-5", PROM_OBP_V3, match_c5ip, patch_c5ip },
{ "SUNW,JSIIep", PROM_OPENFIRM, NULL, patch_krups },
{ NULL, 0, NULL }
};
static const char *
match_c5ip(void)
{
if (strcmp(prom_getpropstring(prom_findroot(), "banner-name"),
"Cycle Computer Corporation") == 0)
return "Cycle 5 IP";
return NULL;
}
void
prom_patch(void)
{
char namebuf[32];
char *propval;
const struct prom_patch *p;
if (prom_version() == PROM_OLDMON)
return;
propval = prom_getpropstringA(prom_findroot(), "name",
namebuf, sizeof(namebuf));
if (propval == NULL)
return;
for (p = prom_patch_tab; p->name != NULL; ++p) {
if (p->promvers == prom_version()
&& strcmp(p->name, namebuf) == 0) {
const struct patch_entry *e;
const char *promstr = "???";
const char *submatch_info = NULL;
switch (prom_version()) {
case PROM_OBP_V0:
promstr = "OBP0";
break;
case PROM_OBP_V2:
promstr = "OBP2";
break;
case PROM_OBP_V3:
promstr = "OBP3";
break;
case PROM_OPENFIRM:
promstr = "OFW";
break;
}
if (p->submatch != NULL) {
submatch_info = (*p->submatch)();
if (submatch_info == NULL)
continue;
}
if (submatch_info != NULL)
printf("Patching %s for %s (%s)\n",
promstr, p->name, submatch_info);
else
printf("Patching %s for %s\n",
promstr, p->name);
for (e = p->patches; e->message != NULL; ++e) {
printf("%s", e->message);
prom_interpret(e->patch);
printf("\n");
}
return;
}
}
}