mirror of
https://github.com/tailix/libkernaux.git
synced 2024-10-30 11:54:01 -04:00
Improve build system (#153)
This commit is contained in:
parent
a1262ac64d
commit
6ec080ddfa
19 changed files with 740 additions and 731 deletions
73
.gitignore
vendored
73
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
/build/*
|
||||
!/build/.keep
|
||||
|
||||
##########################
|
||||
# Common generated files #
|
||||
##########################
|
||||
|
@ -38,8 +41,6 @@
|
|||
/m4/*
|
||||
!/m4/.keep
|
||||
|
||||
# Custom
|
||||
|
||||
/Makefile.in
|
||||
/examples/Makefile.in
|
||||
/fixtures/Makefile.in
|
||||
|
@ -58,7 +59,6 @@
|
|||
/libtool
|
||||
/stamp-h1
|
||||
|
||||
# Temporary
|
||||
/confcache
|
||||
/confdefs.h
|
||||
/confinc.mk
|
||||
|
@ -74,8 +74,6 @@
|
|||
/tests/test_*.log
|
||||
/tests/test_*.trs
|
||||
|
||||
# Custom
|
||||
|
||||
/Makefile
|
||||
/examples/Makefile
|
||||
/fixtures/Makefile
|
||||
|
@ -83,68 +81,3 @@
|
|||
/libc/Makefile
|
||||
/libc/include/Makefile
|
||||
/tests/Makefile
|
||||
|
||||
/include/kernaux/version.h
|
||||
|
||||
/fixtures/multiboot2_bin_examples_gen
|
||||
/fixtures/multiboot2_bin_examples_gen.c
|
||||
/fixtures/multiboot2_header_example0.bin
|
||||
/fixtures/multiboot2_header_example1.bin
|
||||
/fixtures/multiboot2_header_example2.bin
|
||||
/fixtures/multiboot2_info_example0.bin
|
||||
/fixtures/multiboot2_info_example1.bin
|
||||
/fixtures/multiboot2_info_example2.bin
|
||||
|
||||
/examples/assert
|
||||
/examples/cmdline
|
||||
/examples/generic_display
|
||||
/examples/generic_malloc
|
||||
/examples/generic_mutex
|
||||
/examples/macro_bits
|
||||
/examples/macro_cast
|
||||
/examples/macro_container_of
|
||||
/examples/macro_packing
|
||||
/examples/macro_static_test
|
||||
/examples/memmap
|
||||
/examples/multiboot2_header_macro
|
||||
/examples/ntoa
|
||||
/examples/panic
|
||||
/examples/pfa
|
||||
/examples/printf_file
|
||||
/examples/printf_file_va
|
||||
/examples/printf_fmt
|
||||
/examples/printf_str
|
||||
/examples/printf_str_va
|
||||
/examples/units_human
|
||||
|
||||
/tests/multiboot2_header_print0
|
||||
/tests/multiboot2_header_print1
|
||||
/tests/multiboot2_header_print2
|
||||
/tests/multiboot2_info_print0
|
||||
/tests/multiboot2_info_print1
|
||||
/tests/multiboot2_info_print2
|
||||
/tests/test_arch_i386
|
||||
/tests/test_cmdline
|
||||
/tests/test_cmdline_gen
|
||||
/tests/test_cmdline_gen.c
|
||||
/tests/test_elf
|
||||
/tests/test_free_list
|
||||
/tests/test_mbr
|
||||
/tests/test_memmap
|
||||
/tests/test_multiboot2_common_packing
|
||||
/tests/test_multiboot2_header_helpers
|
||||
/tests/test_multiboot2_header_print
|
||||
/tests/test_multiboot2_header_validation
|
||||
/tests/test_multiboot2_info_helpers
|
||||
/tests/test_multiboot2_info_print
|
||||
/tests/test_multiboot2_info_validation
|
||||
/tests/test_ntoa
|
||||
/tests/test_ntoa_assert
|
||||
/tests/test_pfa
|
||||
/tests/test_pfa_assert
|
||||
/tests/test_printf
|
||||
/tests/test_printf_fmt_gen
|
||||
/tests/test_printf_fmt_gen.c
|
||||
/tests/test_printf_gen
|
||||
/tests/test_printf_gen.c
|
||||
/tests/test_units_human
|
||||
|
|
0
build/.keep
Normal file
0
build/.keep
Normal file
|
@ -33,6 +33,8 @@ AC_CONFIG_FILES([
|
|||
libc/include/Makefile
|
||||
include/kernaux/version.h
|
||||
tests/Makefile
|
||||
tests/test_multiboot2_header_print.c
|
||||
tests/test_multiboot2_info_print.c
|
||||
])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.16 subdir-objects])
|
||||
|
|
21
examples/.gitignore
vendored
Normal file
21
examples/.gitignore
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
/assert
|
||||
/cmdline
|
||||
/generic_display
|
||||
/generic_malloc
|
||||
/generic_mutex
|
||||
/macro_bits
|
||||
/macro_cast
|
||||
/macro_container_of
|
||||
/macro_packing
|
||||
/macro_static_test
|
||||
/memmap
|
||||
/multiboot2_header_macro
|
||||
/ntoa
|
||||
/panic
|
||||
/pfa
|
||||
/printf_file
|
||||
/printf_file_va
|
||||
/printf_fmt
|
||||
/printf_str
|
||||
/printf_str_va
|
||||
/units_human
|
8
fixtures/.gitignore
vendored
Normal file
8
fixtures/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/multiboot2_bin_examples_gen
|
||||
/multiboot2_bin_examples_gen.c
|
||||
/multiboot2_header_example0.bin
|
||||
/multiboot2_header_example1.bin
|
||||
/multiboot2_header_example2.bin
|
||||
/multiboot2_info_example0.bin
|
||||
/multiboot2_info_example1.bin
|
||||
/multiboot2_info_example2.bin
|
|
@ -3,6 +3,14 @@ include $(top_srcdir)/make/shared.am
|
|||
noinst_PROGRAMS =
|
||||
nodist_noinst_DATA =
|
||||
|
||||
EXTRA_DIST = \
|
||||
multiboot2_header_example0.txt \
|
||||
multiboot2_header_example1.txt \
|
||||
multiboot2_header_example2.txt \
|
||||
multiboot2_info_example0.txt \
|
||||
multiboot2_info_example1.txt \
|
||||
multiboot2_info_example2.txt
|
||||
|
||||
#########################################
|
||||
# multiboot2_(header|info)_example*.bin #
|
||||
#########################################
|
||||
|
|
11
fixtures/multiboot2_header_example0.txt
Normal file
11
fixtures/multiboot2_header_example0.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
Multiboot 2 header {
|
||||
u32 magic: 0xe85250d6
|
||||
u32 arch: 0 (i386)
|
||||
u32 size: 24
|
||||
u32 checksum: 0x17adaf12
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 0 (none)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 8
|
||||
}
|
52
fixtures/multiboot2_header_example1.txt
Normal file
52
fixtures/multiboot2_header_example1.txt
Normal file
|
@ -0,0 +1,52 @@
|
|||
Multiboot 2 header {
|
||||
u32 magic: 0xe85250d6
|
||||
u32 arch: 4 (MIPS32)
|
||||
u32 size: 104
|
||||
u32 checksum: 0x17adaebe
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 4 (flags)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 console_flags: 0x0 ()
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 4 (flags)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 console_flags: 0x1 (
|
||||
REQUIRE_CONSOLE
|
||||
)
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 4 (flags)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 console_flags: 0x2 (
|
||||
EGA_SUPPORT
|
||||
)
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 4 (flags)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 console_flags: 0x3 (
|
||||
REQUIRE_CONSOLE |
|
||||
EGA_SUPPORT
|
||||
)
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 1 (information request)
|
||||
u16 flags: 0x1 (
|
||||
OPTIONAL
|
||||
)
|
||||
u32 size: 12
|
||||
u32 mbi_tag_types[]: [
|
||||
0 (none)
|
||||
]
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 0 (none)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 8
|
||||
}
|
100
fixtures/multiboot2_header_example2.txt
Normal file
100
fixtures/multiboot2_header_example2.txt
Normal file
|
@ -0,0 +1,100 @@
|
|||
Multiboot 2 header {
|
||||
u32 magic: 0xe85250d6
|
||||
u32 arch: 0 (i386)
|
||||
u32 size: 272
|
||||
u32 checksum: 0x17adae1a
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 1 (information request)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 96
|
||||
u32 mbi_tag_types[]: [
|
||||
0 (none)
|
||||
1 (boot cmd line)
|
||||
2 (boot loader name)
|
||||
3 (module)
|
||||
4 (basic memory info)
|
||||
5 (BIOS boot device)
|
||||
6 (memory map)
|
||||
7 (VBE info)
|
||||
8 (framebuffer info)
|
||||
9 (ELF symbols)
|
||||
10 (APM table)
|
||||
11 (EFI 32bit system table ptr)
|
||||
12 (EFI 64bit system table ptr)
|
||||
13 (SMBIOS tables)
|
||||
14 (ACPI old RSDP)
|
||||
15 (ACPI new RSDP)
|
||||
16 (networking info)
|
||||
17 (EFI memory map)
|
||||
18 (EFI boot services not terminated)
|
||||
19 (EFI 32bit image handle ptr)
|
||||
20 (EFI 64bit image handle ptr)
|
||||
21 (image load base phys addr)
|
||||
]
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 2 (address)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 24
|
||||
u32 header_addr: 0xcafebabe
|
||||
u32 load_addr: 0xdeadbeaf
|
||||
u32 load_end_addr: 0xdeadbabe
|
||||
u32 bss_end_addr: 0xcafebeaf
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 3 (entry address)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 entry_addr: 0xcafebabe
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 4 (flags)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 console_flags: 0x0 ()
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 5 (framebuffer)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 20
|
||||
u32 width: 80
|
||||
u32 height: 25
|
||||
u32 depth: 8
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 6 (module alignment)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 8
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 7 (EFI boot services)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 8
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 8 (EFI i386 entry address)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 entry_addr: 0xcafebabe
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 9 (EFI amd64 entry address)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 12
|
||||
u32 entry_addr: 0xdeadbeaf
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 10 (relocatable header)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 24
|
||||
u32 min_addr: 0xcafebabe
|
||||
u32 max_addr: 0xdeadbeaf
|
||||
u32 align: 8
|
||||
u32 preference: 1 (lowest)
|
||||
}
|
||||
Multiboot 2 header tag {
|
||||
u16 type: 0 (none)
|
||||
u16 flags: 0x0 ()
|
||||
u32 size: 8
|
||||
}
|
8
fixtures/multiboot2_info_example0.txt
Normal file
8
fixtures/multiboot2_info_example0.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
Multiboot 2 info {
|
||||
u32 size: 16
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 0 (none)
|
||||
u32 size: 8
|
||||
}
|
129
fixtures/multiboot2_info_example1.txt
Normal file
129
fixtures/multiboot2_info_example1.txt
Normal file
|
@ -0,0 +1,129 @@
|
|||
Multiboot 2 info {
|
||||
u32 size: 864
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 21 (image load base phys addr)
|
||||
u32 size: 12
|
||||
u32 load_base_addr: 0x400000
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 1 (boot cmd line)
|
||||
u32 size: 21
|
||||
char cmdline[]: "hello kernel"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 2 (boot loader name)
|
||||
u32 size: 30
|
||||
char name[]: "GRUB 2.02-2ubuntu8.20"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 10 (APM table)
|
||||
u32 size: 28
|
||||
u16 version: 258
|
||||
u16 cseg: 61440
|
||||
u32 offset: 54479
|
||||
u16 cseg_16: 61440
|
||||
u16 dseg: 61440
|
||||
u16 flags: 3
|
||||
u16 cseg_len: 65520
|
||||
u16 cseg_16_len: 65520
|
||||
u16 dseg_len: 65520
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 3 (module)
|
||||
u32 size: 29
|
||||
u32 mod_start: 0x102000
|
||||
u32 mod_end: 0x10329c
|
||||
char cmdline[]: "hello module"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 3 (module)
|
||||
u32 size: 17
|
||||
u32 mod_start: 0x104000
|
||||
u32 mod_end: 0x105254
|
||||
char cmdline[]: ""
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 6 (memory map)
|
||||
u32 size: 160
|
||||
u32 entry_size: 24
|
||||
u32 entry_version: 0
|
||||
varies(entry_size) entries[]: [
|
||||
[0] entry: {
|
||||
u64 base_addr: 0x0
|
||||
u64 length: 654336
|
||||
u32 type: 1
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[1] entry: {
|
||||
u64 base_addr: 0x9fc00
|
||||
u64 length: 1024
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[2] entry: {
|
||||
u64 base_addr: 0xf0000
|
||||
u64 length: 65536
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[3] entry: {
|
||||
u64 base_addr: 0x100000
|
||||
u64 length: 133038080
|
||||
u32 type: 1
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[4] entry: {
|
||||
u64 base_addr: 0x7fe0000
|
||||
u64 length: 131072
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[5] entry: {
|
||||
u64 base_addr: 0xfffc0000
|
||||
u64 length: 262144
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
]
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 9 (ELF symbols)
|
||||
u32 size: 420
|
||||
u32 num: 10
|
||||
u32 entsize: 40
|
||||
u32 shndx: 9
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 4 (basic memory info)
|
||||
u32 size: 16
|
||||
u32 mem_lower: 639
|
||||
u32 mem_upper: 129920
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 5 (BIOS boot device)
|
||||
u32 size: 20
|
||||
u32 biosdev: 224
|
||||
u32 partition: 4294967295
|
||||
u32 sub_partition: 4294967295
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 8 (framebuffer info)
|
||||
u32 size: 32
|
||||
u64 framebuffer_addr: 0xb8000
|
||||
u32 framebuffer_pitch: 160
|
||||
u32 framebuffer_width: 80
|
||||
u32 framebuffer_height: 25
|
||||
u8 framebuffer_bpp: 16
|
||||
u8 framebuffer_type: 2
|
||||
u16 reserved: 0x0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 14 (ACPI old RSDP)
|
||||
u32 size: 28
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 0 (none)
|
||||
u32 size: 8
|
||||
}
|
234
fixtures/multiboot2_info_example2.txt
Normal file
234
fixtures/multiboot2_info_example2.txt
Normal file
|
@ -0,0 +1,234 @@
|
|||
Multiboot 2 info {
|
||||
u32 size: 1816
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 1 (boot cmd line)
|
||||
u32 size: 23
|
||||
char cmdline[]: "Hello, Kernel!"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 2 (boot loader name)
|
||||
u32 size: 30
|
||||
char name[]: "GRUB 2.02-2ubuntu8.20"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 3 (module)
|
||||
u32 size: 33
|
||||
u32 mod_start: 0x7b
|
||||
u32 mod_end: 0x1c8
|
||||
char cmdline[]: "Hello, Module 1!"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 3 (module)
|
||||
u32 size: 33
|
||||
u32 mod_start: 0x7b
|
||||
u32 mod_end: 0x1c8
|
||||
char cmdline[]: "Hello, Module 2!"
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 4 (basic memory info)
|
||||
u32 size: 16
|
||||
u32 mem_lower: 123
|
||||
u32 mem_upper: 456
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 5 (BIOS boot device)
|
||||
u32 size: 20
|
||||
u32 biosdev: 0
|
||||
u32 partition: 1
|
||||
u32 sub_partition: 2
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 6 (memory map)
|
||||
u32 size: 160
|
||||
u32 entry_size: 24
|
||||
u32 entry_version: 0
|
||||
varies(entry_size) entries[]: [
|
||||
[0] entry: {
|
||||
u64 base_addr: 0x0
|
||||
u64 length: 654336
|
||||
u32 type: 1
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[1] entry: {
|
||||
u64 base_addr: 0x9fc00
|
||||
u64 length: 1024
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[2] entry: {
|
||||
u64 base_addr: 0xf0000
|
||||
u64 length: 65536
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[3] entry: {
|
||||
u64 base_addr: 0x100000
|
||||
u64 length: 133038080
|
||||
u32 type: 1
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[4] entry: {
|
||||
u64 base_addr: 0x7fe0000
|
||||
u64 length: 131072
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
[5] entry: {
|
||||
u64 base_addr: 0xfffc0000
|
||||
u64 length: 262144
|
||||
u32 type: 2
|
||||
u32 reserved: 0x0
|
||||
}
|
||||
]
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 7 (VBE info)
|
||||
u32 size: 784
|
||||
u16 vbe_mode: 0
|
||||
u16 vbe_interface_seg: 123
|
||||
u16 vbe_interface_off: 456
|
||||
u16 vbe_interface_len: 789
|
||||
u8 vbe_control_info[]: [
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 123
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
]
|
||||
u8 vbe_mode_info[]: [
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
]
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 8 (framebuffer info)
|
||||
u32 size: 40
|
||||
u64 framebuffer_addr: 0x7b
|
||||
u32 framebuffer_pitch: 456
|
||||
u32 framebuffer_width: 123
|
||||
u32 framebuffer_height: 456
|
||||
u8 framebuffer_bpp: 8
|
||||
u8 framebuffer_type: 1
|
||||
u16 reserved: 0x0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 9 (ELF symbols)
|
||||
u32 size: 420
|
||||
u32 num: 10
|
||||
u32 entsize: 40
|
||||
u32 shndx: 9
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 10 (APM table)
|
||||
u32 size: 28
|
||||
u16 version: 0
|
||||
u16 cseg: 123
|
||||
u32 offset: 456
|
||||
u16 cseg_16: 789
|
||||
u16 dseg: 123
|
||||
u16 flags: 1
|
||||
u16 cseg_len: 456
|
||||
u16 cseg_16_len: 789
|
||||
u16 dseg_len: 123
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 11 (EFI 32bit system table ptr)
|
||||
u32 size: 12
|
||||
u32 pointer: 0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 12 (EFI 64bit system table ptr)
|
||||
u32 size: 16
|
||||
u64 pointer: 0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 13 (SMBIOS tables)
|
||||
u32 size: 24
|
||||
u8 major: 1
|
||||
u8 minor: 2
|
||||
u8 reserved[6]: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 14 (ACPI old RSDP)
|
||||
u32 size: 16
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 15 (ACPI new RSDP)
|
||||
u32 size: 16
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 16 (networking info)
|
||||
u32 size: 16
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 17 (EFI memory map)
|
||||
u32 size: 24
|
||||
u32 descriptor_size: 123
|
||||
u32 descriptor_version: 1
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 18 (EFI boot services not terminated)
|
||||
u32 size: 8
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 19 (EFI 32bit image handle ptr)
|
||||
u32 size: 12
|
||||
u32 pointer: 0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 20 (EFI 64bit image handle ptr)
|
||||
u32 size: 16
|
||||
u64 pointer: 0
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 21 (image load base phys addr)
|
||||
u32 size: 12
|
||||
u32 load_base_addr: 0x7b
|
||||
}
|
||||
Multiboot 2 info tag {
|
||||
u32 type: 0 (none)
|
||||
u32 size: 8
|
||||
}
|
1
include/.gitignore
vendored
Normal file
1
include/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/kernaux/version.h
|
33
tests/.gitignore
vendored
Normal file
33
tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/multiboot2_header_print0
|
||||
/multiboot2_header_print1
|
||||
/multiboot2_header_print2
|
||||
/multiboot2_info_print0
|
||||
/multiboot2_info_print1
|
||||
/multiboot2_info_print2
|
||||
/test_arch_i386
|
||||
/test_cmdline
|
||||
/test_cmdline_gen
|
||||
/test_cmdline_gen.c
|
||||
/test_elf
|
||||
/test_free_list
|
||||
/test_mbr
|
||||
/test_memmap
|
||||
/test_multiboot2_common_packing
|
||||
/test_multiboot2_header_helpers
|
||||
/test_multiboot2_header_print
|
||||
/test_multiboot2_header_print.c
|
||||
/test_multiboot2_header_validation
|
||||
/test_multiboot2_info_helpers
|
||||
/test_multiboot2_info_print
|
||||
/test_multiboot2_info_print.c
|
||||
/test_multiboot2_info_validation
|
||||
/test_ntoa
|
||||
/test_ntoa_assert
|
||||
/test_pfa
|
||||
/test_pfa_assert
|
||||
/test_printf
|
||||
/test_printf_fmt_gen
|
||||
/test_printf_fmt_gen.c
|
||||
/test_printf_gen
|
||||
/test_printf_gen.c
|
||||
/test_units_human
|
|
@ -217,7 +217,10 @@ TESTS += test_multiboot2_header_print
|
|||
test_multiboot2_header_print_DEPENDENCIES = \
|
||||
multiboot2_header_print0 \
|
||||
multiboot2_header_print1 \
|
||||
multiboot2_header_print2
|
||||
multiboot2_header_print2 \
|
||||
../fixtures/multiboot2_header_example0.txt \
|
||||
../fixtures/multiboot2_header_example1.txt \
|
||||
../fixtures/multiboot2_header_example2.txt
|
||||
test_multiboot2_header_print_LDADD = $(top_builddir)/libkernaux.la
|
||||
test_multiboot2_header_print_SOURCES = \
|
||||
main.c \
|
||||
|
@ -261,7 +264,10 @@ TESTS += test_multiboot2_info_print
|
|||
test_multiboot2_info_print_DEPENDENCIES = \
|
||||
multiboot2_info_print0 \
|
||||
multiboot2_info_print1 \
|
||||
multiboot2_info_print2
|
||||
multiboot2_info_print2 \
|
||||
../fixtures/multiboot2_info_example0.txt \
|
||||
../fixtures/multiboot2_info_example1.txt \
|
||||
../fixtures/multiboot2_info_example2.txt
|
||||
test_multiboot2_info_print_LDADD = $(top_builddir)/libkernaux.la
|
||||
test_multiboot2_info_print_SOURCES = \
|
||||
main.c \
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef __USE_POSIX2
|
||||
#define __USE_POSIX2
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
static const char output0[] =
|
||||
"Multiboot 2 header {\n"
|
||||
" u32 magic: 0xe85250d6\n"
|
||||
" u32 arch: 0 (i386)\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 checksum: 0x17adaf12\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 0 (none)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
static const char output1[] =
|
||||
"Multiboot 2 header {\n"
|
||||
" u32 magic: 0xe85250d6\n"
|
||||
" u32 arch: 4 (MIPS32)\n"
|
||||
" u32 size: 104\n"
|
||||
" u32 checksum: 0x17adaebe\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x0 ()\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x1 (\n"
|
||||
" REQUIRE_CONSOLE\n"
|
||||
" )\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x2 (\n"
|
||||
" EGA_SUPPORT\n"
|
||||
" )\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x3 (\n"
|
||||
" REQUIRE_CONSOLE |\n"
|
||||
" EGA_SUPPORT\n"
|
||||
" )\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 1 (information request)\n"
|
||||
" u16 flags: 0x1 (\n"
|
||||
" OPTIONAL\n"
|
||||
" )\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 mbi_tag_types[]: [\n"
|
||||
" 0 (none)\n"
|
||||
" ]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 0 (none)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
static const char output2[] =
|
||||
"Multiboot 2 header {\n"
|
||||
" u32 magic: 0xe85250d6\n"
|
||||
" u32 arch: 0 (i386)\n"
|
||||
" u32 size: 272\n"
|
||||
" u32 checksum: 0x17adae1a\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 1 (information request)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 96\n"
|
||||
" u32 mbi_tag_types[]: [\n"
|
||||
" 0 (none)\n"
|
||||
" 1 (boot cmd line)\n"
|
||||
" 2 (boot loader name)\n"
|
||||
" 3 (module)\n"
|
||||
" 4 (basic memory info)\n"
|
||||
" 5 (BIOS boot device)\n"
|
||||
" 6 (memory map)\n"
|
||||
" 7 (VBE info)\n"
|
||||
" 8 (framebuffer info)\n"
|
||||
" 9 (ELF symbols)\n"
|
||||
" 10 (APM table)\n"
|
||||
" 11 (EFI 32bit system table ptr)\n"
|
||||
" 12 (EFI 64bit system table ptr)\n"
|
||||
" 13 (SMBIOS tables)\n"
|
||||
" 14 (ACPI old RSDP)\n"
|
||||
" 15 (ACPI new RSDP)\n"
|
||||
" 16 (networking info)\n"
|
||||
" 17 (EFI memory map)\n"
|
||||
" 18 (EFI boot services not terminated)\n"
|
||||
" 19 (EFI 32bit image handle ptr)\n"
|
||||
" 20 (EFI 64bit image handle ptr)\n"
|
||||
" 21 (image load base phys addr)\n"
|
||||
" ]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 2 (address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 header_addr: 0xcafebabe\n"
|
||||
" u32 load_addr: 0xdeadbeaf\n"
|
||||
" u32 load_end_addr: 0xdeadbabe\n"
|
||||
" u32 bss_end_addr: 0xcafebeaf\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 3 (entry address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 entry_addr: 0xcafebabe\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 4 (flags)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 console_flags: 0x0 ()\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 5 (framebuffer)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 20\n"
|
||||
" u32 width: 80\n"
|
||||
" u32 height: 25\n"
|
||||
" u32 depth: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 6 (module alignment)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 7 (EFI boot services)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 8 (EFI i386 entry address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 entry_addr: 0xcafebabe\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 9 (EFI amd64 entry address)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 entry_addr: 0xdeadbeaf\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 10 (relocatable header)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 min_addr: 0xcafebabe\n"
|
||||
" u32 max_addr: 0xdeadbeaf\n"
|
||||
" u32 align: 8\n"
|
||||
" u32 preference: 1 (lowest)\n"
|
||||
"}\n"
|
||||
"Multiboot 2 header tag {\n"
|
||||
" u16 type: 0 (none)\n"
|
||||
" u16 flags: 0x0 ()\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
void test_main()
|
||||
{
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_header_print0", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output0; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_header_print1", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output1; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_header_print2", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output2; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
}
|
61
tests/test_multiboot2_header_print.c.in
Normal file
61
tests/test_multiboot2_header_print.c.in
Normal file
|
@ -0,0 +1,61 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef __USE_POSIX2
|
||||
#define __USE_POSIX2
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
void test_main()
|
||||
{
|
||||
{
|
||||
FILE *const print_file =
|
||||
popen("@abs_top_builddir@/tests/multiboot2_header_print0", "r");
|
||||
FILE *const text_file =
|
||||
fopen("@abs_top_srcdir@/fixtures/multiboot2_header_example0.txt", "r");
|
||||
assert(print_file != NULL);
|
||||
assert(text_file != NULL);
|
||||
|
||||
while (!feof(text_file)) {
|
||||
assert(fgetc(print_file) == fgetc(text_file));
|
||||
}
|
||||
|
||||
assert(pclose(print_file) == 0);
|
||||
assert(fclose(text_file) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const print_file =
|
||||
popen("@abs_top_builddir@/tests/multiboot2_header_print1", "r");
|
||||
FILE *const text_file =
|
||||
fopen("@abs_top_srcdir@/fixtures/multiboot2_header_example1.txt", "r");
|
||||
assert(print_file != NULL);
|
||||
assert(text_file != NULL);
|
||||
|
||||
while (!feof(text_file)) {
|
||||
assert(fgetc(print_file) == fgetc(text_file));
|
||||
}
|
||||
|
||||
assert(pclose(print_file) == 0);
|
||||
assert(fclose(text_file) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const print_file =
|
||||
popen("@abs_top_builddir@/tests/multiboot2_header_print2", "r");
|
||||
FILE *const text_file =
|
||||
fopen("@abs_top_srcdir@/fixtures/multiboot2_header_example2.txt", "r");
|
||||
assert(print_file != NULL);
|
||||
assert(text_file != NULL);
|
||||
|
||||
while (!feof(text_file)) {
|
||||
assert(fgetc(print_file) == fgetc(text_file));
|
||||
}
|
||||
|
||||
assert(pclose(print_file) == 0);
|
||||
assert(fclose(text_file) == 0);
|
||||
}
|
||||
}
|
|
@ -1,441 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __USE_POSIX2
|
||||
#define __USE_POSIX2
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
static const char output0[] =
|
||||
"Multiboot 2 info {\n"
|
||||
" u32 size: 16\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 0 (none)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
static const char output1[] =
|
||||
"Multiboot 2 info {\n"
|
||||
" u32 size: 864\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 21 (image load base phys addr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 load_base_addr: 0x400000\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 1 (boot cmd line)\n"
|
||||
" u32 size: 21\n"
|
||||
" char cmdline[]: \"hello kernel\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 2 (boot loader name)\n"
|
||||
" u32 size: 30\n"
|
||||
" char name[]: \"GRUB 2.02-2ubuntu8.20\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 10 (APM table)\n"
|
||||
" u32 size: 28\n"
|
||||
" u16 version: 258\n"
|
||||
" u16 cseg: 61440\n"
|
||||
" u32 offset: 54479\n"
|
||||
" u16 cseg_16: 61440\n"
|
||||
" u16 dseg: 61440\n"
|
||||
" u16 flags: 3\n"
|
||||
" u16 cseg_len: 65520\n"
|
||||
" u16 cseg_16_len: 65520\n"
|
||||
" u16 dseg_len: 65520\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 29\n"
|
||||
" u32 mod_start: 0x102000\n"
|
||||
" u32 mod_end: 0x10329c\n"
|
||||
" char cmdline[]: \"hello module\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 17\n"
|
||||
" u32 mod_start: 0x104000\n"
|
||||
" u32 mod_end: 0x105254\n"
|
||||
" char cmdline[]: \"\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 6 (memory map)\n"
|
||||
" u32 size: 160\n"
|
||||
" u32 entry_size: 24\n"
|
||||
" u32 entry_version: 0\n"
|
||||
" varies(entry_size) entries[]: [\n"
|
||||
" [0] entry: {\n"
|
||||
" u64 base_addr: 0x0\n"
|
||||
" u64 length: 654336\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [1] entry: {\n"
|
||||
" u64 base_addr: 0x9fc00\n"
|
||||
" u64 length: 1024\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [2] entry: {\n"
|
||||
" u64 base_addr: 0xf0000\n"
|
||||
" u64 length: 65536\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [3] entry: {\n"
|
||||
" u64 base_addr: 0x100000\n"
|
||||
" u64 length: 133038080\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [4] entry: {\n"
|
||||
" u64 base_addr: 0x7fe0000\n"
|
||||
" u64 length: 131072\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [5] entry: {\n"
|
||||
" u64 base_addr: 0xfffc0000\n"
|
||||
" u64 length: 262144\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" ]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 9 (ELF symbols)\n"
|
||||
" u32 size: 420\n"
|
||||
" u32 num: 10\n"
|
||||
" u32 entsize: 40\n"
|
||||
" u32 shndx: 9\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 4 (basic memory info)\n"
|
||||
" u32 size: 16\n"
|
||||
" u32 mem_lower: 639\n"
|
||||
" u32 mem_upper: 129920\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 5 (BIOS boot device)\n"
|
||||
" u32 size: 20\n"
|
||||
" u32 biosdev: 224\n"
|
||||
" u32 partition: 4294967295\n"
|
||||
" u32 sub_partition: 4294967295\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 8 (framebuffer info)\n"
|
||||
" u32 size: 32\n"
|
||||
" u64 framebuffer_addr: 0xb8000\n"
|
||||
" u32 framebuffer_pitch: 160\n"
|
||||
" u32 framebuffer_width: 80\n"
|
||||
" u32 framebuffer_height: 25\n"
|
||||
" u8 framebuffer_bpp: 16\n"
|
||||
" u8 framebuffer_type: 2\n"
|
||||
" u16 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 14 (ACPI old RSDP)\n"
|
||||
" u32 size: 28\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 0 (none)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
static const char output2_part1[] =
|
||||
"Multiboot 2 info {\n"
|
||||
" u32 size: 1816\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 1 (boot cmd line)\n"
|
||||
" u32 size: 23\n"
|
||||
" char cmdline[]: \"Hello, Kernel!\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 2 (boot loader name)\n"
|
||||
" u32 size: 30\n"
|
||||
" char name[]: \"GRUB 2.02-2ubuntu8.20\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 33\n"
|
||||
" u32 mod_start: 0x7b\n"
|
||||
" u32 mod_end: 0x1c8\n"
|
||||
" char cmdline[]: \"Hello, Module 1!\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 3 (module)\n"
|
||||
" u32 size: 33\n"
|
||||
" u32 mod_start: 0x7b\n"
|
||||
" u32 mod_end: 0x1c8\n"
|
||||
" char cmdline[]: \"Hello, Module 2!\"\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 4 (basic memory info)\n"
|
||||
" u32 size: 16\n"
|
||||
" u32 mem_lower: 123\n"
|
||||
" u32 mem_upper: 456\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 5 (BIOS boot device)\n"
|
||||
" u32 size: 20\n"
|
||||
" u32 biosdev: 0\n"
|
||||
" u32 partition: 1\n"
|
||||
" u32 sub_partition: 2\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 6 (memory map)\n"
|
||||
" u32 size: 160\n"
|
||||
" u32 entry_size: 24\n"
|
||||
" u32 entry_version: 0\n"
|
||||
" varies(entry_size) entries[]: [\n"
|
||||
" [0] entry: {\n"
|
||||
" u64 base_addr: 0x0\n"
|
||||
" u64 length: 654336\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [1] entry: {\n"
|
||||
" u64 base_addr: 0x9fc00\n"
|
||||
" u64 length: 1024\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [2] entry: {\n"
|
||||
" u64 base_addr: 0xf0000\n"
|
||||
" u64 length: 65536\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [3] entry: {\n"
|
||||
" u64 base_addr: 0x100000\n"
|
||||
" u64 length: 133038080\n"
|
||||
" u32 type: 1\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [4] entry: {\n"
|
||||
" u64 base_addr: 0x7fe0000\n"
|
||||
" u64 length: 131072\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" [5] entry: {\n"
|
||||
" u64 base_addr: 0xfffc0000\n"
|
||||
" u64 length: 262144\n"
|
||||
" u32 type: 2\n"
|
||||
" u32 reserved: 0x0\n"
|
||||
" }\n"
|
||||
" ]\n"
|
||||
"}\n";
|
||||
|
||||
static const char output2_part2[] =
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 7 (VBE info)\n"
|
||||
" u32 size: 784\n"
|
||||
" u16 vbe_mode: 0\n"
|
||||
" u16 vbe_interface_seg: 123\n"
|
||||
" u16 vbe_interface_off: 456\n"
|
||||
" u16 vbe_interface_len: 789\n"
|
||||
" u8 vbe_control_info[]: [\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 123\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" ]\n"
|
||||
" u8 vbe_mode_info[]: [\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255\n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
||||
" ]\n"
|
||||
"}\n";
|
||||
|
||||
static const char output2_part3[] =
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 8 (framebuffer info)\n"
|
||||
" u32 size: 40\n"
|
||||
" u64 framebuffer_addr: 0x7b\n"
|
||||
" u32 framebuffer_pitch: 456\n"
|
||||
" u32 framebuffer_width: 123\n"
|
||||
" u32 framebuffer_height: 456\n"
|
||||
" u8 framebuffer_bpp: 8\n"
|
||||
" u8 framebuffer_type: 1\n"
|
||||
" u16 reserved: 0x0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 9 (ELF symbols)\n"
|
||||
" u32 size: 420\n"
|
||||
" u32 num: 10\n"
|
||||
" u32 entsize: 40\n"
|
||||
" u32 shndx: 9\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 10 (APM table)\n"
|
||||
" u32 size: 28\n"
|
||||
" u16 version: 0\n"
|
||||
" u16 cseg: 123\n"
|
||||
" u32 offset: 456\n"
|
||||
" u16 cseg_16: 789\n"
|
||||
" u16 dseg: 123\n"
|
||||
" u16 flags: 1\n"
|
||||
" u16 cseg_len: 456\n"
|
||||
" u16 cseg_16_len: 789\n"
|
||||
" u16 dseg_len: 123\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 11 (EFI 32bit system table ptr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 12 (EFI 64bit system table ptr)\n"
|
||||
" u32 size: 16\n"
|
||||
" u64 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 13 (SMBIOS tables)\n"
|
||||
" u32 size: 24\n"
|
||||
" u8 major: 1\n"
|
||||
" u8 minor: 2\n"
|
||||
" u8 reserved[6]: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 14 (ACPI old RSDP)\n"
|
||||
" u32 size: 16\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 15 (ACPI new RSDP)\n"
|
||||
" u32 size: 16\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 16 (networking info)\n"
|
||||
" u32 size: 16\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 17 (EFI memory map)\n"
|
||||
" u32 size: 24\n"
|
||||
" u32 descriptor_size: 123\n"
|
||||
" u32 descriptor_version: 1\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 18 (EFI boot services not terminated)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 19 (EFI 32bit image handle ptr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 20 (EFI 64bit image handle ptr)\n"
|
||||
" u32 size: 16\n"
|
||||
" u64 pointer: 0\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 21 (image load base phys addr)\n"
|
||||
" u32 size: 12\n"
|
||||
" u32 load_base_addr: 0x7b\n"
|
||||
"}\n"
|
||||
"Multiboot 2 info tag {\n"
|
||||
" u32 type: 0 (none)\n"
|
||||
" u32 size: 8\n"
|
||||
"}\n";
|
||||
|
||||
void test_main()
|
||||
{
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_info_print0", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output0; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const fd = popen("./multiboot2_info_print1", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output1; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
{
|
||||
const size_t part1_len = strlen(output2_part1);
|
||||
const size_t part2_len = strlen(output2_part2);
|
||||
const size_t part3_len = strlen(output2_part3);
|
||||
char *const output2 = malloc(1 + part1_len + part2_len + part3_len);
|
||||
assert(output2);
|
||||
strcpy(output2, output2_part1);
|
||||
strcat(output2, output2_part2);
|
||||
strcat(output2, output2_part3);
|
||||
|
||||
FILE *const fd = popen("./multiboot2_info_print2", "r");
|
||||
assert(fd != NULL);
|
||||
|
||||
for (const char *ch = output2; *ch; ++ch) {
|
||||
assert(fgetc(fd) == *ch);
|
||||
}
|
||||
|
||||
const int status = pclose(fd);
|
||||
assert(status == 0);
|
||||
}
|
||||
}
|
61
tests/test_multiboot2_info_print.c.in
Normal file
61
tests/test_multiboot2_info_print.c.in
Normal file
|
@ -0,0 +1,61 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef __USE_POSIX2
|
||||
#define __USE_POSIX2
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
void test_main()
|
||||
{
|
||||
{
|
||||
FILE *const print_file =
|
||||
popen("@abs_top_builddir@/tests/multiboot2_info_print0", "r");
|
||||
FILE *const text_file =
|
||||
fopen("@abs_top_srcdir@/fixtures/multiboot2_info_example0.txt", "r");
|
||||
assert(print_file != NULL);
|
||||
assert(text_file != NULL);
|
||||
|
||||
while (!feof(text_file)) {
|
||||
assert(fgetc(print_file) == fgetc(text_file));
|
||||
}
|
||||
|
||||
assert(pclose(print_file) == 0);
|
||||
assert(fclose(text_file) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const print_file =
|
||||
popen("@abs_top_builddir@/tests/multiboot2_info_print1", "r");
|
||||
FILE *const text_file =
|
||||
fopen("@abs_top_srcdir@/fixtures/multiboot2_info_example1.txt", "r");
|
||||
assert(print_file != NULL);
|
||||
assert(text_file != NULL);
|
||||
|
||||
while (!feof(text_file)) {
|
||||
assert(fgetc(print_file) == fgetc(text_file));
|
||||
}
|
||||
|
||||
assert(pclose(print_file) == 0);
|
||||
assert(fclose(text_file) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *const print_file =
|
||||
popen("@abs_top_builddir@/tests/multiboot2_info_print2", "r");
|
||||
FILE *const text_file =
|
||||
fopen("@abs_top_srcdir@/fixtures/multiboot2_info_example2.txt", "r");
|
||||
assert(print_file != NULL);
|
||||
assert(text_file != NULL);
|
||||
|
||||
while (!feof(text_file)) {
|
||||
assert(fgetc(print_file) == fgetc(text_file));
|
||||
}
|
||||
|
||||
assert(pclose(print_file) == 0);
|
||||
assert(fclose(text_file) == 0);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue