📄 kn230.c
字号:
* * Each bank of 2 SIMMs can be either 8M or 32M, there is a bit in the * LED register which tells us what size the first bank contains. There * is a configuration constraint of having the large (32M) memories * populate the banks before small memories (8M). Therefore, there are * only a fixed number of possible combinations, and by knowing the * size of memory and what the first bank is, we can figure out what * size each bank contains. * * NOTE: Due to the lack of info provided by the h/w, it is possible * for this algorithm to fail. If there are bad pages, there * exist conditions which will leave the SIMM layout incorrect * for logging parity errors. ****************************************************************************/kn230_getSIMMsizes(){ int memsize; int kn230_nvram_present=0; /* * get the intger value of memory size, it will not be an exact quanity * because the bitmap is marked unusable and there may also be bad memory. * Initialize all banks to zero to make life simpler. * * Need to account for NVRAM in memory, it is not marked in bitmap so * physmem doesn't know about it, if NVRAM is present, must make last * bank a 1Mbyte memory bank, the NVRAM SIMMs. * */ kn230_memsize = ( ctob(physmem) /1024 )/1024 ; kn230_bank1 = kn230_bank2 = kn230_bank3 = kn230_bank4 = 0; if ( *(int *)NVRAM_DIAG & KN230_NVRAM_PRESENT ) kn230_nvram_present = 1; if (kn230_memsize <= 8) { kn230_bank1 = 8; if (kn230_nvram_present) kn230_bank2 = 1; } else if (kn230_memsize <= 16) { kn230_bank1 = kn230_bank2 = 8; if (kn230_nvram_present) kn230_bank3 = 1; } else if (kn230_memsize <= 24) { kn230_bank1 = kn230_bank2 = kn230_bank3 = 8 ; if (kn230_nvram_present) kn230_bank4 = 1; } else if (kn230_memsize <= 32) if ( *(int *)LED_ADDR & KN230_LED1 ) /* bank 1 is not 32M */ kn230_bank1 = kn230_bank2 = kn230_bank3 = kn230_bank4 = 8 ; else { kn230_bank1 = 32 ; if (kn230_nvram_present) kn230_bank2 = 1; } else if (kn230_memsize <= 40) { kn230_bank1 = 32 ; kn230_bank2 = 8 ; if (kn230_nvram_present) kn230_bank3 = 1; } else if (kn230_memsize <= 48) { kn230_bank1 = 32 ; kn230_bank2 = kn230_bank3 = 8 ; if (kn230_nvram_present) kn230_bank4 = 1; } else if (kn230_memsize <= 56) { kn230_bank1 = 32 ; kn230_bank2 = kn230_bank3 = kn230_bank4 = 8 ; } else if (kn230_memsize <= 64) { kn230_bank1 = kn230_bank2 = 32; if (kn230_nvram_present) kn230_bank3 = 1; } else if (kn230_memsize <= 72) { kn230_bank1 = kn230_bank2 = 32 ; kn230_bank3 = 8 ; if (kn230_nvram_present) kn230_bank4 = 1; } else if (kn230_memsize <= 80) { kn230_bank1 = kn230_bank2 = 32 ; kn230_bank3 = kn230_bank4 = 8 ; } else if (kn230_memsize <= 96) { kn230_bank1 = kn230_bank2 = kn230_bank3 = 32; if (kn230_nvram_present) kn230_bank4 = 1; } else if (kn230_memsize <= 104) { kn230_bank1 = kn230_bank2 = kn230_bank3 = 32; kn230_bank4 = 8 ; } else if (kn230_memsize <= 128) kn230_bank1 = kn230_bank2 = kn230_bank3 = kn230_bank4 = 32 ; else printf("KN230: invalid memory configuration\n");}/***************************************************************************** * * kn230_config_nvram * * - initialize pointers to cpu specific routines for Prestoserve * - Check for nvram presence * - initialize status and control register location according to * nvram location * - make call to presto_init to initialize Prestoserve * *****************************************************************************/int kn230_cache_nvram = 1;int kn230_nvram_mapped = 0;kn230_config_nvram(){ extern kn230_nvram_status(); extern kn230_nvram_battery_status(); extern kn230_nvram_battery_enable(); extern kn230_nvram_battery_disable(); extern u_int kn230_machineid(); int hosed = 0; /* * Initialize the structure that will point to the cpu specific * functions for Prestoserve */ presto_interface0.nvram_status = kn230_nvram_status; presto_interface0.nvram_battery_status= kn230_nvram_battery_status; presto_interface0.nvram_battery_disable= kn230_nvram_battery_disable; presto_interface0.nvram_battery_enable= kn230_nvram_battery_enable; /* * configure the NVRAM option if it is present */ if ( *(int *)NVRAM_DIAG & KN230_NVRAM_PRESENT ) { printf("KN230 NVRAM present\n"); kn230_nvram_location = *(unsigned *)NVRAM_LOCATION; /* * Determine physical start of nvram from KSEG1 value stored * in location register. We could do something fancier here, * but this allows me to verify that the location register is * returning a legal value, so that if it doesn't we can bow * out gracefully instead of crash and burn when we attempt * to touch a non existant memory address. This especially * unsightful at this point in configure() because we will * take multiple traps. * */ switch (kn230_nvram_location) { case 0xa0c00000: kn230_nvram_start_addr = 0xc00000 ; break; case 0xa1400000: kn230_nvram_start_addr = 0x1400000; break; case 0xa1c00000: kn230_nvram_start_addr = 0x1c00000; break; case 0xa2400000: kn230_nvram_start_addr = 0x2400000; break; case 0xa2c00000: kn230_nvram_start_addr = 0x2c00000; break; case 0xa3400000: kn230_nvram_start_addr = 0x3400000; break; case 0xa3c00000: kn230_nvram_start_addr = 0x3c00000; break; case 0xa4400000: kn230_nvram_start_addr = 0x4400000; break; case 0xa4c00000: kn230_nvram_start_addr = 0x4c00000; break; case 0xa5400000: kn230_nvram_start_addr = 0x5400000; break; case 0xa6400000: kn230_nvram_start_addr = 0x6400000; break; default:printf("KN230 NVRAM: Bad starting address\n"); hosed = 1; break; } if (hosed) { printf("KN230 NVRAM: not intializing Prestoserve\n"); } else { /* * set up all nvram information * * - locations of status/control registers are at * a fixed offset from first nvram address * * - starting nvram address for presto is 1K from the * physical start of the nvram board, that space is * used for diagnostics, etc.. * * - size of nvram is available from the diag register, * and is 1K less than the full amount because of the * reserved space * */ kn230_nvram_start_addr += 0x400; kn230_nvram_estatus = kn230_nvram_location + 0x200000; kn230_nvram_ostatus = kn230_nvram_location + 0x200004; kn230_nvram_econtrol = kn230_nvram_location - 0x200000; kn230_nvram_ocontrol = kn230_nvram_location-0x200000+0x4; kn230_nvram_size = (*(int *)NVRAM_DIAG & NVRAM_SIZE) >> 4; kn230_nvram_size *= 0x100000; /* convert to bytes */ kn230_nvram_size -= 0x400; /* - reserved space */ presto_init(kn230_nvram_start_addr, kn230_nvram_size, kn230_nvram_mapped, kn230_cache_nvram, kn230_machineid()); } /*end not hosed*/ } /*else not present*/ else printf("KN230 NVRAM not present\n");}/***************************************************************************** * * kn230_nvram_status * * - provide presto with status of diagnostics run on nvram * hence, let presto know what to do - recover, etc... * *****************************************************************************/kn230_nvram_status(){ if ( *(int *)NVRAM_DIAG & KN230_NVRAM_FAILED) return(NVRAM_BAD); else if ( *(int *)NVRAM_DIAG & KN230_NVRAM_RO) return(NVRAM_RDONLY); else if ( *(int *)NVRAM_DIAG & KN230_NVRAM_RW) return(NVRAM_RDWR); else { printf("No nvram diag bits set for status"); return(-1); }}/**************************************************************************** * kn230_nvram_battery_status * * - update the global battery information structure for * Prestoserve * ****************************************************************************/kn230_nvram_battery_status(){ nvram_batteries0.nv_nbatteries = 1; /* one battery */ nvram_batteries0.nv_minimum_ok = 1; /* it must be good */ nvram_batteries0.nv_primary_mandatory = 1; /* primary must be OK */ nvram_batteries0.nv_test_retries = 3; /* call this routine 3 times * for each "test" */ if ((*(int *)kn230_nvram_estatus & KN230_NVRAM_BFAIL) && (*(int *)kn230_nvram_ostatus & KN230_NVRAM_BFAIL)) { nvram_batteries0.nv_status[0] = BATT_OK; return(0); } else if ( !((*(int *)kn230_nvram_estatus & KN230_NVRAM_BFAIL)) && !((*(int *)kn230_nvram_ostatus & KN230_NVRAM_BFAIL))) { nvram_batteries0.nv_status[0] = BATT_NONE; return(0); } else return(1);}/**************************************************************************** * kn230_nvram_battery_enable * * - performs disable battery kill function * ****************************************************************************/kn230_nvram_battery_enable(){ *(int *)kn230_nvram_econtrol = 0x0; wbflush(); *(int *)kn230_nvram_ocontrol = 0x0; wbflush(); if ( (*(int *)kn230_nvram_estatus & KN230_NVRAM_BKILL) && (*(int *)kn230_nvram_ostatus & KN230_NVRAM_BKILL)) return(1); else return(0);}/**************************************************************************** * kn230_nvram_battery_disable * * performs enable battery kill function * the excessive number of wbflushes is * to prevent future headaches when the * new r3020 write buffers merge writes. * ****************************************************************************/kn230_nvram_battery_disable(){ *(int *)kn230_nvram_econtrol = 0x1; *(int *)kn230_nvram_ocontrol = 0x1; wbflush(); *(int *)kn230_nvram_econtrol = 0x1; *(int *)kn230_nvram_ocontrol = 0x1; wbflush(); *(int *)kn230_nvram_econtrol = 0x0; *(int *)kn230_nvram_ocontrol = 0x0; wbflush(); *(int *)kn230_nvram_econtrol = 0x0; *(int *)kn230_nvram_ocontrol = 0x0; wbflush(); *(int *)kn230_nvram_econtrol = 0x1; *(int *)kn230_nvram_ocontrol = 0x1; wbflush(); if ((*(int *)kn230_nvram_estatus & KN230_NVRAM_BKILL) && (*(int *)kn230_nvram_ostatus & KN230_NVRAM_BKILL)) return(0); else return(1); }#include "../h/socket.h"#include "../net/net/if.h"/* * Get the hardware E_net address for on-board ln0 and use it * to build a poor man's version of a unique processor ID. */u_intkn230_machineid(){ register struct ifnet *ifp = ifnet; struct ifdevea ifr; u_int i = 0; int error; if (ifnet == NULL) { printf("kn220: ifnet NULL\n"); return (i); } while (ifp != NULL) { if (ifp->if_name[0] == 'l' && ifp->if_name[1] == 'n' && ifp->if_unit == 0) { /* found ln0 */ error = (*ifp->if_ioctl)(ifp, SIOCRPHYSADDR, &ifr); if (error) return (i); i = (u_int)ifr.default_pa[2]; i = i << 8; i += (u_int)ifr.default_pa[3]; i = i << 8; i += (u_int)ifr.default_pa[4]; i = i << 8; i += (u_int)ifr.default_pa[5]; return (i); } ifp = ifp->if_next; } return (i);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -