sysinfo.c revision 1.7.8.1 1 /* $NetBSD: sysinfo.c,v 1.7.8.1 2009/01/19 13:16:01 skrll 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 <libkern.h>
40 #include <machine/cpu.h>
41 #endif /* TOSTOOLS */
42
43 #include "libtos.h"
44 #include "tosdefs.h"
45 #include "kparamb.h"
46 /*
47 * Extract memory and CPU/FPU info from system.
48 */
49 void
50 sys_info(od)
51 osdsc_t *od;
52 {
53 long *jar;
54 OSH *oshdr;
55
56 od->cputype = 0;
57
58 /*
59 * Some GEMDOS versions use a different year-base in the RTC.
60 */
61 oshdr = *ADDR_OSHEAD;
62 oshdr = oshdr->os_beg;
63 if ((oshdr->os_version > 0x0300) && (oshdr->os_version < 0x0306))
64 od->cputype |= ATARI_CLKBROKEN;
65
66 /*
67 * Auto configure memory sizes when they are not pre-set.
68 */
69 if (od->stmem_size <= 0)
70 od->stmem_size = *ADDR_PHYSTOP;
71
72 if (od->ttmem_size)
73 od->ttmem_start = TTRAM_BASE;
74 else {
75 if (*ADDR_CHKRAMTOP == RAMTOP_MAGIC) {
76 od->ttmem_size = *ADDR_RAMTOP;
77 if (od->ttmem_size > TTRAM_BASE) {
78 od->ttmem_size -= TTRAM_BASE;
79 od->ttmem_start = TTRAM_BASE;
80 }
81 else od->ttmem_size = 0;
82 }
83 }
84
85 /*
86 * Scan cookiejar for CPU types, accellerator boards, etc.
87 */
88 jar = *ADDR_P_COOKIE;
89 if (jar != NULL) {
90 do {
91 if (jar[0] == 0x5f435055) { /* _CPU */
92 switch (jar[1]) {
93 case 0:
94 od->cputype |= ATARI_68000;
95 break;
96 case 10:
97 od->cputype |= ATARI_68010;
98 break;
99 case 20:
100 od->cputype |= ATARI_68020;
101 break;
102 case 30:
103 od->cputype |= ATARI_68030;
104 break;
105 case 40:
106 od->cputype |= ATARI_68040;
107 break;
108 case 60:
109 od->cputype |= ATARI_68060;
110 break;
111 default:
112 /* This error is caught later on */
113 break;
114 }
115 }
116 if (jar[0] == 0x42504658) { /* BPFX */
117 unsigned long *p;
118
119 p = (unsigned long*)jar[1];
120
121 od->ttmem_start = p[1];
122 od->ttmem_size = p[2];
123 }
124 if (jar[0] == 0x5f435432) { /* _CT2 */
125 /*
126 * The CT2 board has a different physical base address!
127 */
128 od->ttmem_start = CTRAM_BASE;
129 }
130 jar = &jar[2];
131 } while (jar[-2]);
132 }
133 }
134