summaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorRegina König2020-06-23 23:10:28 +0200
committerRegina König2020-06-23 23:10:28 +0200
commit6c2f2d74709ce2183db3976b962e6c366cddfbc5 (patch)
tree50e31f616a91479b5e77bbf7221e58ed8bda95b6 /documentation
parentsome more information (diff)
downloadmemtest86-6c2f2d74709ce2183db3976b962e6c366cddfbc5.tar.gz
memtest86-6c2f2d74709ce2183db3976b962e6c366cddfbc5.tar.xz
memtest86-6c2f2d74709ce2183db3976b962e6c366cddfbc5.zip
some new files
Diffstat (limited to 'documentation')
-rw-r--r--documentation/UEFI general/EDK2.odtbin0 -> 16320 bytes
-rw-r--r--documentation/UEFI general/UEFI Overview20
-rw-r--r--documentation/UEFI general/UEFI Programming with FASM146
-rw-r--r--documentation/UEFI general/qemu_kvm_for_debug26
-rw-r--r--documentation/UEFI_from_spec/Access SMBIOS (renamed from documentation/UEFI/Access SMBIOS)0
-rw-r--r--documentation/UEFI_from_spec/EFI_BOOT_SERVICES (renamed from documentation/UEFI/EFI_BOOT_SERVICES)0
-rw-r--r--documentation/UEFI_from_spec/EFI_CONFIGURATION_TABLE (renamed from documentation/UEFI/EFI_CONFIGURATION_TABLE)0
-rw-r--r--documentation/UEFI_from_spec/EFI_GUID (renamed from documentation/UEFI/EFI_GUID)0
-rw-r--r--documentation/UEFI_from_spec/EFI_IMAGE_ENTRY_POINT (renamed from documentation/UEFI/EFI_IMAGE_ENTRY_POINT)0
-rw-r--r--documentation/UEFI_from_spec/UEFI Shell commands (renamed from documentation/UEFI/UEFI Shell commands)0
10 files changed, 192 insertions, 0 deletions
diff --git a/documentation/UEFI general/EDK2.odt b/documentation/UEFI general/EDK2.odt
new file mode 100644
index 0000000..28484c6
--- /dev/null
+++ b/documentation/UEFI general/EDK2.odt
Binary files differ
diff --git a/documentation/UEFI general/UEFI Overview b/documentation/UEFI general/UEFI Overview
new file mode 100644
index 0000000..f173bfb
--- /dev/null
+++ b/documentation/UEFI general/UEFI Overview
@@ -0,0 +1,20 @@
+Reference: https://wiki.osdev.org/UEFI
+
+
+UEFI VS LEGACY BIOS
+
+Both motherboards come with BIOS ROMs, which contains firmware that performs the initial power-on configuration of the
+system before loading some third-party code into memory and jumping to it.
+Differences:
+ - where they find that code
+ - how to prepare system before jumping to it
+ - what convenience functions they provide for the code to call while running
+
+PLATFORM INITIALIZATION
+
+BIOS: performs all the usual platform initialization (memory controller configuration, PCI bus configuration and BAR mapping,
+ graphics card initialization, etc...) but then drops into a backwards-compatible real mode environment.
+ Bootloader must enable A20 gate, configure a GDT and an IDT, switch to protected mode, and for x86-64 CPUs,
+ configure paging and switch to long mode.
+UEFI firmware: performs those same steps but also prepares a protected mode environment with flat segmentation and for x86-64 CPUs,
+ a long mode environment with identity-mapped paging. The A20 gate is enabled as well.
diff --git a/documentation/UEFI general/UEFI Programming with FASM b/documentation/UEFI general/UEFI Programming with FASM
new file mode 100644
index 0000000..472b757
--- /dev/null
+++ b/documentation/UEFI general/UEFI Programming with FASM
@@ -0,0 +1,146 @@
+UEFI Programming with FASM
+
+As an extra, I will also demonstrate same Hello World example in assembly (using FASM, that currently has experimental UEFI support since version 1.67.28):
+
+First we need some to create simple UEFI headers (efi.inc):
+
+;for 32/64 portability and automatic natural align in structure definitions
+
+struc int8 {
+ . db ?
+}
+struc int16 {
+ align 2
+ . dw ?
+}
+struc int32 {
+ align 4
+ . dd ?
+}
+struc int64 {
+ align 8
+ . dq ?
+}
+struc intn {
+ align 8
+ . dq ?
+}
+struc dptr {
+ align 8
+ . dq ?
+}
+
+;symbols
+
+EFIERR = 0x8000000000000000
+EFI_SUCCESS = 0
+EFI_LOAD_ERROR = EFIERR or 1
+EFI_INVALID_PARAMETER = EFIERR or 2
+EFI_UNSUPPORTED = EFIERR or 3
+EFI_BAD_BUFFER_SIZE = EFIERR or 4
+EFI_BUFFER_TOO_SMALL = EFIERR or 5
+EFI_NOT_READY = EFIERR or 6
+EFI_DEVICE_ERROR = EFIERR or 7
+EFI_WRITE_PROTECTED = EFIERR or 8
+EFI_OUT_OF_RESOURCES = EFIERR or 9
+EFI_VOLUME_CORRUPTED = EFIERR or 10
+EFI_VOLUME_FULL = EFIERR or 11
+EFI_NO_MEDIA = EFIERR or 12
+EFI_MEDIA_CHANGED = EFIERR or 13
+EFI_NOT_FOUND = EFIERR or 14
+EFI_ACCESS_DENIED = EFIERR or 15
+EFI_NO_RESPONSE = EFIERR or 16
+EFI_NO_MAPPING = EFIERR or 17
+EFI_TIMEOUT = EFIERR or 18
+EFI_NOT_STARTED = EFIERR or 19
+EFI_ALREADY_STARTED = EFIERR or 20
+EFI_ABORTED = EFIERR or 21
+EFI_ICMP_ERROR = EFIERR or 22
+EFI_TFTP_ERROR = EFIERR or 23
+EFI_PROTOCOL_ERROR = EFIERR or 24
+
+;helper macro for definition of relative structure member offsets
+
+macro struct name
+{
+ virtual at 0
+ name name
+ end virtual
+}
+
+;structures
+
+struc EFI_TABLE_HEADER {
+ .Signature int64
+ .Revision int32
+ .HeaderSize int32
+ .CRC32 int32
+ .Reserved int32
+}
+struct EFI_TABLE_HEADER
+
+struc EFI_SYSTEM_TABLE {
+ .Hdr EFI_TABLE_HEADER
+ .FirmwareVendor dptr
+ .FirmwareRevision int32
+ .ConsoleInHandle dptr
+ .ConIn dptr
+ .ConsoleOutHandle dptr
+ .ConOut dptr
+ .StandardErrorHandle dptr
+ .StdErr dptr
+ .RuntimeServices dptr
+ .BootServices dptr
+ .NumberOfTableEntries intn
+ .ConfigurationTable dptr
+}
+struct EFI_SYSTEM_TABLE
+
+struc SIMPLE_TEXT_OUTPUT_INTERFACE {
+ .Reset dptr
+ .OutputString dptr
+ .TestString dptr
+ .QueryMode dptr
+ .SetMode dptr
+ .SetAttribute dptr
+ .ClearScreen dptr
+ .SetCursorPosition dptr
+ .EnableCursor dptr
+ .Mode dptr
+}
+struct SIMPLE_TEXT_OUTPUT_INTERFACE
+
+And here is the assembly code itself (hello.asm):
+
+format pe64 dll efi
+entry main
+
+section '.text' code executable readable
+
+include 'efi.inc'
+
+main:
+ sub rsp, 4*8 ; reserve space for 4 arguments
+
+ mov [Handle], rcx ; ImageHandle
+ mov [SystemTable], rdx ; pointer to SystemTable
+
+ lea rdx, [_hello]
+ mov rcx, [SystemTable]
+ mov rcx, [rcx + EFI_SYSTEM_TABLE.ConOut]
+ call [rcx + SIMPLE_TEXT_OUTPUT_INTERFACE.OutputString]
+
+ add rsp, 4*8
+ mov eax, EFI_SUCCESS
+ retn
+
+
+section '.data' data readable writeable
+
+Handle dq ?
+SystemTable dq ?
+_hello du 'Hello World',13,10,'(From EFI app written in FASM)',13,10,0
+
+section '.reloc' fixups data discardable
+
+Compile and link it with fasm.exe hello_world.asm.
diff --git a/documentation/UEFI general/qemu_kvm_for_debug b/documentation/UEFI general/qemu_kvm_for_debug
new file mode 100644
index 0000000..e166637
--- /dev/null
+++ b/documentation/UEFI general/qemu_kvm_for_debug
@@ -0,0 +1,26 @@
+This is how I generally use qemu for debugging:
+
+sudo qemu-system-x86_64 -L . -serial pty -serial pty -monitor stdio \
+ -drive file=/dev/local/virt-ovmf,if=ide,id=drive-ide0-0-0 \
+ -nographic -S
+
+This command:
+
+ Creates two serial ports: one for the OVMF debug output, and one for a usable serial console
+
+ Uses a LVM block device, /dev/local/virt-ovmf as the local storage
+ Disables graphic output
+ Starts the qemu monitor prompt on stdio
+ Tells qemu not to start the machine right away.
+
+I then:
+
+ start two screen sessions on the PTYs that qemu prints
+
+ start it by typing c at the monitor prompt
+
+During boot, I get the OVMF debug output on the first screen session, and once the machine is booted, I get a login prompt on the second screen session. For this to work, you'll need to configure init to create a getty session on the serial ports. To do this from within your virtual machine:
+
+cd /etc/init/
+sed s/tty1/ttyS0 < tty1.conf | sudo dd of=ttyS0.conf
+sed s/tty1/ttyS1 < tty1.conf | sudo dd of=ttyS1.conf
diff --git a/documentation/UEFI/Access SMBIOS b/documentation/UEFI_from_spec/Access SMBIOS
index cd20f5f..cd20f5f 100644
--- a/documentation/UEFI/Access SMBIOS
+++ b/documentation/UEFI_from_spec/Access SMBIOS
diff --git a/documentation/UEFI/EFI_BOOT_SERVICES b/documentation/UEFI_from_spec/EFI_BOOT_SERVICES
index d50840d..d50840d 100644
--- a/documentation/UEFI/EFI_BOOT_SERVICES
+++ b/documentation/UEFI_from_spec/EFI_BOOT_SERVICES
diff --git a/documentation/UEFI/EFI_CONFIGURATION_TABLE b/documentation/UEFI_from_spec/EFI_CONFIGURATION_TABLE
index 949febf..949febf 100644
--- a/documentation/UEFI/EFI_CONFIGURATION_TABLE
+++ b/documentation/UEFI_from_spec/EFI_CONFIGURATION_TABLE
diff --git a/documentation/UEFI/EFI_GUID b/documentation/UEFI_from_spec/EFI_GUID
index 521b083..521b083 100644
--- a/documentation/UEFI/EFI_GUID
+++ b/documentation/UEFI_from_spec/EFI_GUID
diff --git a/documentation/UEFI/EFI_IMAGE_ENTRY_POINT b/documentation/UEFI_from_spec/EFI_IMAGE_ENTRY_POINT
index 4f9044e..4f9044e 100644
--- a/documentation/UEFI/EFI_IMAGE_ENTRY_POINT
+++ b/documentation/UEFI_from_spec/EFI_IMAGE_ENTRY_POINT
diff --git a/documentation/UEFI/UEFI Shell commands b/documentation/UEFI_from_spec/UEFI Shell commands
index d94913f..d94913f 100644
--- a/documentation/UEFI/UEFI Shell commands
+++ b/documentation/UEFI_from_spec/UEFI Shell commands