stage1: add header
parent
bfc2b5cb7c
commit
43d454e9fe
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This is the first file to be included in mod.rs,
|
||||
* which exposes its contents to all following files
|
||||
*/
|
||||
|
||||
.macro LOCAL name, type=function
|
||||
.type \name , @\type
|
||||
\name :
|
||||
.endm
|
||||
|
||||
.macro GLOBL name, type=function
|
||||
.global \name
|
||||
.type \name , %\type
|
||||
\name :
|
||||
.endm
|
||||
|
||||
.macro END name
|
||||
.size \name , . - \name
|
||||
.endm
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This sits at the very beginning of the stage1 image, which in turn is
|
||||
* located at the beginning of the bussy boot partition. stage0 always reads
|
||||
* the first 32 K of that partition to 0x0500, validates the magic number and
|
||||
* checksum, and then jumps to the entry point at 0x0510.
|
||||
*
|
||||
* ATTENTION: if you change the structure of this header, you must
|
||||
* also change the (hardcoded) offsets in stage0.s and build.py!
|
||||
*/
|
||||
|
||||
.extern _stage1_start /* stage1.ld */
|
||||
.extern _stage1_end /* stage1.ld */
|
||||
|
||||
.section .header, "awx"
|
||||
.code16
|
||||
|
||||
/*
|
||||
* offset 0x00 (loaded at 0x0500)
|
||||
* stage1 magic number. stage0 checks this.
|
||||
*/
|
||||
GLOBL _stage1_magic, object
|
||||
.word 0xacab
|
||||
END _stage1_magic
|
||||
|
||||
/*
|
||||
* offset 0x02 (loaded at 0x0502)
|
||||
* Length of the entire stage1 image in bytes, excluding bss.
|
||||
* Hardcoded during image build. Must not exceed 32 K.
|
||||
*/
|
||||
GLOBL _stage1_len, object
|
||||
.word 0x8000
|
||||
END _stage1_len
|
||||
|
||||
/*
|
||||
* offset 0x04 (loaded at 0x0504)
|
||||
* CRC32 (polynomial 0x04c11db7) checksum of the entire stage1 image
|
||||
* as defined by the length field at offset 0x02. Must be zeroed for
|
||||
* checksum calculation. stage0 checks AND CLEARS this.
|
||||
* Hardcoded during image build.
|
||||
*/
|
||||
GLOBL _stage1_csum, object
|
||||
.long 0
|
||||
END _stage1_csum
|
||||
|
||||
/*
|
||||
* offset 0x08 (loaded at 0x0508)
|
||||
* Reserved; MUST be set to 0. stage0 ignores this.
|
||||
*/
|
||||
.quad 0
|
||||
|
||||
/*
|
||||
* offset 0x10 (loaded at 0x0510)
|
||||
* stage1 entry point. stage0 jumps here.
|
||||
*/
|
||||
GLOBL _start
|
||||
1: jmp 1b
|
||||
END _start
|
@ -0,0 +1,21 @@
|
||||
macro_rules! include_asm {
|
||||
($name:literal) => {
|
||||
::core::arch::global_asm!(
|
||||
::core::concat!(".file \"", $name, "\""), // for better debugging
|
||||
::core::include_str!($name),
|
||||
::core::concat!(".file \"", ::core::file!(), "\""),
|
||||
options(raw, att_syntax),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// common macros for the other assembly files, keep at the beginning
|
||||
include_asm!("common.s");
|
||||
|
||||
// stage1 header containing its magic, size, checksum, and entry point
|
||||
include_asm!("header.s");
|
||||
extern "C" {
|
||||
pub static _stage1_magic: u16;
|
||||
pub static _stage1_len: u16;
|
||||
pub static _stage1_csum: u32;
|
||||
}
|
Loading…
Reference in New Issue