]> git.saurik.com Git - apple/boot.git/blob - i386/libsa/memory.h
boot-111.tar.gz
[apple/boot.git] / i386 / libsa / memory.h
1 /*
2 * Copyright (c) 1999 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 #ifndef __BOOT_MEMORY_H
27 #define __BOOT_MEMORY_H
28
29 /* Memory addresses used by booter and friends */
30
31 #define BASE_SEG 0x2000
32 #define STACK_SEG 0x3000
33 #define STACK_OFS 0xFFF0 // stack pointer
34
35 #define BOOT1U_SEG 0x1000
36 #define BOOT1U_OFS 0x0200
37
38 #define BOOT2_SEG BASE_SEG
39 #define BOOT2_OFS 0x0200 // 512 byte disk sector offset
40
41 #define BIOS_ADDR 0x0C00 // BIOS disk I/O buffer
42 #define BIOS_LEN 0x2000 // 8K - divisible by 512 and 2048
43
44 /* These are all "virtual" addresses...
45 * which are physical addresses plus MEMBASE.
46 */
47 #define ADDR32(seg, ofs) (((seg) << 4 ) + (ofs))
48
49 #define MEMBASE 0x0
50
51 #define BOOTSTRUCT_ADDR 0x011000 // it's slightly smaller
52 #define BOOTSTRUCT_LEN 0x00F000
53
54 #define BASE_ADDR ADDR32(BASE_SEG, 0)
55 #define BASE1U_ADDR ADDR32(BOOT1U_SEG, 0)
56 #define BOOT1U_ADDR ADDR32(BOOT1U_SEG, BOOT1U_OFS)
57 #define BOOT2_ADDR ADDR32(BOOT2_SEG, BOOT2_OFS)
58
59 #define VIDEO_ADDR 0x0A0000 // unusable space
60 #define VIDEO_LEN 0x060000
61
62 #define KERNEL_ADDR 0x0100000 // 64M kernel + drivers
63 #define KERNEL_LEN 0x4000000
64
65 #define ZALLOC_ADDR 0x4100000 // 47M zalloc area
66 #define ZALLOC_LEN 0x2F00000
67
68 #define LOAD_ADDR 0x7000000 // 16M File load buffer
69 #define LOAD_LEN 0x1000000
70
71 #define TFTP_ADDR LOAD_ADDR // tftp download buffer
72 #define TFTP_LEN LOAD_LEN
73
74 #define kLoadAddr LOAD_ADDR
75 #define kLoadSize LOAD_LEN
76
77 #define CONVENTIONAL_LEN 0x0A0000 // 640k
78 #define EXTENDED_ADDR 0x100000 // 1024k
79
80 #define ptov(paddr) ((paddr) - MEMBASE)
81 #define vtop(vaddr) ((vaddr) + MEMBASE)
82
83 /*
84 * Extract segment/offset from a linear address.
85 */
86 #define OFFSET16(addr) ((addr) - BASE_ADDR)
87 #define OFFSET1U16(addr) ((addr) - BASE1U_ADDR)
88 #define OFFSET(addr) ((addr) & 0xFFFF)
89 #define SEGMENT(addr) (((addr) & 0xF0000) >> 4)
90
91 /*
92 * We need a minimum of 32MB of system memory.
93 */
94 #define MIN_SYS_MEM_KB (32 * 1024)
95
96 /*
97 * The number of descriptor entries in the GDT.
98 */
99 #define NGDTENT 7
100
101 /*
102 * The total size of the GDT in bytes.
103 * Each descriptor entry require 8 bytes.
104 */
105 #define GDTLIMIT ( NGDTENT * 8 )
106
107 #endif /* !__BOOT_MEMORY_H */