autoconf.c revision 1.92
11.92Smhitch/* $NetBSD: autoconf.c,v 1.92 2003/10/27 09:56:56 mhitch 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.92Smhitch__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.92 2003/10/27 09:56:56 mhitch 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.1Smw 501.79Saymericstatic void findroot(void); 511.79Saymericvoid mbattach(struct device *, struct device *, void *); 521.79Saymericint mbprint(void *, const char *); 531.79Saymericint mbmatch(struct device *, struct cfdata *, void *); 541.11Schopps 551.17Schopps#include <sys/kernel.h> 561.46Sthorpej 571.47Smhitchu_long boot_partition; 581.74Smattstruct device *booted_device; 591.74Smattint booted_partition; 601.81Saymeric 611.81Saymericint amiga_realconfig; 621.46Sthorpej 631.1Smw/* 641.17Schopps * called at boot time, configure all devices on system 651.1Smw */ 661.11Schoppsvoid 671.65Sthorpejcpu_configure() 681.1Smw{ 691.44Sis int s; 701.62Sis#ifdef DEBUG_KERNEL_START 711.62Sis int i; 721.62Sis#endif 731.49Sgwr 741.17Schopps /* 751.17Schopps * this is the real thing baby (i.e. not console init) 761.17Schopps */ 771.17Schopps amiga_realconfig = 1; 781.36Sis#ifdef DRACO 791.36Sis if (is_draco()) { 801.36Sis *draco_intena &= ~DRIRQ_GLOBAL; 811.36Sis } else 821.36Sis#endif 831.3Smw custom.intena = INTF_INTEN; 841.44Sis s = splhigh(); 851.1Smw 861.31Scgd if (config_rootfound("mainbus", "mainbus") == NULL) 871.17Schopps panic("no mainbus found"); 881.36Sis 891.39Sis#ifdef DEBUG_KERNEL_START 901.43Schristos printf("survived autoconf, going to enable interrupts\n"); 911.39Sis#endif 921.79Saymeric 931.36Sis#ifdef DRACO 941.36Sis if (is_draco()) { 951.36Sis *draco_intena |= DRIRQ_GLOBAL; 961.36Sis /* softints always enabled */ 971.36Sis } else 981.36Sis#endif 991.36Sis { 1001.36Sis custom.intena = INTF_SETCLR | INTF_INTEN; 1011.28Schopps 1021.36Sis /* also enable hardware aided software interrupts */ 1031.36Sis custom.intena = INTF_SETCLR | INTF_SOFTINT; 1041.36Sis } 1051.39Sis#ifdef DEBUG_KERNEL_START 1061.62Sis for (i=splhigh(); i>=s ;i-=0x100) { 1071.62Sis splx(i); 1081.62Sis printf("%d...", (i>>8) & 7); 1091.62Sis } 1101.43Schristos printf("survived interrupt enable\n"); 1111.62Sis#else 1121.62Sis splx(s); 1131.39Sis#endif 1141.63Sthorpej#ifdef DEBUG_KERNEL_START 1151.63Sthorpej printf("survived configure...\n"); 1161.63Sthorpej#endif 1171.49Sgwr} 1181.49Sgwr 1191.49Sgwrvoid 1201.49Sgwrcpu_rootconf() 1211.49Sgwr{ 1221.77Sfrueauf findroot(); 1231.39Sis#ifdef DEBUG_KERNEL_START 1241.46Sthorpej printf("survived findroot()\n"); 1251.39Sis#endif 1261.64Sthorpej setroot(booted_device, booted_partition); 1271.39Sis#ifdef DEBUG_KERNEL_START 1281.43Schristos printf("survived setroot()\n"); 1291.1Smw#endif 1301.17Schopps} 1311.3Smw 1321.17Schopps/*ARGSUSED*/ 1331.17Schoppsint 1341.17Schoppssimple_devprint(auxp, pnp) 1351.17Schopps void *auxp; 1361.42Smhitch const char *pnp; 1371.17Schopps{ 1381.17Schopps return(QUIET); 1391.1Smw} 1401.1Smw 1411.17Schoppsint 1421.17Schoppsmatchname(fp, sp) 1431.17Schopps char *fp, *sp; 1441.17Schopps{ 1451.17Schopps int len; 1461.1Smw 1471.17Schopps len = strlen(fp); 1481.17Schopps if (strlen(sp) != len) 1491.17Schopps return(0); 1501.17Schopps if (bcmp(fp, sp, len) == 0) 1511.17Schopps return(1); 1521.17Schopps return(0); 1531.17Schopps} 1541.1Smw 1551.17Schopps/* 1561.17Schopps * use config_search to find appropriate device, then call that device 1571.79Saymeric * directly with NULL device variable storage. A device can then 1581.79Saymeric * always tell the difference betwean the real and console init 1591.17Schopps * by checking for NULL. 1601.17Schopps */ 1611.11Schoppsint 1621.17Schoppsamiga_config_found(pcfp, pdp, auxp, pfn) 1631.17Schopps struct cfdata *pcfp; 1641.17Schopps struct device *pdp; 1651.17Schopps void *auxp; 1661.17Schopps cfprint_t pfn; 1671.1Smw{ 1681.17Schopps struct device temp; 1691.17Schopps struct cfdata *cf; 1701.86Sthorpej const struct cfattach *ca; 1711.17Schopps 1721.17Schopps if (amiga_realconfig) 1731.31Scgd return(config_found(pdp, auxp, pfn) != NULL); 1741.17Schopps 1751.89Saymeric if (pdp == NULL) { 1761.89Saymeric memset(&temp, 0, sizeof temp); 1771.17Schopps pdp = &temp; 1781.89Saymeric } 1791.17Schopps 1801.17Schopps pdp->dv_cfdata = pcfp; 1811.88Saymeric pdp->dv_cfdriver = config_cfdriver_lookup(pcfp->cf_name); 1821.91Saymeric pdp->dv_unit = pcfp->cf_unit; 1831.89Saymeric 1841.17Schopps if ((cf = config_search((cfmatch_t)NULL, pdp, auxp)) != NULL) { 1851.86Sthorpej ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname); 1861.86Sthorpej if (ca != NULL) { 1871.86Sthorpej (*ca->ca_attach)(pdp, NULL, auxp); 1881.86Sthorpej pdp->dv_cfdata = NULL; 1891.86Sthorpej return(1); 1901.86Sthorpej } 1911.1Smw } 1921.17Schopps pdp->dv_cfdata = NULL; 1931.17Schopps return(0); 1941.17Schopps} 1951.17Schopps 1961.17Schopps/* 1971.17Schopps * this function needs to get enough configured to do a console 1981.79Saymeric * basically this means start attaching the grfxx's that support 1991.17Schopps * the console. Kinda hacky but it works. 2001.17Schopps */ 2011.32Sveegovoid 2021.17Schoppsconfig_console() 2031.79Saymeric{ 2041.17Schopps struct cfdata *cf; 2051.84Sthorpej 2061.84Sthorpej config_init(); 2071.36Sis 2081.17Schopps /* 2091.17Schopps * we need mainbus' cfdata. 2101.17Schopps */ 2111.17Schopps cf = config_rootsearch(NULL, "mainbus", "mainbus"); 2121.36Sis if (cf == NULL) { 2131.17Schopps panic("no mainbus"); 2141.36Sis } 2151.1Smw /* 2161.44Sis * delay clock calibration. 2171.44Sis */ 2181.44Sis amiga_config_found(cf, NULL, "clock", NULL); 2191.44Sis 2201.44Sis /* 2211.17Schopps * internal grf. 2221.1Smw */ 2231.36Sis#ifdef DRACO 2241.36Sis if (!(is_draco())) 2251.36Sis#endif 2261.36Sis amiga_config_found(cf, NULL, "grfcc", NULL); 2271.67Saymeric 2281.1Smw /* 2291.27Schopps * zbus knows when its not for real and will 2301.21Schopps * only configure the appropriate hardware 2311.1Smw */ 2321.27Schopps amiga_config_found(cf, NULL, "zbus", NULL); 2331.1Smw} 2341.1Smw 2351.79Saymeric/* 2361.79Saymeric * mainbus driver 2371.17Schopps */ 2381.85SthorpejCFATTACH_DECL(mainbus, sizeof(struct device), 2391.85Sthorpej mbmatch, mbattach, NULL, NULL); 2401.17Schopps 2411.11Schoppsint 2421.45Sveegombmatch(pdp, cfp, auxp) 2431.45Sveego struct device *pdp; 2441.45Sveego struct cfdata *cfp; 2451.45Sveego void *auxp; 2461.1Smw{ 2471.72Sis#if 0 /* 2481.72Sis * XXX is this right? but we need to be found twice 2491.72Sis * (early console init hack) 2501.72Sis */ 2511.71Skleink static int mainbus_matched = 0; 2521.30Sthorpej 2531.71Skleink /* Allow only one instance. */ 2541.71Skleink if (mainbus_matched) 2551.71Skleink return (0); 2561.71Skleink 2571.71Skleink mainbus_matched = 1; 2581.72Sis#endif 2591.71Skleink return (1); 2601.1Smw} 2611.1Smw 2621.1Smw/* 2631.17Schopps * "find" all the things that should be there. 2641.1Smw */ 2651.11Schoppsvoid 2661.17Schoppsmbattach(pdp, dp, auxp) 2671.17Schopps struct device *pdp, *dp; 2681.17Schopps void *auxp; 2691.1Smw{ 2701.43Schristos printf("\n"); 2711.17Schopps config_found(dp, "clock", simple_devprint); 2721.52Sis if (is_a3000() || is_a4000()) { 2731.52Sis config_found(dp, "a34kbbc", simple_devprint); 2741.58Sis } else 2751.53Sis#ifdef DRACO 2761.58Sis if (!is_draco()) 2771.53Sis#endif 2781.58Sis { 2791.52Sis config_found(dp, "a2kbbc", simple_devprint); 2801.52Sis } 2811.36Sis#ifdef DRACO 2821.36Sis if (is_draco()) { 2831.52Sis config_found(dp, "drbbc", simple_devprint); 2841.36Sis config_found(dp, "kbd", simple_devprint); 2851.36Sis config_found(dp, "drsc", simple_devprint); 2861.55Sis config_found(dp, "drsupio", simple_devprint); 2871.79Saymeric } else 2881.36Sis#endif 2891.36Sis { 2901.36Sis config_found(dp, "ser", simple_devprint); 2911.36Sis config_found(dp, "par", simple_devprint); 2921.36Sis config_found(dp, "kbd", simple_devprint); 2931.36Sis config_found(dp, "ms", simple_devprint); 2941.36Sis config_found(dp, "grfcc", simple_devprint); 2951.78Sis config_found(dp, "amidisplaycc", simple_devprint); 2961.36Sis config_found(dp, "fdc", simple_devprint); 2971.36Sis } 2981.69Smhitch if (is_a4000() || is_a1200()) { 2991.69Smhitch config_found(dp, "wdc", simple_devprint); 3001.23Schopps config_found(dp, "idesc", simple_devprint); 3011.69Smhitch } 3021.29Schopps if (is_a4000()) /* Try to configure A4000T SCSI */ 3031.29Schopps config_found(dp, "afsc", simple_devprint); 3041.17Schopps if (is_a3000()) 3051.17Schopps config_found(dp, "ahsc", simple_devprint); 3061.67Saymeric if (/*is_a600() || */is_a1200()) 3071.67Saymeric config_found(dp, "pccard", simple_devprint); 3081.54Sis#ifdef DRACO 3091.54Sis if (!is_draco()) 3101.54Sis#endif 3111.54Sis config_found(dp, "aucc", simple_devprint); 3121.54Sis 3131.57Sis config_found(dp, "zbus", simple_devprint); 3141.1Smw} 3151.1Smw 3161.11Schoppsint 3171.17Schoppsmbprint(auxp, pnp) 3181.17Schopps void *auxp; 3191.40Scgd const char *pnp; 3201.1Smw{ 3211.17Schopps if (pnp) 3221.87Sthorpej aprint_normal("%s at %s", (char *)auxp, pnp); 3231.17Schopps return(UNCONF); 3241.1Smw} 3251.1Smw 3261.46Sthorpej/* 3271.46Sthorpej * The system will assign the "booted device" indicator (and thus 3281.46Sthorpej * rootdev if rootspec is wildcarded) to the first partition 'a' 3291.46Sthorpej * in preference of boot. However, it does walk unit backwards 3301.46Sthorpej * to remain compatible with the old Amiga method of picking the 3311.46Sthorpej * last root found. 3321.46Sthorpej */ 3331.46Sthorpej#include <sys/fcntl.h> /* XXXX and all that uses it */ 3341.46Sthorpej#include <sys/proc.h> /* XXXX and all that uses it */ 3351.17Schopps 3361.46Sthorpej#include "fd.h" 3371.46Sthorpej#include "sd.h" 3381.46Sthorpej#include "cd.h" 3391.67Saymeric#include "wd.h" 3401.1Smw 3411.46Sthorpej#if NFD > 0 3421.46Sthorpejextern struct cfdriver fd_cd; 3431.82Sgehennaextern const struct bdevsw fd_bdevsw; 3441.46Sthorpej#endif 3451.46Sthorpej#if NSD > 0 3461.69Smhitchextern struct cfdriver sd_cd; 3471.82Sgehennaextern const struct bdevsw sd_bdevsw; 3481.46Sthorpej#endif 3491.46Sthorpej#if NCD > 0 3501.46Sthorpejextern struct cfdriver cd_cd; 3511.82Sgehennaextern const struct bdevsw cd_bdevsw; 3521.46Sthorpej#endif 3531.67Saymeric#if NWD > 0 3541.69Smhitchextern struct cfdriver wd_cd; 3551.82Sgehennaextern const struct bdevsw wd_bdevsw; 3561.67Saymeric#endif 3571.1Smw 3581.46Sthorpejstruct cfdriver *genericconf[] = { 3591.46Sthorpej#if NFD > 0 3601.46Sthorpej &fd_cd, 3611.46Sthorpej#endif 3621.46Sthorpej#if NSD > 0 3631.46Sthorpej &sd_cd, 3641.46Sthorpej#endif 3651.69Smhitch#if NWD > 0 3661.69Smhitch &wd_cd, 3671.69Smhitch#endif 3681.46Sthorpej#if NCD > 0 3691.46Sthorpej &cd_cd, 3701.46Sthorpej#endif 3711.46Sthorpej NULL, 3721.1Smw}; 3731.1Smw 3741.11Schoppsvoid 3751.76Smattfindroot(void) 3761.1Smw{ 3771.46Sthorpej struct disk *dkp; 3781.46Sthorpej struct partition *pp; 3791.46Sthorpej struct device **devs; 3801.46Sthorpej int i, maj, unit; 3811.82Sgehenna const struct bdevsw *bdp; 3821.47Smhitch 3831.47Smhitch#if NSD > 0 3841.47Smhitch /* 3851.47Smhitch * If we have the boot partition offset (boot_partition), try 3861.47Smhitch * to locate the device corresponding to that partition. 3871.47Smhitch */ 3881.56Sis#ifdef DEBUG_KERNEL_START 3891.56Sis printf("Boot partition offset is %ld\n", boot_partition); 3901.56Sis#endif 3911.47Smhitch if (boot_partition != 0) { 3921.54Sis int i; 3931.47Smhitch 3941.47Smhitch for (unit = 0; unit < sd_cd.cd_ndevs; ++unit) { 3951.56Sis#ifdef DEBUG_KERNEL_START 3961.56Sis printf("probing for sd%d\n", unit); 3971.56Sis#endif 3981.47Smhitch if (sd_cd.cd_devs[unit] == NULL) 3991.47Smhitch continue; 4001.47Smhitch 4011.47Smhitch /* 4021.47Smhitch * Find the disk corresponding to the current 4031.47Smhitch * device. 4041.47Smhitch */ 4051.47Smhitch devs = (struct device **)sd_cd.cd_devs; 4061.47Smhitch if ((dkp = disk_find(devs[unit]->dv_xname)) == NULL) 4071.47Smhitch continue; 4081.47Smhitch 4091.47Smhitch if (dkp->dk_driver == NULL || 4101.47Smhitch dkp->dk_driver->d_strategy == NULL) 4111.47Smhitch continue; 4121.82Sgehenna bdp = &sd_bdevsw; 4131.82Sgehenna maj = bdevsw_lookup_major(bdp); 4141.82Sgehenna if ((*bdp->d_open)(MAKEDISKDEV(maj, unit, RAW_PART), 4151.47Smhitch FREAD | FNONBLOCK, 0, curproc)) 4161.47Smhitch continue; 4171.82Sgehenna (*bdp->d_close)(MAKEDISKDEV(maj, unit, RAW_PART), 4181.47Smhitch FREAD | FNONBLOCK, 0, curproc); 4191.47Smhitch pp = &dkp->dk_label->d_partitions[0]; 4201.54Sis for (i = 0; i < dkp->dk_label->d_npartitions; 4211.54Sis i++, pp++) { 4221.56Sis#ifdef DEBUG_KERNEL_START 4231.56Sis printf("sd%d%c type %d offset %d size %d\n", 4241.56Sis unit, i+'a', pp->p_fstype, 4251.56Sis pp->p_offset, pp->p_size); 4261.56Sis#endif 4271.54Sis if (pp->p_size == 0 || 4281.54Sis (pp->p_fstype != FS_BSDFFS && 4291.54Sis pp->p_fstype != FS_SWAP)) 4301.54Sis continue; 4311.54Sis if (pp->p_offset == boot_partition) { 4321.76Smatt if (booted_device == NULL) { 4331.76Smatt booted_device = devs[unit]; 4341.76Smatt booted_partition = i; 4351.54Sis } else 4361.54Sis printf("Ambiguous boot device\n"); 4371.54Sis } 4381.47Smhitch } 4391.47Smhitch } 4401.47Smhitch } 4411.76Smatt if (booted_device != NULL) 4421.47Smhitch return; /* we found the boot device */ 4431.47Smhitch#endif 4441.46Sthorpej 4451.46Sthorpej for (i = 0; genericconf[i] != NULL; i++) { 4461.46Sthorpej for (unit = genericconf[i]->cd_ndevs - 1; unit >= 0; unit--) { 4471.46Sthorpej if (genericconf[i]->cd_devs[unit] == NULL) 4481.46Sthorpej continue; 4491.46Sthorpej 4501.46Sthorpej /* 4511.46Sthorpej * Find the disk structure corresponding to the 4521.46Sthorpej * current device. 4531.46Sthorpej */ 4541.46Sthorpej devs = (struct device **)genericconf[i]->cd_devs; 4551.46Sthorpej if ((dkp = disk_find(devs[unit]->dv_xname)) == NULL) 4561.46Sthorpej continue; 4571.46Sthorpej 4581.46Sthorpej if (dkp->dk_driver == NULL || 4591.46Sthorpej dkp->dk_driver->d_strategy == NULL) 4601.46Sthorpej continue; 4611.46Sthorpej 4621.92Smhitch bdp = NULL; 4631.82Sgehenna#if NFD > 0 4641.82Sgehenna if (fd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4651.82Sgehenna bdp = &fd_bdevsw; 4661.82Sgehenna#endif 4671.82Sgehenna#if NSD > 0 4681.82Sgehenna if (sd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4691.82Sgehenna bdp = &sd_bdevsw; 4701.82Sgehenna#endif 4711.82Sgehenna#if NWD > 0 4721.82Sgehenna if (wd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4731.82Sgehenna bdp = &wd_bdevsw; 4741.82Sgehenna#endif 4751.82Sgehenna#if NCD > 0 4761.82Sgehenna if (cd_bdevsw.d_strategy == dkp->dk_driver->d_strategy) 4771.82Sgehenna bdp = &cd_bdevsw; 4781.82Sgehenna#endif 4791.46Sthorpej#ifdef DIAGNOSTIC 4801.82Sgehenna if (bdp == NULL) 4811.46Sthorpej panic("findroot: impossible"); 4821.46Sthorpej#endif 4831.82Sgehenna maj = bdevsw_lookup_major(bdp); 4841.46Sthorpej 4851.46Sthorpej /* Open disk; forces read of disklabel. */ 4861.82Sgehenna if ((*bdp->d_open)(MAKEDISKDEV(maj, 4871.46Sthorpej unit, 0), FREAD|FNONBLOCK, 0, &proc0)) 4881.46Sthorpej continue; 4891.82Sgehenna (void)(*bdp->d_close)(MAKEDISKDEV(maj, 4901.46Sthorpej unit, 0), FREAD|FNONBLOCK, 0, &proc0); 4911.46Sthorpej 4921.46Sthorpej pp = &dkp->dk_label->d_partitions[0]; 4931.46Sthorpej if (pp->p_size != 0 && pp->p_fstype == FS_BSDFFS) { 4941.76Smatt booted_device = devs[unit]; 4951.76Smatt booted_partition = 0; 4961.46Sthorpej return; 4971.46Sthorpej } 4981.1Smw } 4991.1Smw } 5001.3Smw} 5011.17Schopps 5021.11Schopps/* 5031.11Schopps * Try to determine, of this machine is an A3000, which has a builtin 5041.11Schopps * realtime clock and scsi controller, so that this hardware is only 5051.11Schopps * included as "configured" if this IS an A3000 5061.11Schopps */ 5071.5Smw 5081.5Smwint a3000_flag = 1; /* patchable */ 5091.5Smw#ifdef A4000 5101.5Smwint a4000_flag = 1; /* patchable - default to A4000 */ 5111.5Smw#else 5121.5Smwint a4000_flag = 0; /* patchable */ 5131.5Smw#endif 5141.5Smw 5151.3Smwint 5161.11Schoppsis_a3000() 5171.3Smw{ 5181.11Schopps /* this is a dirty kludge.. but how do you do this RIGHT ? :-) */ 5191.22Schopps extern long boot_fphystart; 5201.11Schopps short sc; 5211.11Schopps 5221.19Schopps if ((machineid >> 16) == 3000) 5231.19Schopps return (1); /* It's an A3000 */ 5241.19Schopps if (machineid >> 16) 5251.19Schopps return (0); /* It's not an A3000 */ 5261.19Schopps /* Machine type is unknown, so try to guess it */ 5271.11Schopps /* where is fastram on the A4000 ?? */ 5281.11Schopps /* if fastram is below 0x07000000, assume it's not an A3000 */ 5291.22Schopps if (boot_fphystart < 0x07000000) 5301.17Schopps return(0); 5311.11Schopps /* 5321.11Schopps * OK, fastram starts at or above 0x07000000, check specific 5331.11Schopps * machines 5341.11Schopps */ 5351.17Schopps for (sc = 0; sc < ncfdev; sc++) { 5361.17Schopps switch (cfdev[sc].rom.manid) { 5371.17Schopps case 2026: /* Progressive Peripherals, Inc */ 5381.17Schopps switch (cfdev[sc].rom.prodid) { 5391.17Schopps case 0: /* PPI Mercury - A3000 */ 5401.17Schopps case 1: /* PP&S A3000 '040 */ 5411.17Schopps return(1); 5421.17Schopps case 150: /* PPI Zeus - it's an A2000 */ 5431.17Schopps case 105: /* PP&S A2000 '040 */ 5441.17Schopps case 187: /* PP&S A500 '040 */ 5451.17Schopps return(0); 5461.11Schopps } 5471.11Schopps break; 5481.3Smw 5491.17Schopps case 2112: /* IVS */ 5501.17Schopps switch (cfdev[sc].rom.prodid) { 5511.17Schopps case 242: 5521.17Schopps return(0); /* A2000 accelerator? */ 5531.11Schopps } 5541.11Schopps break; 5551.11Schopps } 5561.11Schopps } 5571.17Schopps return (a3000_flag); /* XXX let flag tell now */ 5581.5Smw} 5591.5Smw 5601.5Smwint 5611.11Schoppsis_a4000() 5621.5Smw{ 5631.19Schopps if ((machineid >> 16) == 4000) 5641.19Schopps return (1); /* It's an A4000 */ 5651.24Schopps if ((machineid >> 16) == 1200) 5661.24Schopps return (0); /* It's an A1200, so not A4000 */ 5671.36Sis#ifdef DRACO 5681.36Sis if (is_draco()) 5691.36Sis return (0); 5701.36Sis#endif 5711.24Schopps /* Do I need this any more? */ 5721.19Schopps if ((custom.deniseid & 0xff) == 0xf8) 5731.19Schopps return (1); 5741.19Schopps#ifdef DEBUG 5751.19Schopps if (a4000_flag) 5761.43Schristos printf("Denise ID = %04x\n", (unsigned short)custom.deniseid); 5771.19Schopps#endif 5781.19Schopps if (machineid >> 16) 5791.19Schopps return (0); /* It's not an A4000 */ 5801.19Schopps return (a4000_flag); /* Machine type not set */ 5811.24Schopps} 5821.24Schopps 5831.24Schoppsint 5841.24Schoppsis_a1200() 5851.24Schopps{ 5861.24Schopps if ((machineid >> 16) == 1200) 5871.24Schopps return (1); /* It's an A1200 */ 5881.24Schopps return (0); /* Machine type not set */ 5891.1Smw} 590