]>
git.saurik.com Git - apple/boot.git/blob - i386/libsaio/bootstruct.c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright 1993 NeXT, Inc.
26 * All rights reserved.
29 #include "io_inline.h"
31 #include "kernBootStruct.h"
33 // CMOS access ports in I/O space.
39 /*==========================================================================
40 * Returns the number of active ATA drives since these will increment the
41 * bios device numbers of SCSI drives.
47 unsigned short hdtype
;
50 struct driveParameters param
;
52 printf("Reading drive parameters...\n");
53 readDriveParameters(0x80, ¶m
);
54 printf("%d fixed disk drive(s) installed\n", param
.totalDrives
);
55 for (count
= 0; count
< 256; count
++)
57 if (readDriveParameters(count
+ 0x80, ¶m
))
61 printf("Drive %d: %d cyls, %d heads, %d sectors\n",
62 count
, param
.cylinders
, param
.heads
, param
.sectors
);
66 printf("CMOS addr 0x11 = %x\n",inb(CMOSDATA
));
68 printf("CMOS addr 0x12 = %x\n",inb(CMOSDATA
));
72 outb( CMOSADDR
, HDTYPE
);
73 hdtype
= (unsigned short) inb( CMOSDATA
);
75 if (hdtype
& 0xF0) count
++;
76 if (hdtype
& 0x0F) count
++;
80 /*==========================================================================
81 * Initialize the 'kernBootStruct'. A structure of parameters passed to
82 * the kernel by the booter.
85 KERNBOOTSTRUCT
* kernBootStruct
= (KERNBOOTSTRUCT
*) KERNSTRUCT_ADDR
;
92 bzero( (char *) kernBootStruct
, sizeof(*kernBootStruct
) );
94 // Get size of conventional memory.
96 kernBootStruct
->convmem
= memsize(0);
98 // Get size of extended memory.
100 kernBootStruct
->extmem
= memsize(1);
102 // Get number of ATA devices.
104 kernBootStruct
->numIDEs
= countIDEDisks();
106 // Get disk info from BIOS.
108 for ( i
= 0; i
< 4; i
++ )
110 kernBootStruct
->diskInfo
[i
] = get_diskinfo(0x80 + i
);
113 kernBootStruct
->magicCookie
= KERNBOOTMAGIC
;
114 kernBootStruct
->configEnd
= kernBootStruct
->config
;
115 kernBootStruct
->graphicsMode
= GRAPHICS_MODE
;