1 ;;;;------------------------------------------------------------------
3 ;;;; Copyright (C) 2001-2002, 2004,
4 ;;;; Department of Computer Science, University of Tromso, Norway.
6 ;;;; For distribution policy, see the accompanying file COPYING.
8 ;;;; Filename: multiboot.lisp
10 ;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
11 ;;;; Created at: Wed Jun 12 12:14:12 2002
13 ;;;; $Id: multiboot.lisp,v 1.5 2004/07/28 14:23:37 ffjeld Exp $
15 ;;;;------------------------------------------------------------------
19 ;;; The layout of the Multiboot header must be as follows:
21 ;;; Offset Type Field Name Note
22 ;;; 0 u32 magic required
23 ;;; 4 u32 flags required
24 ;;; 8 u32 checksum required
25 ;;; 12 u32 header_addr if flags[16] is set
26 ;;; 16 u32 load_addr if flags[16] is set
27 ;;; 20 u32 load_end_addr if flags[16] is set
28 ;;; 24 u32 bss_end_addr if flags[16] is set
29 ;;; 28 u32 entry_addr if flags[16] is set
30 ;;; 32 u32 mode_type if flags[2] is set
31 ;;; 36 u32 width if flags[2] is set
32 ;;; 40 u32 height if flags[2] is set
33 ;;; 44 u32 depth if flags[2] is set
36 (defconstant +multiboot-header-magic-value
+ #x1BADB002
)
38 (define-binary-class multiboot-header
(movitz-heap-object)
41 :initform
+scan-skip-word
+)
45 :map-binary-write
(lambda (x type
)
46 (declare (ignore x type
))
47 (- (sizeof 'multiboot-header
) 8)))
50 :initform
+multiboot-header-magic-value
+
56 :initform
'(:addresses-included
)
57 :binary-type
(define-bitfield multiboot-flags
(lu32)
59 ;; Align modules to 4K boundaries?
61 ;; Pass memory information to the kernel?
63 ;; Pass video modes information to the kernel
65 ;; Is the address fiels below included in the header?
66 :addresses-included
16))))
69 :initform
(ldb (byte 32 0)
70 (- (+ +multiboot-header-magic-value
+
71 (enum-value 'multiboot-flags
'(:addresses-included
)))))
74 ;; Contains the address corresponding to the beginning of the
75 ;; Multiboot header -- the physical memory location at which the
76 ;; magic value is supposed to be loaded. This field serves to
77 ;; "synchronize" the mapping between OS image offsets and physical
79 :accessor header-address
80 :initarg
:header-address
83 ;; Contains the physical address of the beginning of the text
84 ;; segment. The offset in the OS image file at which to start
85 ;; loading is defined by the offset at which the header was found,
86 ;; minus (header_addr - load_addr). load_addr must be less than or
87 ;; equal to header_addr.
88 :accessor load-address
89 :initarg
:load-address
92 ;; Contains the physical address of the end of the data segment.
93 ;; (load_end_addr - load_addr) specifies how much data to load.
94 ;; This implies that the text and data segments must be
95 ;; consecutive in the OS image; this is true for existing a.out
96 ;; executable formats. If this field is zero, the boot loader
97 ;; assumes that the text and data segments occupy the whole OS
99 :accessor load-end-address
100 :initarg
:load-end-address
103 ;; Contains the physical address of the end of the bss
104 ;; segment. The boot loader initializes this area to zero, and
105 ;; reserves the memory it occupies to avoid placing boot modules
106 ;; and other data relevant to the operating system in that
107 ;; area. If this field is zero, the boot loader assumes that no
108 ;; bss segment is present.
109 :accessor bss-end-address
110 :initarg
:bss-end-address
114 ;; The physical address to which the boot loader should jump in
115 ;; order to start running the operating system.
116 :accessor entry-address
117 :initarg
:entry-address
120 ;; Valid numbers for `mode_type' is 0 for linear graphics mode and
121 ;; 1 for EGA-standard text mode. Everything else is reserved for
122 ;; future expansion. Please note that even if you set this field
123 ;; to indicate that you want a graphics mode, you might get a text
125 :accessor video-mode-type
126 :initarg
:video-mode-type
130 ;; `width' and `height' is specified in pixels, if graphics mode,
131 ;; or characters in EGA text mode. `depth' is given in bits per
132 ;; pixel for graphics, or zero for EGA text modes.
133 :accessor video-width
134 :initarg
:video-width
138 :accessor video-height
139 :initarg
:video-height
143 :accessor video-depth
144 :initarg
:video-depth
148 (defmethod movitz-object-offset ((obj multiboot-header
)) 0)