From d1ba80702c70b2baafe8f2b3743838b76902c9af Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 15 Jan 2022 15:42:13 +0500 Subject: [PATCH] Remove hang functions --- README.md | 39 +++++++++----------- examples/bootloader-multiboot2-grub/main.c | 2 +- examples/bootloader-multiboot2-limine/main.c | 2 +- include/kernaux/asm/i386.h | 2 - include/kernaux/asm/x86_64.h | 2 - src/asm/i386.S | 6 --- src/asm/x86_64.S | 7 ---- 7 files changed, 19 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 9ddf3f7..51c2de4 100644 --- a/README.md +++ b/README.md @@ -191,33 +191,28 @@ src/asm/i386.o: file format elf32-i386 Disassembly of section .text: -00000000 : - 0: fa cli - 1: f4 hlt - 2: eb fc jmp 0 +00000000 : + 0: 0f 20 c0 mov %cr0,%eax + 3: c3 ret -00000004 : - 4: 0f 20 c0 mov %cr0,%eax +00000004 : + 4: 0f 20 e0 mov %cr4,%eax 7: c3 ret -00000008 : - 8: 0f 20 e0 mov %cr4,%eax - b: c3 ret +00000008 : + 8: 8b 44 24 04 mov 0x4(%esp),%eax + c: 0f 22 c0 mov %eax,%cr0 + f: c3 ret -0000000c : - c: 8b 44 24 04 mov 0x4(%esp),%eax - 10: 0f 22 c0 mov %eax,%cr0 - 13: c3 ret +00000010 : + 10: 8b 44 24 04 mov 0x4(%esp),%eax + 14: 0f 22 d8 mov %eax,%cr3 + 17: c3 ret -00000014 : - 14: 8b 44 24 04 mov 0x4(%esp),%eax - 18: 0f 22 d8 mov %eax,%cr3 - 1b: c3 ret - -0000001c : - 1c: 8b 44 24 04 mov 0x4(%esp),%eax - 20: 0f 22 e0 mov %eax,%cr4 - 23: c3 ret +00000018 : + 18: 8b 44 24 04 mov 0x4(%esp),%eax + 1c: 0f 22 e0 mov %eax,%cr4 + 1f: c3 ret ``` diff --git a/examples/bootloader-multiboot2-grub/main.c b/examples/bootloader-multiboot2-grub/main.c index 2d8d903..a8d2656 100644 --- a/examples/bootloader-multiboot2-grub/main.c +++ b/examples/bootloader-multiboot2-grub/main.c @@ -46,5 +46,5 @@ void poweroff() void panic(const char *const str) { kernaux_console_printf("panic: %s\n", str); - kernaux_asm_i386_hang(); + poweroff(); } diff --git a/examples/bootloader-multiboot2-limine/main.c b/examples/bootloader-multiboot2-limine/main.c index 2d8d903..a8d2656 100644 --- a/examples/bootloader-multiboot2-limine/main.c +++ b/examples/bootloader-multiboot2-limine/main.c @@ -46,5 +46,5 @@ void poweroff() void panic(const char *const str) { kernaux_console_printf("panic: %s\n", str); - kernaux_asm_i386_hang(); + poweroff(); } diff --git a/include/kernaux/asm/i386.h b/include/kernaux/asm/i386.h index 48c9b86..5656df9 100644 --- a/include/kernaux/asm/i386.h +++ b/include/kernaux/asm/i386.h @@ -7,8 +7,6 @@ extern "C" { #include -void kernaux_asm_i386_hang() __attribute__((noreturn)); - inline static uint8_t kernaux_asm_i386_inportb(uint16_t port); inline static uint16_t kernaux_asm_i386_inportw(uint16_t port); inline static uint32_t kernaux_asm_i386_inportd(uint16_t port); diff --git a/include/kernaux/asm/x86_64.h b/include/kernaux/asm/x86_64.h index 187cdec..3afc908 100644 --- a/include/kernaux/asm/x86_64.h +++ b/include/kernaux/asm/x86_64.h @@ -7,8 +7,6 @@ extern "C" { #include -void kernaux_asm_x86_64_hang() __attribute__((noreturn)); - inline static uint8_t kernaux_asm_x86_64_inportb(uint16_t port); inline static uint16_t kernaux_asm_x86_64_inportw(uint16_t port); inline static uint32_t kernaux_asm_x86_64_inportd(uint16_t port); diff --git a/src/asm/i386.S b/src/asm/i386.S index f6cb51e..ea61c91 100644 --- a/src/asm/i386.S +++ b/src/asm/i386.S @@ -2,18 +2,12 @@ #include "config.h" #endif -.global kernaux_asm_i386_hang .global kernaux_asm_i386_read_cr0 .global kernaux_asm_i386_read_cr4 .global kernaux_asm_i386_write_cr0 .global kernaux_asm_i386_write_cr3 .global kernaux_asm_i386_write_cr4 -kernaux_asm_i386_hang: - cli - hlt - jmp kernaux_asm_i386_hang - kernaux_asm_i386_read_cr0: mov %cr0, %eax ret diff --git a/src/asm/x86_64.S b/src/asm/x86_64.S index a5d1f5c..c7cde56 100644 --- a/src/asm/x86_64.S +++ b/src/asm/x86_64.S @@ -1,10 +1,3 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif - -.global kernaux_asm_x86_64_hang - -kernaux_asm_x86_64_hang: - cli - hlt - jmp kernaux_asm_x86_64_hang