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