Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/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 0x8000 // 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#define KERNEL_VALID_ADDR(x) ((((unsigned long)x) >= KERNEL_ADDR ) && (((unsigned long)x) < (KERNEL_ADDR + KERNEL_LEN)))
90
91#ifdef ZALLOC
92#define ZALLOC_ADDR 0x08100000 // 256M zalloc area
93#define ZALLOC_LEN 0x10000000
94#define ZALLOC_VALID_MEMORY(x) ((((unsigned long)x) >= ZALLOC_ADDR ) && (((unsigned long)x) < (ZALLOC_ADDR + ZALLOC_LEN)))
95#define ALLOC_VALID_ADDR(x) ZALLOC_VALID_MEMORY(x)
96#else
97#define MALLOC_ADDR 0x08100000 // 256M malloc area
98#define MALLOC_LEN 0x10000000
99#define MALLOC_VALID_ADDR(x) ((((unsigned long)x) >= MALLOC_ADDR ) && (((unsigned long)x) < (MALLOC_ADDR + MALLOC_LEN)))
100#define ALLOC_VALID_ADDR(x) MALLOC_VALID_ADDR(x)
101#endif
102#define LOAD_ADDR 0x18100000 // 64M File load buffer
103#define LOAD_LEN 0x04000000
104
105#define APP_ALLOC_ADDR 0x1C100000 // 128M alloc area for all apps
106#define APP_ALLOC_LEN 0x8000000
107
108// Location of data fed to boot2 by the prebooter
109#define PREBOOT_DATA 0x24100000
110
111#define TFTP_ADDR LOAD_ADDR // tftp download buffer
112#define TFTP_LEN LOAD_LEN
113
114#define kLoadAddr LOAD_ADDR
115#define kLoadSize LOAD_LEN
116
117#define CONVENTIONAL_LEN 0x0A0000 // 640k
118#define EXTENDED_ADDR 0x100000 // 1024k
119
120#define ptov(paddr) ((paddr) - MEMBASE)
121#define vtop(vaddr) ((vaddr) + MEMBASE)
122
123/*
124 * Extract segment/offset from a linear address.
125 */
126#define OFFSET16(addr) ((addr) - BASE_ADDR)
127#define OFFSET(addr) ((addr) & 0xFFFF)
128#define SEGMENT(addr) (((addr) & 0xF0000) >> 4)
129
130/* Extract segment/offset in normalized form so that the resulting far pointer
131 will point to something that is very unlikely to straddle a segment.
132 This is sometimes known as a "huge" pointer.
133 */
134#define NORMALIZED_OFFSET(addr) ((addr) & 0x000F)
135#define NORMALIZED_SEGMENT(addr) (((addr) & 0xFFFF0) >> 4)
136
137/*
138 * We need a minimum of 32MB of system memory.
139 */
140#define MIN_SYS_MEM_KB (32 * 1024)
141
142/*
143 * The number of descriptor entries in the GDT.
144 */
145#define NGDTENT 7
146
147/*
148 * The total size of the GDT in bytes.
149 * Each descriptor entry require 8 bytes.
150 */
151#define GDTLIMIT ( NGDTENT * 8 )
152
153#ifndef PAGE_SIZE
154#define PAGE_SIZE 4096
155#endif
156
157#endif /* !__BOOT_MEMORY_H */
158

Archive Download this file

Revision: 2182