autoconf.c revision 1.106
11.106Sphx/* $NetBSD: autoconf.c,v 1.106 2011/01/13 22:02:05 phx Exp $ */ 21.25Scgd 31.1Smw/* 41.17Schopps * Copyright (c) 1994 Christian E. Hopps 51.1Smw * All rights reserved. 61.1Smw * 71.1Smw * Redistribution and use in source and binary forms, with or without 81.1Smw * modification, are permitted provided that the following conditions 91.1Smw * are met: 101.1Smw * 1. Redistributions of source code must retain the above copyright 111.1Smw * notice, this list of conditions and the following disclaimer. 121.1Smw * 2. Redistributions in binary form must reproduce the above copyright 131.1Smw * notice, this list of conditions and the following disclaimer in the 141.1Smw * documentation and/or other materials provided with the distribution. 151.1Smw * 3. All advertising materials mentioning features or use of this software 161.1Smw * must display the following acknowledgement: 171.17Schopps * This product includes software developed by Christian E. Hopps. 181.17Schopps * 4. The name of the author may not be used to endorse or promote products 191.17Schopps * derived from this software without specific prior written permission 201.4Smw * 211.17Schopps * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.17Schopps * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.17Schopps * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.17Schopps * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.17Schopps * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.17Schopps * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.17Schopps * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.17Schopps * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.17Schopps * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.17Schopps * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1Smw */ 321.80Saymeric 331.80Saymeric#include <sys/cdefs.h> 341.106Sphx__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.106 2011/01/13 22:02:05 phx Exp $"); 351.80Saymeric 361.9Schopps#include <sys/param.h> 371.9Schopps#include <sys/systm.h> 381.17Schopps#include <sys/reboot.h> 391.9Schopps#include <sys/conf.h> 401.46Sthorpej#include <sys/buf.h> 411.17Schopps#include <sys/device.h> 421.17Schopps#include <sys/disklabel.h> 431.46Sthorpej#include <sys/disk.h> 441.90Sthorpej#include <sys/proc.h> 451.19Schopps#include <machine/cpu.h> 461.17Schopps#include <amiga/amiga/cfdev.h> 471.17Schopps#include <amiga/amiga/device.h> 481.9Schopps#include <amiga/amiga/custom.h> 491.104Sphx#ifdef DRACO 501.104Sphx#include <amiga/amiga/drcustom.h> 511.104Sphx#endif 521.1Smw 531.79Saymericstatic void findroot(void); 541.79Saymericvoid mbattach(struct device *, struct device *, void *); 551.79Saymericint mbprint(void *, const char *); 561.79Saymericint mbmatch(struct device *, struct cfdata *, void *); 571.11Schopps 581.17Schopps#include <sys/kernel.h> 591.46Sthorpej 601.47Smhitchu_long boot_partition; 611.81Saymeric 621.81Saymericint amiga_realconfig; 631.46Sthorpej 641.1Smw/* 651.17Schopps * called at boot time, configure all devices on system 661.1Smw */ 671.11Schoppsvoid 681.102Sceggercpu_configure(void) 691.1Smw{ 701.44Sis int s; 711.62Sis#ifdef DEBUG_KERNEL_START 721.62Sis int i; 731.62Sis#endif 741.49Sgwr 751.17Schopps /* 761.17Schopps * this is the real thing baby (i.e. not console init) 771.17Schopps */ 781.17Schopps amiga_realconfig = 1; 791.36Sis#ifdef DRACO 801.36Sis if (is_draco()) { 811.36Sis *draco_intena &= ~DRIRQ_GLOBAL; 821.36Sis } else 831.36Sis#endif 841.3Smw custom.intena = INTF_INTEN; 851.44Sis s = splhigh(); 861.1Smw 871.95Sjmc if (config_rootfound("mainbus", NULL) == NULL) 881.17Schopps panic("no mainbus found"); 891.36Sis 901.39Sis#ifdef DEBUG_KERNEL_START 911.43Schristos printf("survived autoconf, going to enable interrupts\n"); 921.39Sis#endif 931.79Saymeric 941.36Sis#ifdef DRACO 951.36Sis if (is_draco()) { 961.36Sis *draco_intena |= DRIRQ_GLOBAL; 971.36Sis /* softints always enabled */ 981.36Sis } else 991.36Sis#endif 1001.36Sis { 1011.36Sis custom.intena = INTF_SETCLR | INTF_INTEN; 1021.28Schopps 1031.36Sis /* also enable hardware aided software interrupts */ 1041.36Sis custom.intena = INTF_SETCLR | INTF_SOFTINT; 1051.36Sis } 1061.39Sis#ifdef DEBUG_KERNEL_START 1071.62Sis for (i=splhigh(); i>=s ;i-=0x100) { 1081.62Sis splx(i); 1091.62Sis printf("%d...", (i>>8) & 7); 1101.62Sis } 1111.43Schristos printf("survived interrupt enable\n"); 1121.62Sis#else 1131.62Sis splx(s); 1141.39Sis#endif 1151.63Sthorpej#ifdef DEBUG_KERNEL_START 1161.63Sthorpej printf("survived configure...\n"); 1171.63Sthorpej#endif 1181.49Sgwr} 1191.49Sgwr 1201.49Sgwrvoid 1211.102Sceggercpu_rootconf(void) 1221.49Sgwr{ 1231.77Sfrueauf findroot(); 1241.39Sis#ifdef DEBUG_KERNEL_START 1251.46Sthorpej printf("survived findroot()\n"); 1261.39Sis#endif 1271.64Sthorpej setroot(booted_device, booted_partition); 1281.39Sis#ifdef DEBUG_KERNEL_START 1291.43Schristos printf("survived setroot()\n"); 1301.1Smw#endif 1311.17Schopps} 1321.3Smw 1331.17Schopps/*ARGSUSED*/ 1341.17Schoppsint 1351.100Sdslsimple_devprint(void *auxp, const char *pnp) 1361.17Schopps{ 1371.17Schopps return(QUIET); 1381.1Smw} 1391.1Smw 1401.17Schoppsint 1411.101Sdslmatchname(const char *fp, const char *sp) 1421.17Schopps{ 1431.17Schopps int len; 1441.1Smw 1451.17Schopps len = strlen(fp); 1461.17Schopps if (strlen(sp) != len) 1471.17Schopps return(0); 1481.103Scegger if (memcmp(fp, sp, len) == 0) 1491.17Schopps return(1); 1501.17Schopps return(0); 1511.17Schopps} 1521.1Smw 1531.17Schopps/* 1541.96Sdrochner * use config_search_ia to find appropriate device, then call that device 1551.79Saymeric * directly with NULL device variable storage. A device can then 1561.79Saymeric * always tell the difference betwean the real and console init 1571.17Schopps * by checking for NULL. 1581.17Schopps */ 1591.11Schoppsint 1601.100Sdslamiga_config_found(struct cfdata *pcfp, struct device *pdp, void *auxp, cfprint_t pfn) 1611.1Smw{ 1621.17Schopps struct device temp; 1631.17Schopps struct cfdata *cf; 1641.86Sthorpej const struct cfattach *ca; 1651.17Schopps 1661.17Schopps if (amiga_realconfig) 1671.31Scgd return(config_found(pdp, auxp, pfn) != NULL); 1681.17Schopps 1691.89Saymeric if (pdp == NULL) { 1701.89Saymeric memset(&temp, 0, sizeof temp); 1711.17Schopps pdp = &temp; 1721.89Saymeric } 1731.17Schopps 1741.17Schopps pdp->dv_cfdata = pcfp; 1751.88Saymeric pdp->dv_cfdriver = config_cfdriver_lookup(pcfp->cf_name); 1761.91Saymeric pdp->dv_unit = pcfp->cf_unit; 1771.89Saymeric 1781.97Sisaki if ((cf = config_search_ia(NULL, pdp, NULL, auxp)) != NULL) { 1791.86Sthorpej ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname); 1801.86Sthorpej if (ca != NULL) { 1811.86Sthorpej (*ca->ca_attach)(pdp, NULL, auxp); 1821.86Sthorpej pdp->dv_cfdata = NULL; 1831.86Sthorpej return(1); 1841.86Sthorpej } 1851.1Smw } 1861.17Schopps pdp->dv_cfdata = NULL; 1871.17Schopps return(0); 1881.17Schopps} 1891.17Schopps 1901.17Schopps/* 1911.17Schopps * this function needs to get enough configured to do a console 1921.79Saymeric * basically this means start attaching the grfxx's that support 1931.17Schopps * the console. Kinda hacky but it works. 1941.17Schopps */ 1951.32Sveegovoid 1961.102Sceggerconfig_console(void) 1971.79Saymeric{ 1981.17Schopps struct cfdata *cf; 1991.84Sthorpej 2001.84Sthorpej config_init(); 2011.36Sis 2021.17Schopps /* 2031.17Schopps * we need mainbus' cfdata. 2041.17Schopps */ 2051.95Sjmc cf = config_rootsearch(NULL, "mainbus", NULL); 2061.36Sis if (cf == NULL) { 2071.17Schopps panic("no mainbus"); 2081.36Sis } 2091.1Smw /* 2101.44Sis * delay clock calibration. 2111.44Sis */ 2121.95Sjmc amiga_config_found(cf, NULL, __UNCONST("clock"), NULL); 2131.44Sis 2141.44Sis /* 2151.17Schopps * internal grf. 2161.1Smw */ 2171.36Sis#ifdef DRACO 2181.36Sis if (!(is_draco())) 2191.36Sis#endif 2201.95Sjmc amiga_config_found(cf, NULL, __UNCONST("grfcc"), NULL); 2211.67Saymeric 2221.1Smw /* 2231.27Schopps * zbus knows when its not for real and will 2241.21Schopps * only configure the appropriate hardware 2251.1Smw */ 2261.95Sjmc amiga_config_found(cf, NULL, __UNCONST("zbus"), NULL); 2271.1Smw} 2281.1Smw 2291.79Saymeric/* 2301.79Saymeric * mainbus driver 2311.17Schopps */ 2321.85SthorpejCFATTACH_DECL(mainbus, sizeof(struct device), 2331.85Sthorpej mbmatch, mbattach, NULL, NULL); 2341.17Schopps 2351.11Schoppsint 2361.100Sdslmbmatch(struct device *pdp, struct cfdata *cfp, void *auxp) 2371.1Smw{ 2381.72Sis#if 0 /* 2391.72Sis * XXX is this right? but we need to be found twice 2401.72Sis * (early console init hack) 2411.72Sis */ 2421.71Skleink static int mainbus_matched = 0; 2431.30Sthorpej 2441.71Skleink /* Allow only one instance. */ 2451.71Skleink if (mainbus_matched) 2461.71Skleink return (0); 2471.71Skleink 2481.71Skleink mainbus_matched = 1; 2491.72Sis#endif 2501.71Skleink return (1); 2511.1Smw} 2521.1Smw 2531.1Smw/* 2541.17Schopps * "find" all the things that should be there. 2551.1Smw */ 2561.11Schoppsvoid 2571.101Sdslmbattach(struct device *pdp, struct device *dp, void *auxp) 2581.1Smw{ 2591.43Schristos printf("\n"); 2601.95Sjmc config_found(dp, __UNCONST("clock"), simple_devprint); 2611.52Sis if (is_a3000() || is_a4000()) { 2621.95Sjmc config_found(dp, __UNCONST("a34kbbc"), simple_devprint); 2631.58Sis } else 2641.53Sis#ifdef DRACO 2651.58Sis if (!is_draco()) 2661.53Sis#endif 2671.58Sis { 2681.95Sjmc config_found(dp, __UNCONST("a2kbbc"), simple_devprint); 2691.52Sis } 2701.36Sis#ifdef DRACO 2711.36Sis if (is_draco()) { 2721.95Sjmc config_found(dp, __UNCONST("drbbc"), simple_devprint); 2731.95Sjmc config_found(dp, __UNCONST("kbd"), simple_devprint); 2741.95Sjmc config_found(dp, __UNCONST("drsc"), simple_devprint); 2751.95Sjmc config_found(dp, __UNCONST("drsupio"), simple_devprint); 2761.79Saymeric } else 2771.36Sis#endif 2781.36Sis { 2791.95Sjmc config_found(dp, __UNCONST("ser"), simple_devprint); 2801.95Sjmc config_found(dp, __UNCONST("par"), simple_devprint); 2811.95Sjmc config_found(dp, __UNCONST("kbd"), simple_devprint); 2821.95Sjmc config_found(dp, __UNCONST("ms"), simple_devprint); 2831.95Sjmc config_found(dp, __UNCONST("grfcc"), simple_devprint); 2841.95Sjmc config_found(dp, __UNCONST("amidisplaycc"), simple_devprint); 2851.95Sjmc config_found(dp, __UNCONST("fdc"), simple_devprint); 2861.36Sis } 2871.106Sphx if (is_a4000() || is_a1200() || is_a600()) 2881.95Sjmc config_found(dp, __UNCONST("wdc"), simple_devprint); 2891.29Schopps if (is_a4000()) /* Try to configure A4000T SCSI */ 2901.95Sjmc config_found(dp, __UNCONST("afsc"), simple_devprint); 2911.17Schopps if (is_a3000()) 2921.95Sjmc config_found(dp, __UNCONST("ahsc"), simple_devprint); 2931.106Sphx if (is_a600() || is_a1200()) 2941.95Sjmc config_found(dp, __UNCONST("pccard"), simple_devprint); 2951.54Sis#ifdef DRACO 2961.54Sis if (!is_draco()) 2971.54Sis#endif 2981.95Sjmc config_found(dp, __UNCONST("aucc"), simple_devprint); 2991.54Sis 3001.95Sjmc config_found(dp, __UNCONST("zbus"), simple_devprint); 3011.1Smw} 3021.1Smw 3031.11Schoppsint 3041.100Sdslmbprint(void *auxp, const char *pnp) 3051.1Smw{ 3061.17Schopps if (pnp) 3071.87Sthorpej aprint_normal("%s at %s", (char *)auxp, pnp); 3081.17Schopps return(UNCONF); 3091.1Smw} 3101.1Smw 3111.46Sthorpej/* 3121.46Sthorpej * The system will assign the "booted device" indicator (and thus 3131.46Sthorpej * rootdev if rootspec is wildcarded) to the first partition 'a' 3141.46Sthorpej * in preference of boot. However, it does walk unit backwards 3151.46Sthorpej * to remain compatible with the old Amiga method of picking the 3161.46Sthorpej * last root found. 3171.46Sthorpej */ 3181.46Sthorpej#include <sys/fcntl.h> /* XXXX and all that uses it */ 3191.46Sthorpej#include <sys/proc.h> /* XXXX and all that uses it */ 3201.17Schopps 3211.46Sthorpej#include "fd.h" 3221.46Sthorpej#include "sd.h" 3231.46Sthorpej#include "cd.h" 3241.67Saymeric#include "wd.h" 3251.1Smw 3261.46Sthorpej#if NFD > 0 3271.46Sthorpejextern struct cfdriver fd_cd; 3281.82Sgehennaextern const struct bdevsw fd_bdevsw; 3291.46Sthorpej#endif 3301.46Sthorpej#if NSD > 0 3311.69Smhitchextern struct cfdriver sd_cd; 3321.82Sgehennaextern const struct bdevsw sd_bdevsw; 3331.46Sthorpej#endif 3341.46Sthorpej#if NCD > 0 3351.46Sthorpejextern struct cfdriver cd_cd; 3361.82Sgehennaextern const struct bdevsw cd_bdevsw; 3371.46Sthorpej#endif 3381.67Saymeric#if NWD > 0 3391.69Smhitchextern struct cfdriver wd_cd; 3401.82Sgehennaextern const struct bdevsw wd_bdevsw; 3411.67Saymeric#endif 3421.1Smw 3431.46Sthorpejstruct cfdriver *genericconf[] = { 3441.46Sthorpej#if NFD > 0 3451.46Sthorpej &fd_cd, 3461.46Sthorpej#endif 3471.46Sthorpej#if NSD > 0 3481.46Sthorpej &sd_cd, 3491.46Sthorpej#endif 3501.69Smhitch#if NWD > 0 3511.69Smhitch &wd_cd, 3521.69Smhitch#endif 3531.46Sthorpej#if NCD > 0 3541.46Sthorpej &cd_cd, 3551.46Sthorpej#endif 3561.46Sthorpej NULL, 3571.1Smw}; 3581.1Smw 3591.11Schoppsvoid 3601.76Smattfindroot(void) 3611.1Smw{ 3621.46Sthorpej struct disk *dkp; 3631.46Sthorpej struct partition *pp; 3641.99Scegger device_t *devs; 3651.46Sthorpej int i, maj, unit; 3661.82Sgehenna const struct bdevsw *bdp; 3671.47Smhitch 3681.47Smhitch#if NSD > 0 3691.47Smhitch /* 3701.47Smhitch * If we have the boot partition offset (boot_partition), try 3711.47Smhitch * to locate the device corresponding to that partition. 3721.47Smhitch */ 3731.56Sis#ifdef DEBUG_KERNEL_START 3741.56Sis printf("Boot partition offset is %ld\n", boot_partition); 3751.56Sis#endif 3761.47Smhitch if (boot_partition != 0) { 3771.47Smhitch 3781.47Smhitch for (unit = 0; unit < sd_cd.cd_ndevs; ++unit) { 3791.56Sis#ifdef DEBUG_KERNEL_START 3801.56Sis printf("probing for sd%d\n", unit); 3811.56Sis#endif 3821.99Scegger if (device_lookup(&sd_cd,unit) == NULL) 3831.47Smhitch continue; 3841.47Smhitch 3851.47Smhitch /* 3861.47Smhitch * Find the disk corresponding to the current 3871.47Smhitch * device. 3881.47Smhitch */ 3891.99Scegger devs = (device_t *)sd_cd.cd_devs; 3901.99Scegger if ((dkp = disk_find(device_xname(device_lookup(&sd_cd, unit)))) == NULL) 3911.47Smhitch continue; 3921.47Smhitch 3931.47Smhitch if (dkp->dk_driver == NULL || 3941.47Smhitch dkp->dk_driver->d_strategy == NULL) 3951.47Smhitch continue; 3961.82Sgehenna bdp = &sd_bdevsw; 3971.82Sgehenna maj = bdevsw_lookup_major(bdp); 3981.82Sgehenna if ((*bdp->d_open)(MAKEDISKDEV(maj, unit, RAW_PART), 3991.98Schristos FREAD | FNONBLOCK, 0, curlwp)) 4001.47Smhitch continue; 4011.82Sgehenna (*bdp->d_close)(MAKEDISKDEV(maj, unit, RAW_PART), 4021.98Schristos FREAD | FNONBLOCK, 0, curlwp); 4031.47Smhitch pp = &dkp->dk_label->d_partitions[0]; 4041.54Sis for (i = 0; i < dkp->dk_label->d_npartitions; 4051.54Sis i++, pp++) { 4061.56Sis#ifdef DEBUG_KERNEL_START 4071.56Sis printf("sd%d%c type %d offset %d size %d\n", 4081.56Sis unit, i+'a', pp->p_fstype, 4091.56Sis pp->p_offset, pp->p_size); 4101.56Sis#endif 4111.54Sis if (pp->p_size == 0 || 4121.54Sis (pp->p_fstype != FS_BSDFFS && 4131.54Sis pp->p_fstype != FS_SWAP)) 4141.54Sis continue; 4151.54Sis if (pp->p_offset == boot_partition) { 4161.76Smatt if (booted_device == NULL) { 4171.76Smatt booted_device = devs[unit]; 4181.76Smatt booted_partition = i; 4191.54Sis } else 4201.54Sis printf("Ambiguous boot device\n"); 4211.54Sis } 4221.47Smhitch } 4231.47Smhitch } 4241.47Smhitch } 4251.76Smatt if (booted_device != NULL) 4261.47Smhitch return; /* we found the boot device */ 4271.47Smhitch#endif 4281.46Sthorpej 4291.46Sthorpej for (i = 0; genericconf[i] != NULL; i++) { 4301.46Sthorpej for (unit = genericconf[i]->cd_ndevs - 1; unit >= 0; unit--) { 4311.46Sthorpej if (genericconf[i]->cd_devs[unit] == NULL) 4321.46Sthorpej continue; 4331.46Sthorpej 4341.46Sthorpej /* 4351.46Sthorpej * Find the disk structure corresponding to the 4361.46Sthorpej * current device. 4371.46Sthorpej */ 4381.99Scegger devs = (device_t *)genericconf[i]->cd_devs; 4391.99Scegger if ((dkp = disk_find(device_xname(devs[unit]))) == NULL) 4401.46Sthorpej continue; 4411.46Sthorpej 4421.46Sthorpej if (dkp->dk_driver == NULL || 4431.46Sthorpej dkp->dk_driver->d_strategy == NULL) 4441.46Sthorpej continue; 4451.46Sthorpej 4461.92Smhitch bdp = NULL; 4471.82Sgehenna#if NFD > 0 4481.82Sgehenna if (fd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4491.82Sgehenna bdp = &fd_bdevsw; 4501.82Sgehenna#endif 4511.82Sgehenna#if NSD > 0 4521.82Sgehenna if (sd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4531.82Sgehenna bdp = &sd_bdevsw; 4541.82Sgehenna#endif 4551.82Sgehenna#if NWD > 0 4561.82Sgehenna if (wd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4571.82Sgehenna bdp = &wd_bdevsw; 4581.82Sgehenna#endif 4591.82Sgehenna#if NCD > 0 4601.82Sgehenna if (cd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4611.82Sgehenna bdp = &cd_bdevsw; 4621.82Sgehenna#endif 4631.46Sthorpej#ifdef DIAGNOSTIC 4641.82Sgehenna if (bdp == NULL) 4651.46Sthorpej panic("findroot: impossible"); 4661.46Sthorpej#endif 4671.82Sgehenna maj = bdevsw_lookup_major(bdp); 4681.46Sthorpej 4691.46Sthorpej /* Open disk; forces read of disklabel. */ 4701.82Sgehenna if ((*bdp->d_open)(MAKEDISKDEV(maj, 4711.98Schristos unit, 0), FREAD|FNONBLOCK, 0, &lwp0)) 4721.46Sthorpej continue; 4731.82Sgehenna (void)(*bdp->d_close)(MAKEDISKDEV(maj, 4741.98Schristos unit, 0), FREAD|FNONBLOCK, 0, &lwp0); 4751.46Sthorpej 4761.46Sthorpej pp = &dkp->dk_label->d_partitions[0]; 4771.46Sthorpej if (pp->p_size != 0 && pp->p_fstype == FS_BSDFFS) { 4781.76Smatt booted_device = devs[unit]; 4791.76Smatt booted_partition = 0; 4801.46Sthorpej return; 4811.46Sthorpej } 4821.1Smw } 4831.1Smw } 4841.3Smw} 4851.17Schopps 4861.11Schopps/* 4871.11Schopps * Try to determine, of this machine is an A3000, which has a builtin 4881.11Schopps * realtime clock and scsi controller, so that this hardware is only 4891.11Schopps * included as "configured" if this IS an A3000 4901.11Schopps */ 4911.5Smw 4921.5Smwint a3000_flag = 1; /* patchable */ 4931.5Smw#ifdef A4000 4941.5Smwint a4000_flag = 1; /* patchable - default to A4000 */ 4951.5Smw#else 4961.5Smwint a4000_flag = 0; /* patchable */ 4971.5Smw#endif 4981.5Smw 4991.3Smwint 5001.11Schoppsis_a3000() 5011.3Smw{ 5021.11Schopps /* this is a dirty kludge.. but how do you do this RIGHT ? :-) */ 5031.22Schopps extern long boot_fphystart; 5041.11Schopps short sc; 5051.11Schopps 5061.19Schopps if ((machineid >> 16) == 3000) 5071.19Schopps return (1); /* It's an A3000 */ 5081.19Schopps if (machineid >> 16) 5091.19Schopps return (0); /* It's not an A3000 */ 5101.19Schopps /* Machine type is unknown, so try to guess it */ 5111.11Schopps /* where is fastram on the A4000 ?? */ 5121.11Schopps /* if fastram is below 0x07000000, assume it's not an A3000 */ 5131.22Schopps if (boot_fphystart < 0x07000000) 5141.17Schopps return(0); 5151.11Schopps /* 5161.11Schopps * OK, fastram starts at or above 0x07000000, check specific 5171.11Schopps * machines 5181.11Schopps */ 5191.17Schopps for (sc = 0; sc < ncfdev; sc++) { 5201.17Schopps switch (cfdev[sc].rom.manid) { 5211.17Schopps case 2026: /* Progressive Peripherals, Inc */ 5221.17Schopps switch (cfdev[sc].rom.prodid) { 5231.17Schopps case 0: /* PPI Mercury - A3000 */ 5241.17Schopps case 1: /* PP&S A3000 '040 */ 5251.17Schopps return(1); 5261.17Schopps case 150: /* PPI Zeus - it's an A2000 */ 5271.17Schopps case 105: /* PP&S A2000 '040 */ 5281.17Schopps case 187: /* PP&S A500 '040 */ 5291.17Schopps return(0); 5301.11Schopps } 5311.11Schopps break; 5321.3Smw 5331.17Schopps case 2112: /* IVS */ 5341.17Schopps switch (cfdev[sc].rom.prodid) { 5351.17Schopps case 242: 5361.17Schopps return(0); /* A2000 accelerator? */ 5371.11Schopps } 5381.11Schopps break; 5391.11Schopps } 5401.11Schopps } 5411.17Schopps return (a3000_flag); /* XXX let flag tell now */ 5421.5Smw} 5431.5Smw 5441.5Smwint 5451.11Schoppsis_a4000() 5461.5Smw{ 5471.19Schopps if ((machineid >> 16) == 4000) 5481.19Schopps return (1); /* It's an A4000 */ 5491.24Schopps if ((machineid >> 16) == 1200) 5501.24Schopps return (0); /* It's an A1200, so not A4000 */ 5511.36Sis#ifdef DRACO 5521.36Sis if (is_draco()) 5531.36Sis return (0); 5541.36Sis#endif 5551.24Schopps /* Do I need this any more? */ 5561.19Schopps if ((custom.deniseid & 0xff) == 0xf8) 5571.19Schopps return (1); 5581.19Schopps#ifdef DEBUG 5591.19Schopps if (a4000_flag) 5601.43Schristos printf("Denise ID = %04x\n", (unsigned short)custom.deniseid); 5611.19Schopps#endif 5621.19Schopps if (machineid >> 16) 5631.19Schopps return (0); /* It's not an A4000 */ 5641.19Schopps return (a4000_flag); /* Machine type not set */ 5651.24Schopps} 5661.24Schopps 5671.24Schoppsint 5681.24Schoppsis_a1200() 5691.24Schopps{ 5701.24Schopps if ((machineid >> 16) == 1200) 5711.24Schopps return (1); /* It's an A1200 */ 5721.24Schopps return (0); /* Machine type not set */ 5731.1Smw} 5741.106Sphx 5751.106Sphxint 5761.106Sphxis_a600() 5771.106Sphx{ 5781.106Sphx if ((machineid >> 16) == 600) 5791.106Sphx return (1); /* It's an A600 */ 5801.106Sphx return (0); /* Machine type not set */ 5811.106Sphx} 582