/*
* Copyright (c) 2001 Valeriy E. Ushakov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* PROM patches to apply to machine matching name/promvers.
*/
struct prom_patch {
const char *name; /* "name" of the root node */
int promvers; /* prom_version() */
const char *(*submatch)(void); /* Additional matches to test */
const struct patch_entry *patches; /* The patches themselves */
};
/*
* Patches for JavaStation 1 with OBP 2.30.
* NB: its romvec is version 3, so this is PROM_OBP_V3.
*/
static const struct patch_entry patch_js1_obp[] = {
/*
* Can not remove a node, so just rename bogus /obio/zs so that it
* does not get matched.
*/
{ "zs: renaming out of the way",
"\" /obio/zs@0,0\" find-device \" fakezs\" name"
" \" /obio/zs@0,100000\" find-device \" fakezs\" name "
" device-end"
},
/*
* Patches for JavaStation 1 with OpenFirmware.
* PROM in these machines is crippled in many ways.
*/
static const struct patch_entry patch_js1_ofw[] = {
/*
* JS1/OFW has no CPU node in the device tree. Create one to save us a
* _lot_ of headache in cpu.c and mainbus_attach. Mostly copied from
* OBP2. While clock-frequency is usually at the root node, add it
* here for brevity as kernel checks CPU node for this property anyway.
*/
{ "cpu: creating node ", /* NB: space at the end is intentional */
"0 0 0 0 \" /\" begin-package"
" \" FMI,MB86904\" device-name" /* NB: will print the name */
" \" cpu\" device-type"
" 0 \" mid\" integer-property"
/*
* Can not remove a node, so just rename bogus /iommu/sbus/SUNW,CS4231
* so that it does not get matched.
*/
{ "SUNW,CS4231: renaming out of the way",
"\" /iommu/sbus/SUNW,CS4231@3,c000000\" find-device \" fakeCS4231\" name"
" device-end"
},
/*
* Additional match routine for Cycle 5 IP.
* This uses the SPARCstation 5 PROM almost unchanged, so we check the
* "banner-name" attribute of the root node.
*/
static const char *
match_c5ip(void)
{
if (strcmp(prom_getpropstring(prom_findroot(), "banner-name"),
"Cycle Computer Corporation") == 0)
return "Cycle 5 IP";
return NULL;
}
/*
* Check if this machine needs tweaks to its PROM. It's simpler to fix
* the PROM than to invent workarounds in the kernel code. We do this
* patching in the secondary boot to avoid wasting space in the kernel.
*/
void
prom_patch(void)
{
char namebuf[32];
char *propval;
const struct prom_patch *p;
if (prom_version() == PROM_OLDMON)
return; /* don't bother - no forth in this */