multiboot2: Clean up the example kernel
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest27 patches 1 replyIn review
- v34 patches 8 repliesSuperseded
v4 changes over v3 from the cover letter
* Use ".balign 8" in all assembly code, removing ".align".
* No removing useless whitespace from assembly sources.
* As requested, consistently order the patterns in .gitignore:
Non-rooted patterns go before .gitignore-directory-rooted patterns, then sort each part with "LC_ALL=C sort".
* Add Reviewed-by to the autogen.sh patch.
* Split up the changes required to get the example kernel to build. As the build was broken from the start, it does not matter if any of these commits leaves the source tree in a state of broken build.
* Made the example kernel build for mips.
* Remove some obsolete remnants from supporting ancient autotools and from just copying over from Multiboot 1.
* Generate some more information about the example kernel to help understand how it is built and how it will behave.
* Update comments to read about "Multiboot 2" instead of "Multiboot".
* Clean up some things in the code (stack cleanups, label the header terminator tags, use builtin macro __ASSEMBLER__,
Patches in v4 No applies recorded yet
Reviews trailers per patch
1 of 27 patches has a Reviewed-by or Acked-by.
| Patch | Daniel Kiper |
|---|---|
| 1/27 | R-b |
| 2/27 | |
| 3/27 | |
| 4/27 | |
| 5/27 | |
| 6/27 | |
| 7/27 | |
| 8/27 | |
| 9/27 | |
| 10/27 | |
| 11/27 | |
| 12/27 | |
| 13/27 | |
| 14/27 | |
| 15/27 | |
| 16/27 | |
| 17/27 | |
| 18/27 | |
| 19/27 | |
| 20/27 | |
| 21/27 | |
| 22/27 | |
| 23/27 | |
| 24/27 | |
| 25/27 | |
| 26/27 | |
| 27/27 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel
This patch series cleans up the Multiboot2 build system and example kernel:
* Fix initializing the source tree with autogen.sh when using current gnulib.
* Change from obsolete .bzrignore to .gitignore.
* Fix the Multiboot2 header tag alignment in the assembly language boot_*.S files to 8 byte boundaries so that the resulting kernel image actually satisfies the Multiboot2 spec.
The i386 code used to have no alignment, and the mips code used to have 256 byte alignment. Neither of those satisfies the Multiboot 2 specification's 8 byte requirement.
* Document both i386 and mips boot code in the spec text.
* Fix build of the example kernel for both i386 and mips. No idea whether the kernels actually work, though.
Still looking for a few qemu commands to boot such an example kernel in a VM, preferably with gdb debugging, and especially for mips.
* Remove obsolete remnants from supporting pre-2003 autotools. We require 2008 autotools anyway, so we can drop those ancient workarounds from the late 1990s and early 2000s.
* Generate listing files, symbol lists, and a kernel map file to help people understand the built example kernel image.
Patch set revision history:
v4 changes over v3:
* Use ".balign 8" in all assembly code, removing ".align".
* No removing useless whitespace from assembly sources.
* As requested, consistently order the patterns in .gitignore:
Non-rooted patterns go before .gitignore-directory-rooted patterns, then sort each part with "LC_ALL=C sort".
* Add Reviewed-by to the autogen.sh patch.
* Split up the changes required to get the example kernel to build. As the build was broken from the start, it does not matter if any of these commits leaves the source tree in a state of broken build.
* Made the example kernel build for mips.
* Remove some obsolete remnants from supporting ancient autotools and from just copying over from Multiboot 1.
* Generate some more information about the example kernel to help understand how it is built and how it will behave.
* Update comments to read about "Multiboot 2" instead of "Multiboot".
* Clean up some things in the code (stack cleanups, label the header terminator tags, use builtin macro __ASSEMBLER__,
v3 changes over v2:
* improved .gitignore
* fix the case logic for the ix86 matching pattern ([[]])
* fix mb2 header tag alignment
* fix alignment on mips
Hans Ulrich Niedermann (27):
multiboot2: Allow autogen.sh to run with current gnulib
multiboot2: Use .gitignore files
multiboot2: Use m4 quoting and AS_HELP_STRING
multiboot2: Remove obsolete compat code for ancient Autoconf
multiboot2: Remove CCAS workarounds for pre-2005 Automake
multiboot2: Remove unnecessary definition of CC
multiboot2: Automake generates dependencies automatically
multiboot2: Automake cleans built programs automatically
multiboot2: Use the constants by their proper names
multiboot2: Rename boot.S to boot_i386.S
multiboot2: Add boot_i386.S to shipped files
multiboot2: Add boot_mips.S example code to docs
multiboot2: Build arch specific boot code
multiboot2: Fix example kernel header tag alignment
multiboot2: Remove unreferenced AOUT_KLUDGE
multiboot2: Change "Multiboot" in comments to "Multiboot2"
multiboot2: Clean up stack (cdecl calling conventions)
multiboot2: Use predefined #ifdef __ASSEMBLER__
multiboot2: Set -nostdlib before AC_PROG_CC for x-compile
multiboot2: mips build wants __start symbol
multiboot2: "make distcheck" with example kernel enabled
multiboot2: Always define the kernel_* vars
multiboot2: Generate per object file listings
multiboot2: Generate a kernel.map map file
multiboot2: Generate gcc temp files (*.i and *.s)
multiboot2: Generate symbol lists and disassembly file
multiboot2: Add labels around the termination tag
.bzrignore | 30 ---------------
.gitignore | 55 +++++++++++++++++++++++++++
Makefile.am | 2 +
configure.ac | 74 ++++++++++++++++++++++++++++---------
doc/.gitignore | 4 ++
doc/Makefile.am | 47 +++++++++++++++++++----
doc/{boot.S => boot_i386.S} | 28 +++++++-------
doc/boot_mips.S | 25 ++++++-------
doc/kernel.c | 4 +-
doc/multiboot.texi | 55 +++++++++++++++++----------
doc/multiboot2.h | 17 ++++++---
11 files changed, 231 insertions(+), 110 deletions(-)
delete mode 100644 .bzrignore
create mode 100644 .gitignore
create mode 100644 doc/.gitignore
rename doc/{boot.S => boot_i386.S} (85%)Interdiff:
.gitignore +17 -13
@@ -1,13 +1,9 @@ # Generated by "autogen.sh" -/gendocs.sh -/lib/ -/m4/ +Makefile.in +/INSTALL /NEWS /README - -Makefile.in - /aclocal.m4 /autom4te.cache/ /compile
@@ -18,13 +14,15 @@ Makefile.in /depcomp /doc/mdate-sh /doc/texinfo.tex +/gendocs.sh /install-sh -/INSTALL +/lib/ +/m4/ /missing # Generated by "configure" -Makefile .deps/ +Makefile /config.h /config.log
@@ -32,17 +30,23 @@ Makefile /stamp-h1 # Generated by "make" +*.lst +*.i +*.o +*.s + +/doc/*.S.texi /doc/*.c.texi /doc/*.h.texi -/doc/*.S.texi +/doc/kernel +/doc/kernel.lss +/doc/kernel.map +/doc/kernel.sym +/doc/kernel.vsym /doc/multiboot.info* /doc/stamp-vti /doc/version.texi -*.o - -/doc/kernel - # Generated by "make web-manual" /doc/manual/ /doc/multiboot.aux
Makefile.am +2 -0
@@ -1,3 +1,5 @@ +AM_DISTCHECK_CONFIGURE_FLAGS = --enable-example-kernel + # Do not change this order if you don't know what you are doing. AUTOMAKE_OPTIONS = 1.7 gnu SUBDIRS = doc
configure.ac +35 -20
85 lines not on this page · raw message
doc/.gitignore +2 -0
@@ -1,2 +1,4 @@ +# gnulib-tool insists on having these ignore patterns in this file. +# We keep all other ignore patterns in the top-level .gitignore file. /gendocs_template /gendocs_template_min
doc/Makefile.am +35 -5
@@ -1,5 +1,6 @@ +CLEANFILES = info_TEXINFOS = multiboot.texi -EXAMPLES = boot_i386.S boot_mips.S kernel.c multiboot2.h +arch_sources = boot_i386.S boot_mips.S multiboot_TEXINFOS = boot_i386.S.texi boot_mips.S.texi kernel.c.texi multiboot2.h.texi SRC2TEXI = src2texi noinst_SCRIPTS = $(SRC2TEXI)
@@ -9,18 +10,47 @@ pkginclude_HEADERS = multiboot2.h # The example kernel is built if you specify --enable-example-kernel. if BUILD_EXAMPLE_KERNEL noinst_PROGRAMS = kernel +endif + kernel_SOURCES = boot_$(kernel_boot_arch).S kernel.c multiboot2.h kernel_CCASFLAGS = $(kernel_ccasflags) kernel_CFLAGS = $(kernel_cflags) -fno-builtin -nostdinc -O -g -Wall \ -imacros $(top_builddir)/config.h kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none -boot.o: multiboot2.h -endif +CLEANFILES += kernel.map +kernel_LDFLAGS += -Wl,-Map,kernel.map + +CLEANFILES += *.lst +kernel_CCASFLAGS += -Wa,-adhlns=$(@:.o=.lst) +kernel_CFLAGS += -Wa,-adhlns=$(@:.o=.lst) + +CLEANFILES += *.i *.s +kernel_CCASFLAGS += -save-temps=obj +kernel_CFLAGS += -save-temps=obj EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \ - $(EXAMPLES) $(multiboot_TEXINFOS) -CLEANFILES = $(noinst_PROGRAMS) + $(arch_sources) $(multiboot_TEXINFOS) + +noinst_DATA = + +CLEANFILES += kernel.lss +noinst_DATA += kernel.lss +kernel.lss: kernel$(EXEEXT) + $(OBJDUMP) -h -S kernel$(EXEEXT) > kernel.lss.new + mv -f kernel.lss.new kernel.lss + +CLEANFILES += kernel.sym +noinst_DATA += kernel.sym +kernel.sym: kernel$(EXEEXT) + $(NM) -n kernel$(EXEEXT) | $(SORT_U) > kernel.sym.new + mv -f kernel.sym.new kernel.sym + +CLEANFILES += kernel.vsym +noinst_DATA += kernel.vsym +kernel.vsym: kernel$(EXEEXT) + $(OBJDUMP) --syms kernel$(EXEEXT) | $(GREP) '^[0-9a-f]\{4,16\} ' | $(SORT_U) > kernel.vsym.new + mv -f kernel.vsym.new kernel.vsym # Cancel the rule %.texi -> %. This rule may confuse make to determine # the dependecies.
doc/boot_i386.S +12 -17
@@ -15,7 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define ASM_FILE 1 #include <multiboot2.h> /* C symbol format. HAVE_ASM_USCORE is defined by configure. */
@@ -28,13 +27,6 @@ /* The size of our stack (16KB). */ #define STACK_SIZE 0x4000 -/* The flags for the Multiboot header. */ -#ifdef __ELF__ -# define AOUT_KLUDGE 0 -#else -# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE -#endif - .text .globl start, _start
@@ -43,9 +35,9 @@ _start: jmp multiboot_entry /* Align 64 bits boundary. */ - .align 8 + .balign 8 - /* Multiboot header. */ + /* Multiboot2 header. */ multiboot_header: /* magic */ .long MULTIBOOT2_HEADER_MAGIC
@@ -56,7 +48,7 @@ multiboot_header: /* checksum */ .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header)) #ifndef __ELF__ - .align 8 + .balign 8 address_tag_start: .short MULTIBOOT_HEADER_TAG_ADDRESS .short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -70,7 +62,7 @@ address_tag_start: /* bss_end_addr */ .long _end address_tag_end: - .align 8 + .balign 8 entry_address_tag_start: .short MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS .short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -79,7 +71,7 @@ entry_address_tag_start: .long multiboot_entry entry_address_tag_end: #endif /* __ELF__ */ - .align 8 + .balign 8 framebuffer_tag_start: .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER .short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -88,12 +80,13 @@ framebuffer_tag_start: .long 768 .long 32 framebuffer_tag_end: - .align 8 + .balign 8 +terminator_tag_start: .short MULTIBOOT_HEADER_TAG_END .short 0 - .long 8 + .long terminator_tag_end - terminator_tag_start +terminator_tag_end: multiboot_header_end: - multiboot_entry: /* Initialize the stack pointer. */ movl $(stack + STACK_SIZE), %esp
@@ -102,17 +95,19 @@ multiboot_entry: pushl $0 popf - /* Push the pointer to the Multiboot information structure. */ + /* Push the pointer to the Multiboot2 information structure. */ pushl %ebx /* Push the magic value. */ pushl %eax /* Now enter the C main function... */ call EXT_C(cmain) + addl $8, %esp /* Halt. */ pushl $halt_message call EXT_C(printf) + addl $4, %esp loop: hlt jmp loop
doc/boot_mips.S +10 -16
@@ -15,7 +15,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define ASM_FILE 1 #include <multiboot2.h> /* C symbol format. HAVE_ASM_USCORE is defined by configure. */
@@ -28,27 +27,21 @@ /* The size of our stack (16KB). */ #define STACK_SIZE 0x4000 -/* The flags for the Multiboot header. */ -#ifdef __ELF__ -# define AOUT_KLUDGE 0 -#else -# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE -#endif - .text .set noreorder .set nomacro - .globl start, _start + .globl start, _start, __start start: _start: +__start: b multiboot_entry nop /* Align 64 bits boundary. */ .balign 8 - - /* Multiboot header. */ + + /* Multiboot2 header. */ multiboot_header: /* magic */ .long MULTIBOOT2_HEADER_MAGIC
@@ -60,7 +53,7 @@ multiboot_header: .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_MIPS32 + (multiboot_header_end - multiboot_header)) #ifndef __ELF__ .balign 8 -address_tag_start: +address_tag_start: .short MULTIBOOT_HEADER_TAG_ADDRESS .short MULTIBOOT_HEADER_TAG_OPTIONAL .long address_tag_end - address_tag_start
@@ -74,7 +67,7 @@ address_tag_start: .long _end address_tag_end: .balign 8 -entry_address_tag_start: +entry_address_tag_start: .short MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS .short MULTIBOOT_HEADER_TAG_OPTIONAL .long entry_address_tag_end - entry_address_tag_start
@@ -83,7 +76,7 @@ entry_address_tag_start: entry_address_tag_end: #endif /* __ELF__ */ .balign 8 -framebuffer_tag_start: +framebuffer_tag_start: .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER .short MULTIBOOT_HEADER_TAG_OPTIONAL .long framebuffer_tag_end - framebuffer_tag_start
@@ -92,11 +85,12 @@ framebuffer_tag_start: .long 32 framebuffer_tag_end: .balign 8 +terminator_tag_start: .short MULTIBOOT_HEADER_TAG_END .short 0 - .long 8 + .long terminator_tag_end - terminator_tag_start +terminator_tag_end: multiboot_header_end: - multiboot_entry: /* Initialize the stack pointer. */ lui $sp, %hi (stack + STACK_SIZE)
doc/kernel.c +2 -2
@@ -44,7 +44,7 @@ static void itoa (char *buf, int base, int d);static void putchar (int c);void printf (const char *format, ...); -/* Check if MAGIC is valid and print the Multiboot information structure +/* Check if MAGIC is valid and print the Multiboot2 information structure pointed by ADDR. */ void cmain (unsigned long magic,unsigned long addr)
@@ -55,7 +55,7 @@ cmain (unsigned long magic, unsigned long addr)/* Clear the screen. */ cls (); -/* Am I booted by a Multiboot-compliant boot loader? */ +/* Am I booted by a Multiboot2-compliant boot loader? */ if (magic !=MULTIBOOT2_BOOTLOADER_MAGIC ) {printf ("Invalid magic number: 0x%x\n" , (unsigned ) magic);
doc/multiboot.texi +2 -2
@@ -1574,10 +1574,10 @@ macros, such as the magic number for the Multiboot2 header, the Multiboot2 header structure and the Multiboot2 information structure. @menu -* multiboot2.h:: +* multiboot2.h:: * boot_i386.S:: * boot_mips.S:: -* kernel.c:: +* kernel.c:: * Other Multiboot2 kernels:: @end menu
doc/multiboot2.h +11 -6
@@ -32,14 +32,13 @@/* This should be in %eax. */ #define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 -/* Alignment of multiboot modules. */ +/* Alignment of multiboot2 modules. */ #define MULTIBOOT_MOD_ALIGN 0x00001000 -/* Alignment of the multiboot info structure. */ +/* Alignment of the multiboot2 info structure. */ #define MULTIBOOT_INFO_ALIGN 0x00000008 -/* Flags set in the 'flags' member of the multiboot header. */ - +/* Multiboot2 boot information tag types */ #define MULTIBOOT_TAG_ALIGN 8#define MULTIBOOT_TAG_TYPE_END 0#define MULTIBOOT_TAG_TYPE_CMDLINE 1
@@ -64,6 +63,7 @@#define MULTIBOOT_TAG_TYPE_EFI64_IH 20#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 +/* Multiboot2 header tag types */ #define MULTIBOOT_HEADER_TAG_END 0#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1#define MULTIBOOT_HEADER_TAG_ADDRESS 2
@@ -76,18 +76,23 @@#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 +/* values for Multiboot2 header architecture field */ #define MULTIBOOT_ARCHITECTURE_I386 0#define MULTIBOOT_ARCHITECTURE_MIPS32 4 + +/* Flag set in the 'flags' member of the multiboot2 header tag. */ #define MULTIBOOT_HEADER_TAG_OPTIONAL 1 +/* Values for the Multiboot2 relocateable header tag preference field */ #define MULTIBOOT_LOAD_PREFERENCE_NONE 0#define MULTIBOOT_LOAD_PREFERENCE_LOW 1#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 +/* Flags for the Multiboot2 (console) flags tag */ #define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 -#ifndef ASM_FILE +#ifndef __ASSEMBLER__typedef unsigned char multiboot_uint8_t ;typedef unsigned short multiboot_uint16_t ;
@@ -412,6 +417,6 @@ struct multiboot_tag_load_base_addrmultiboot_uint32_t load_base_addr; }; -#endif /* ! ASM_FILE */ +#endif /* ! __ASSEMBLER__ */ #endif /* ! MULTIBOOT_HEADER */
Signature · 1 line
2.26.2