]>
git.saurik.com Git - apple/boot.git/blob - i386/libsaio/bootstruct.c
dc3bdb4aa75ca690f83947cddfcb8f8f0e35948a
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright 1993 NeXT, Inc.
27 * All rights reserved.
31 #include "bootstruct.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.
43 static int countIDEDisks()
46 unsigned short hdtype
;
49 struct driveParameters param
;
51 printf("Reading drive parameters...\n");
52 readDriveParameters(0x80, ¶m
);
53 printf("%d fixed disk drive(s) installed\n", param
.totalDrives
);
54 for (count
= 0; count
< 256; count
++)
56 if (readDriveParameters(count
+ 0x80, ¶m
))
60 printf("Drive %d: %d cyls, %d heads, %d sectors\n",
61 count
, param
.cylinders
, param
.heads
, param
.sectors
);
65 printf("CMOS addr 0x11 = %x\n",inb(CMOSDATA
));
67 printf("CMOS addr 0x12 = %x\n",inb(CMOSDATA
));
71 outb( CMOSADDR
, HDTYPE
);
72 hdtype
= (unsigned short) inb( CMOSDATA
);
74 if (hdtype
& 0xF0) count
++;
75 if (hdtype
& 0x0F) count
++;
79 /*==========================================================================
80 * Initialize the 'kernBootStruct'. A structure of parameters passed to
81 * the kernel by the booter.
84 KernelBootArgs_t
*bootArgs
;
86 void initKernBootStruct( int biosdev
)
88 static int init_done
= 0;
90 bootArgs
= (KernelBootArgs_t
*)KERNSTRUCT_ADDR
;
94 bzero(bootArgs
, sizeof(KernelBootArgs_t
));
96 // Get system memory map. Also update the size of the
97 // conventional/extended memory for backwards compatibility.
99 bootArgs
->memoryMapCount
=
100 getMemoryMap( bootArgs
->memoryMap
, kMemoryMapCountMax
,
101 (unsigned long *) &bootArgs
->convmem
,
102 (unsigned long *) &bootArgs
->extmem
);
104 if ( bootArgs
->memoryMapCount
== 0 )
106 // BIOS did not provide a memory map, systems with
107 // discontiguous memory or unusual memory hole locations
108 // may have problems.
110 bootArgs
->convmem
= getConventionalMemorySize();
111 bootArgs
->extmem
= getExtendedMemorySize();
114 bootArgs
->magicCookie
= KERNBOOTMAGIC
;
115 bootArgs
->configEnd
= bootArgs
->config
;
116 bootArgs
->graphicsMode
= TEXT_MODE
;
119 /* XXX initialize bootArgs here */
124 // Get number of ATA devices.
126 bootArgs
->numDrives
= countIDEDisks();
128 // Update kernDev from biosdev.
130 bootArgs
->kernDev
= biosdev
;
134 /* Copy boot args after kernel and record address. */
137 reserveKernBootStruct(void)
139 void *oldAddr
= bootArgs
;
140 bootArgs
= (KernelBootArgs_t
*)AllocateKernelMemory(sizeof(KERNBOOTSTRUCT
));
141 bcopy(oldAddr
, bootArgs
, sizeof(KernelBootArgs_t
));