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