]>
Commit | Line | Data |
---|---|---|
f083c6c3 A |
1 | /* |
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. | |
7 | * | |
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 | |
13 | * file. | |
14 | * | |
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. | |
22 | * | |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | ||
26 | #include "sl.h" | |
27 | #include "saio_internal.h" | |
28 | #include "bootstruct.h" | |
29 | ||
30 | static long gImageLastKernelAddr; | |
31 | ||
32 | #define kPageSize 4096 | |
33 | #define RoundPage(x) ((((unsigned)(x)) + kPageSize - 1) & ~(kPageSize - 1)) | |
34 | ||
35 | ||
36 | long | |
37 | AllocateMemoryRange(char * rangeName, long start, long length, long type) | |
38 | { | |
39 | if ( bootArgs->numBootDrivers < NDRIVERS ) | |
40 | { | |
41 | int num = bootArgs->numBootDrivers; | |
42 | ||
43 | bootArgs->driverConfig[num].address = start; | |
44 | bootArgs->driverConfig[num].size = length; | |
45 | bootArgs->driverConfig[num].type = type; | |
46 | bootArgs->numBootDrivers++; | |
47 | } | |
48 | else | |
49 | { | |
50 | stop( "AllocateMemoryRange error" ); | |
51 | } | |
52 | return 0; | |
53 | } | |
54 | ||
55 | long | |
56 | AllocateKernelMemory( long inSize ) | |
57 | { | |
58 | long addr; | |
59 | ||
60 | if (gImageLastKernelAddr == 0) { | |
61 | gImageLastKernelAddr = RoundPage( bootArgs->kaddr + | |
62 | bootArgs->ksize ); | |
63 | } | |
64 | addr = gImageLastKernelAddr; | |
65 | gImageLastKernelAddr += RoundPage(inSize); | |
66 | ||
67 | if ( gImageLastKernelAddr >= (KERNEL_ADDR + KERNEL_LEN) ) { | |
68 | stop ("AllocateKernelMemory error"); | |
69 | } | |
70 | ||
71 | bootArgs->ksize = gImageLastKernelAddr - bootArgs->kaddr; | |
72 | ||
73 | return addr; | |
74 | } |