]>
git.saurik.com Git - apple/boot.git/blob - i386/libsaio/bootstruct.c
18c9ccdd161ce91ab433049342a1fd88ed1ffe7a
2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999-2003 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 2.0 (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.
30 #include "bootstruct.h"
32 // CMOS access ports in I/O space.
38 /*==========================================================================
39 * Returns the number of active ATA drives since these will increment the
40 * bios device numbers of SCSI drives.
42 static int countIDEDisks()
45 unsigned short hdtype
;
48 struct driveParameters param
;
50 printf("Reading drive parameters...\n");
51 readDriveParameters(0x80, ¶m
);
52 printf("%d fixed disk drive(s) installed\n", param
.totalDrives
);
53 for (count
= 0; count
< 256; count
++)
55 if (readDriveParameters(count
+ 0x80, ¶m
))
59 printf("Drive %d: %d cyls, %d heads, %d sectors\n",
60 count
, param
.cylinders
, param
.heads
, param
.sectors
);
64 printf("CMOS addr 0x11 = %x\n",inb(CMOSDATA
));
66 printf("CMOS addr 0x12 = %x\n",inb(CMOSDATA
));
70 outb( CMOSADDR
, HDTYPE
);
71 hdtype
= (unsigned short) inb( CMOSDATA
);
73 if (hdtype
& 0xF0) count
++;
74 if (hdtype
& 0x0F) count
++;
78 /*==========================================================================
79 * Initialize the 'kernBootStruct'. A structure of parameters passed to
80 * the kernel by the booter.
83 KernelBootArgs_t
*bootArgs
;
85 void initKernBootStruct( int biosdev
)
87 static int init_done
= 0;
89 bootArgs
= (KernelBootArgs_t
*)KERNSTRUCT_ADDR
;
93 bzero(bootArgs
, sizeof(KernelBootArgs_t
));
95 // Get system memory map. Also update the size of the
96 // conventional/extended memory for backwards compatibility.
98 bootArgs
->memoryMapCount
=
99 getMemoryMap( bootArgs
->memoryMap
, kMemoryMapCountMax
,
100 (unsigned long *) &bootArgs
->convmem
,
101 (unsigned long *) &bootArgs
->extmem
);
103 if ( bootArgs
->memoryMapCount
== 0 )
105 // BIOS did not provide a memory map, systems with
106 // discontiguous memory or unusual memory hole locations
107 // may have problems.
109 bootArgs
->convmem
= getConventionalMemorySize();
110 bootArgs
->extmem
= getExtendedMemorySize();
113 bootArgs
->magicCookie
= KERNBOOTMAGIC
;
114 bootArgs
->configEnd
= bootArgs
->config
;
115 bootArgs
->graphicsMode
= TEXT_MODE
;
118 /* XXX initialize bootArgs here */
123 // Get number of ATA devices.
125 bootArgs
->numDrives
= countIDEDisks();
127 // Update kernDev from biosdev.
129 bootArgs
->kernDev
= biosdev
;
133 /* Copy boot args after kernel and record address. */
136 reserveKernBootStruct(void)
138 void *oldAddr
= bootArgs
;
139 bootArgs
= (KernelBootArgs_t
*)AllocateKernelMemory(sizeof(KERNBOOTSTRUCT
));
140 bcopy(oldAddr
, bootArgs
, sizeof(KernelBootArgs_t
));