Chameleon

Chameleon Svn Source Tree

Root/branches/blackosx/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_SEG 0x1000// zef: old STACK_SEG 0x5000
52#define STACK_OFS 0xFFF0 // stack pointer
53
54#define BOOT1U_SEG 0x1000
55#define BOOT1U_OFS 0x0200
56
57#define BOOT2_SEG 0x2000
58#define BOOT2_OFS 0x0200 // 512 byte disk sector offset
59
60#define BIOS_ADDR 0x9000 // BIOS disk I/O buffer
61#define BIOS_LEN 0x8000 // 32K - divisible by 512 and 2048
62
63#define BOOT0_ADDR 0x7E00 // boot0 gets loaded here
64
65
66/* These are all "virtual" addresses...
67 * which are physical addresses plus MEMBASE.
68 */
69#define ADDR32(seg, ofs) (((seg) << 4 ) + (ofs))
70
71#define MEMBASE 0x0
72
73#define BOOTSTRUCT_ADDR 0x00011000 // it's slightly smaller
74#define BOOTSTRUCT_LEN 0x0000F000
75
76#define BASE_ADDR ADDR32(BASE_SEG, 0)
77#define BOOT1U_ADDR ADDR32(BOOT1U_SEG, BOOT1U_OFS)
78#define BOOT2_ADDR ADDR32(BOOT2_SEG, BOOT2_OFS)
79// TODO: BOOT_ADDR ?
80
81#define HIB_ADDR 0x00040000 // special hibernation area
82#define HIB_LEN 0x00060000
83
84#define VIDEO_ADDR 0x000A0000 // unusable space
85#define VIDEO_LEN 0x00060000
86
87#define KERNEL_ADDR 0x00100000 // 128M kernel + drivers
88#define KERNEL_LEN 0x08000000
89
90#define ZALLOC_ADDR 0x08100000 // 256M zalloc area
91#define ZALLOC_LEN 0x10000000
92
93#define LOAD_ADDR 0x18100000 // 64M File load buffer
94#define LOAD_LEN 0x04000000
95
96// Location of data fed to boot2 by the prebooter
97#define PREBOOT_DATA 0x1C100000 // Still have enough room for a 63M ramdisk image
98 // in case of 512MB system memory.
99
100#define TFTP_ADDR LOAD_ADDR // tftp download buffer
101#define TFTP_LEN LOAD_LEN
102
103#define kLoadAddr LOAD_ADDR
104#define kLoadSize LOAD_LEN
105
106#define CONVENTIONAL_LEN 0x0A0000 // 640k
107#define EXTENDED_ADDR 0x100000 // 1024k
108
109#define ptov(paddr) ((paddr) - MEMBASE)
110#define vtop(vaddr) ((vaddr) + MEMBASE)
111
112/*
113 * Extract segment/offset from a linear address.
114 */
115#define OFFSET16(addr) ((addr) - BASE_ADDR)
116#define OFFSET(addr) ((addr) & 0xFFFF)
117#define SEGMENT(addr) (((addr) & 0xF0000) >> 4)
118
119/* Extract segment/offset in normalized form so that the resulting far pointer
120 will point to something that is very unlikely to straddle a segment.
121 This is sometimes known as a "huge" pointer.
122 */
123#define NORMALIZED_OFFSET(addr) ((addr) & 0x000F)
124#define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4)
125
126/*
127 * We need a minimum of 32MB of system memory.
128 */
129#define MIN_SYS_MEM_KB (32 * 1024)
130
131/*
132 * The number of descriptor entries in the GDT.
133 */
134#define NGDTENT 7
135
136/*
137 * The total size of the GDT in bytes.
138 * Each descriptor entry require 8 bytes.
139 */
140#define GDTLIMIT ( NGDTENT * 8 )
141
142#endif /* !__BOOT_MEMORY_H */
143

Archive Download this file

Revision: 215