Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/libsa/memory.h

1/*
2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
12 * this file.
13 *
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
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef __BOOT_MEMORY_H
26#define __BOOT_MEMORY_H
27
28/* Memory addresses used by booter and friends */
29
30/* DFE 2007-12-21: Changed BASE_SEG to be conditional
31 This allows boot1u and other planned first-stage booters to avoid
32 maintaining their own copies of asm.s and bios.s and instead
33 simply build the files from libsaio with the right preprocessor
34 definitions.
35
36 This affects BASE_ADDR and OFFSET16() thus obviating the need for
37 separate BASE1U_ADDR and OFFSET1U16() macros.
38
39 Be careful though as changing these values with preprocessor macros
40 obviously requires rebuilding the source files. That means in particular
41 that libsaio.a is only suitable for boot2.
42 */
43#if defined(BASE_SEG)
44/* assume user knows what he's doing */
45#elif defined(BOOT1)
46# define BASE_SEG BOOT1U_SEG
47#else
48# define BASE_SEG BOOT2_SEG
49#endif
50
51#define STACK_SEG0x1000// zef: old STACK_SEG 0x5000
52#define STACK_OFS0xFFF0// stack pointer
53
54#define BOOT1U_SEG0x1000
55#define BOOT1U_OFS0x0200
56
57#define BOOT2_SEG0x2000
58#define BOOT2_OFS0x0200// 512 byte disk sector offset
59
60#define BOOT2_MAX_LENGTH0x6FE00// Maximum size for boot2 is currentl 447kb
61
62#define BIOS_ADDR0x8000// BIOS disk I/O buffer
63#define BIOS_LEN0x8000// 32K - divisible by 512 and 2048
64
65#define BOOT0_ADDR0x7E00// boot0 gets loaded here
66
67
68/* These are all "virtual" addresses...
69 * which are physical addresses plus MEMBASE.
70 */
71#define ADDR32(seg, ofs) (((seg) << 4 ) + (ofs))
72
73#define MEMBASE 0x0
74
75#define BOOTSTRUCT_ADDR 0x00011000 // it's slightly smaller
76#define BOOTSTRUCT_LEN 0x0000F000
77
78#define BASE_ADDR ADDR32(BASE_SEG, 0)
79#define BOOT1U_ADDR ADDR32(BOOT1U_SEG, BOOT1U_OFS)
80#define BOOT2_ADDR ADDR32(BOOT2_SEG, BOOT2_OFS)
81// TODO: BOOT_ADDR ?
82
83#define HIB_ADDR 0x00040000 // special hibernation area
84#define HIB_LEN 0x00060000
85
86#define VIDEO_ADDR 0x000A0000 // unusable space
87#define VIDEO_LEN 0x00060000
88
89#define KERNEL_ADDR 0x00100000 // 128M kernel + drivers
90#define KERNEL_LEN 0x08000000
91
92#define ZALLOC_ADDR 0x08100000 // 256M zalloc area
93
94#define ZALLOC_LEN 0x10000000 // Reverted from commit 2554 was 0x14000000
95
96#define LOAD_ADDR 0x18100000 // 64M File load buffer
97#define LOAD_LEN 0x04000000
98
99// Location of data fed to boot2 by the prebooter
100#define PREBOOT_DATA 0x1C100000 // Still have enough room for a 63M ramdisk image
101 // in case of 512MB system memory.
102
103#define TFTP_ADDR LOAD_ADDR // tftp download buffer
104#define TFTP_LEN LOAD_LEN
105
106#define kLoadAddr LOAD_ADDR
107#define kLoadSize LOAD_LEN
108
109#define CONVENTIONAL_LEN 0x0A0000 // 640k
110#define EXTENDED_ADDR 0x100000 // 1024k
111
112#define ptov(paddr) ((paddr) - MEMBASE)
113#define vtop(vaddr) ((vaddr) + MEMBASE)
114
115/*
116 * Extract segment/offset from a linear address.
117 */
118#define OFFSET16(addr) ((addr) - BASE_ADDR)
119#define OFFSET(addr) ((addr) & 0xFFFF)
120#define SEGMENT(addr) (((addr) & 0xF0000) >> 4)
121
122/*
123 * Extract segment/offset in normalized form so that the resulting far pointer
124 * will point to something that is very unlikely to straddle a segment.
125 * This is sometimes known as a "huge" pointer.
126 */
127#define NORMALIZED_OFFSET(addr) ((addr) & 0x000F)
128#define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4)
129
130/*
131 * We need a minimum of 32MB of system memory.
132 */
133#define MIN_SYS_MEM_KB (32 * 1024)
134
135/*
136 * The number of descriptor entries in the GDT (Global Descriptor Table).
137 */
138#define NGDTENT 7
139
140/*
141 * The total size of the GDT in bytes.
142 * Each descriptor entry require 8 bytes.
143 */
144#define GDTLIMIT (NGDTENT * 8)
145
146#endif /* !__BOOT_MEMORY_H */
147

Archive Download this file

Revision: 2565