]> git.saurik.com Git - apple/boot.git/blobdiff - i386/libsa/memory.h
boot-132.tar.gz
[apple/boot.git] / i386 / libsa / memory.h
index ee658946d8fb16da2dbba6f309868b33259292c4..bb473dc4db885f9d0030cd04ed69ed820f929a4b 100644 (file)
@@ -1,12 +1,12 @@
 /*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
+ * Portions Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights
  * Reserved.  This file contains Original Code and/or Modifications of
  * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License").  You may not use this file
+ * Source License Version 2.0 (the "License").  You may not use this file
  * except in compliance with the License.  Please obtain a copy of the
  * License at http://www.apple.com/publicsource and read it before using
  * this file.
 
 /* Memory addresses used by booter and friends */
 
+#define BASE_SEG          0x2000
+#define STACK_SEG         0x5000
+#define STACK_OFS         0xFFF0      // stack pointer
+
+#define BOOT1U_SEG        0x1000
+#define BOOT1U_OFS        0x0200
+
+#define BOOT2_SEG         BASE_SEG
+#define BOOT2_OFS         0x0200      // 512 byte disk sector offset
+
+#define BIOS_ADDR         0x8000      // BIOS disk I/O buffer
+#define BIOS_LEN          0x8000      // 32K - divisible by 512 and 2048
+
+#define BOOT0_ADDR        0x7E00      // boot0 gets loaded here
+
+
 /* These are all "virtual" addresses...
  * which are physical addresses plus MEMBASE.
  */
-#define MEMBASE             0x0
-#define BASE_SEG            0x0
-
-#define BIOS_ADDR           0x000C00    // BIOS buffer
-#define BIOS_LEN            0x002400    // 9k
-#define BOOTER_LOAD_ADDR    0x003000    // loaded here for compat.
-#define BOOTER_ADDR         0x003000    // start of booter code
-#define BOOTER_LEN          0x00B000
-#define STACK_ADDR          0x00FFF0
-#define BOOTSTRUCT_ADDR     0x011000    // it's slightly smaller
-#define BOOTSTRUCT_LEN      0x00F000
-#define RLD_ADDR            0x030000    // not used
-#define RLD_LEN             0x070000
-#define VIDEO_ADDR          0x0A0000    // unusable space
-#define VIDEO_LEN           0x060000
-#define KERNEL_ADDR         0x100000    // 14Mb kernel + drivers
-#define KERNEL_LEN          0xe00000
-#define ZALLOC_ADDR         0xf00000    // 1Mb for zalloc
-#define ZALLOC_LEN          0x100000
-#define TFTP_ADDR           0x1000000   // 8Mb download buffer
-#define TFTP_LEN            0x800000
-
-/* These are physical values */
-
-#define CONVENTIONAL_LEN    0x0A0000      // 640k
-#define EXTENDED_ADDR       0x100000      // 1024k
-#define KERNEL_BOOT_ADDR    KERNEL_ADDR   // load at 1Mb
-
-#define ptov(paddr) ((paddr) - MEMBASE)
-#define vtop(vaddr) ((vaddr) + MEMBASE)
+#define ADDR32(seg, ofs)  (((seg) << 4 ) + (ofs))
+
+#define MEMBASE           0x0
+
+#define BOOTSTRUCT_ADDR   0x00011000    // it's slightly smaller
+#define BOOTSTRUCT_LEN    0x0000F000
+
+#define BASE_ADDR         ADDR32(BASE_SEG, 0)
+#define BASE1U_ADDR       ADDR32(BOOT1U_SEG, 0)
+#define BOOT1U_ADDR       ADDR32(BOOT1U_SEG, BOOT1U_OFS)
+#define BOOT2_ADDR        ADDR32(BOOT2_SEG, BOOT2_OFS)
+
+#define HIB_ADDR          0x00040000    // special hibernation area
+#define HIB_LEN           0x00060000
+
+#define VIDEO_ADDR        0x000A0000    // unusable space
+#define VIDEO_LEN         0x00060000
+
+#define KERNEL_ADDR       0x00100000   // 64M kernel + drivers
+#define KERNEL_LEN        0x04000000
+
+#define ZALLOC_ADDR       0x04100000   // 39M zalloc area
+#define ZALLOC_LEN        0x02700000
+
+#define LOAD_ADDR         0x06800000   // 24M File load buffer
+#define LOAD_LEN          0x01800000
+
+#define TFTP_ADDR         LOAD_ADDR   // tftp download buffer
+#define TFTP_LEN          LOAD_LEN
+
+#define kLoadAddr         LOAD_ADDR
+#define kLoadSize         LOAD_LEN
+
+#define CONVENTIONAL_LEN  0x0A0000    // 640k
+#define EXTENDED_ADDR     0x100000    // 1024k
+
+#define ptov(paddr)       ((paddr) - MEMBASE)
+#define vtop(vaddr)       ((vaddr) + MEMBASE)
+
+/*
+ * Extract segment/offset from a linear address.
+ */
+#define OFFSET16(addr)    ((addr) - BASE_ADDR)
+#define OFFSET1U16(addr)  ((addr) - BASE1U_ADDR)
+#define OFFSET(addr)      ((addr) & 0xFFFF)
+#define SEGMENT(addr)     (((addr) & 0xF0000) >> 4)
+
+/*
+ * We need a minimum of 32MB of system memory.
+ */
+#define MIN_SYS_MEM_KB  (32 * 1024)
 
 /*
- * Limits to the size of various things...
+ * The number of descriptor entries in the GDT.
  */
+#define NGDTENT   7
 
 /*
- * We need a minimum of 24Mb of system memory.
+ * The total size of the GDT in bytes.
+ * Each descriptor entry require 8 bytes.
  */
-#define MIN_SYS_MEM_KB  (24 * 1024)
+#define GDTLIMIT  ( NGDTENT * 8 )
 
 #endif /* !__BOOT_MEMORY_H */