Moved ATA driver into its own package
[movitz-core.git] / multiboot.lisp
blob764e997f13997ff3dba2fe768c932c1034355938
1 ;;;;------------------------------------------------------------------
2 ;;;;
3 ;;;; Copyright (C) 2001-2002, 2004,
4 ;;;; Department of Computer Science, University of Tromso, Norway.
5 ;;;;
6 ;;;; For distribution policy, see the accompanying file COPYING.
7 ;;;;
8 ;;;; Filename: multiboot.lisp
9 ;;;; Description:
10 ;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
11 ;;;; Created at: Wed Jun 12 12:14:12 2002
12 ;;;;
13 ;;;; $Id: multiboot.lisp,v 1.5 2004/07/28 14:23:37 ffjeld Exp $
14 ;;;;
15 ;;;;------------------------------------------------------------------
17 (in-package movitz)
19 ;;; The layout of the Multiboot header must be as follows:
20 ;;;
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)
39 ((scan-skip-header
40 :binary-type lu32
41 :initform +scan-skip-word+)
42 (scan-skip-length
43 :binary-type lu32
44 :initform 0
45 :map-binary-write (lambda (x type)
46 (declare (ignore x type))
47 (- (sizeof 'multiboot-header) 8)))
48 (magic
49 :accessor magic
50 :initform +multiboot-header-magic-value+
51 :initarg :magic
52 :binary-type lu32)
53 (flags
54 :accessor flags
55 :initarg :flags
56 :initform '(:addresses-included)
57 :binary-type (define-bitfield multiboot-flags (lu32)
58 (((:bits)
59 ;; Align modules to 4K boundaries?
60 :align-modules-4k 0
61 ;; Pass memory information to the kernel?
62 :pass-memory-info 1
63 ;; Pass video modes information to the kernel
64 :pass-video-info 2
65 ;; Is the address fiels below included in the header?
66 :addresses-included 16))))
67 (checksum
68 :accessor checksum
69 :initform (ldb (byte 32 0)
70 (- (+ +multiboot-header-magic-value+
71 (enum-value 'multiboot-flags '(:addresses-included)))))
72 :binary-type lu32)
73 (header-address
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
78 ;; memory addresses.
79 :accessor header-address
80 :initarg :header-address
81 :binary-type lu32)
82 (load-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
90 :binary-type lu32)
91 (load-end-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
98 ;; image file.
99 :accessor load-end-address
100 :initarg :load-end-address
101 :binary-type lu32)
102 (bss-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
111 :initform 0
112 :binary-type lu32)
113 (entry-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
118 :binary-type lu32)
119 (video-mode-type
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
124 ;; mode.
125 :accessor video-mode-type
126 :initarg :video-mode-type
127 :initform 0
128 :binary-type lu32)
129 (video-width
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
135 :initform 0
136 :binary-type lu32)
137 (video-height
138 :accessor video-height
139 :initarg :video-height
140 :initform 0
141 :binary-type lu32)
142 (video-depth
143 :accessor video-depth
144 :initarg :video-depth
145 :initform 0
146 :binary-type lu32)))
148 (defmethod movitz-object-offset ((obj multiboot-header)) 0)