1 /* $NetBSD: sysinfo.c,v 1.7 2008/04/28 20:23:15 martin Exp $ */ 2 3 /*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Leo Weppelman. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifdef TOSTOOLS 33 #include <stdio.h> 34 #include <sys/types.h> 35 #else 36 37 #include <lib/libsa/stand.h> 38 #include <atari_stand.h> 39 #include <string.h> 40 #include <libkern.h> 41 #include <machine/cpu.h> 42 #endif /* TOSTOOLS */ 43 44 #include "libtos.h" 45 #include "tosdefs.h" 46 #include "kparamb.h" 47 /* 48 * Extract memory and CPU/FPU info from system. 49 */ 50 void 51 sys_info(od) 52 osdsc_t *od; 53 { 54 long *jar; 55 OSH *oshdr; 56 57 od->cputype = 0; 58 59 /* 60 * Some GEMDOS versions use a different year-base in the RTC. 61 */ 62 oshdr = *ADDR_OSHEAD; 63 oshdr = oshdr->os_beg; 64 if ((oshdr->os_version > 0x0300) && (oshdr->os_version < 0x0306)) 65 od->cputype |= ATARI_CLKBROKEN; 66 67 /* 68 * Auto configure memory sizes when they are not pre-set. 69 */ 70 if (od->stmem_size <= 0) 71 od->stmem_size = *ADDR_PHYSTOP; 72 73 if (od->ttmem_size) 74 od->ttmem_start = TTRAM_BASE; 75 else { 76 if (*ADDR_CHKRAMTOP == RAMTOP_MAGIC) { 77 od->ttmem_size = *ADDR_RAMTOP; 78 if (od->ttmem_size > TTRAM_BASE) { 79 od->ttmem_size -= TTRAM_BASE; 80 od->ttmem_start = TTRAM_BASE; 81 } 82 else od->ttmem_size = 0; 83 } 84 } 85 86 /* 87 * Scan cookiejar for CPU types, accellerator boards, etc. 88 */ 89 jar = *ADDR_P_COOKIE; 90 if (jar != NULL) { 91 do { 92 if (jar[0] == 0x5f435055) { /* _CPU */ 93 switch (jar[1]) { 94 case 0: 95 od->cputype |= ATARI_68000; 96 break; 97 case 10: 98 od->cputype |= ATARI_68010; 99 break; 100 case 20: 101 od->cputype |= ATARI_68020; 102 break; 103 case 30: 104 od->cputype |= ATARI_68030; 105 break; 106 case 40: 107 od->cputype |= ATARI_68040; 108 break; 109 case 60: 110 od->cputype |= ATARI_68060; 111 break; 112 default: 113 /* This error is caught later on */ 114 break; 115 } 116 } 117 if (jar[0] == 0x42504658) { /* BPFX */ 118 unsigned long *p; 119 120 p = (unsigned long*)jar[1]; 121 122 od->ttmem_start = p[1]; 123 od->ttmem_size = p[2]; 124 } 125 if (jar[0] == 0x5f435432) { /* _CT2 */ 126 /* 127 * The CT2 board has a different physical base address! 128 */ 129 od->ttmem_start = CTRAM_BASE; 130 } 131 jar = &jar[2]; 132 } while (jar[-2]); 133 } 134 } 135