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