]>
git.saurik.com Git - apple/boot.git/blob - i386/libsaio/bootstruct.c
667f7c07f05161d80b00277660053dc260f594bd
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.
31 // CMOS access ports in I/O space.
37 /*==========================================================================
38 * Returns the number of active ATA drives since these will increment the
39 * bios device numbers of SCSI drives.
41 static int countIDEDisks()
44 unsigned short hdtype
;
47 struct driveParameters param
;
49 printf("Reading drive parameters...\n");
50 readDriveParameters(0x80, ¶m
);
51 printf("%d fixed disk drive(s) installed\n", param
.totalDrives
);
52 for (count
= 0; count
< 256; count
++)
54 if (readDriveParameters(count
+ 0x80, ¶m
))
58 printf("Drive %d: %d cyls, %d heads, %d sectors\n",
59 count
, param
.cylinders
, param
.heads
, param
.sectors
);
63 printf("CMOS addr 0x11 = %x\n",inb(CMOSDATA
));
65 printf("CMOS addr 0x12 = %x\n",inb(CMOSDATA
));
69 outb( CMOSADDR
, HDTYPE
);
70 hdtype
= (unsigned short) inb( CMOSDATA
);
72 if (hdtype
& 0xF0) count
++;
73 if (hdtype
& 0x0F) count
++;
77 /*==========================================================================
78 * Initialize the 'kernBootStruct'. A structure of parameters passed to
79 * the kernel by the booter.
82 KERNBOOTSTRUCT
* kernBootStruct
= (KERNBOOTSTRUCT
*) KERNSTRUCT_ADDR
;
84 void initKernBootStruct( int biosdev
)
86 static int init_done
= 0;
91 bzero( (char *) kernBootStruct
, sizeof(*kernBootStruct
) );
93 // Get size of conventional memory.
95 kernBootStruct
->convmem
= memsize(0);
97 // Get size of extended memory.
99 kernBootStruct
->extmem
= memsize(1);
101 kernBootStruct
->magicCookie
= KERNBOOTMAGIC
;
102 kernBootStruct
->configEnd
= kernBootStruct
->config
;
103 kernBootStruct
->graphicsMode
= TEXT_MODE
;
108 // Get number of ATA devices.
110 kernBootStruct
->numIDEs
= countIDEDisks();
112 // Get disk info from BIOS.
114 for ( i
= 0; i
< 4; i
++ )
116 kernBootStruct
->diskInfo
[i
] = get_diskinfo(0x80 + i
);
119 // Update kernDev from biosdev.
121 switch ( BIOS_DEV_TYPE( biosdev
) )
123 case kBIOSDevTypeNetwork
:
124 kernBootStruct
->kernDev
= B_TYPE(DEV_EN
); break;
125 case kBIOSDevTypeHardDrive
:
126 kernBootStruct
->kernDev
= B_TYPE(DEV_HD
); break;
127 case kBIOSDevTypeFloppy
:
128 kernBootStruct
->kernDev
= B_TYPE(DEV_FD
); break;