From a914c37365967afaf3148293a857c36af6f94ecb Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Fri, 21 Jan 2022 21:44:28 +0100 Subject: Separating assembly, moving #defines to .h & cleaning Makefile --- src/as/boot.s | 30 +----------------------------- src/as/crti.s | 16 ---------------- src/as/crtn.s | 10 ---------- src/as/gdt.s | 6 ++++++ src/as/idt.s | 7 +++++++ src/as/ioport.s | 13 +++++++++++++ 6 files changed, 27 insertions(+), 55 deletions(-) delete mode 100644 src/as/crti.s delete mode 100644 src/as/crtn.s create mode 100644 src/as/gdt.s create mode 100644 src/as/idt.s create mode 100644 src/as/ioport.s (limited to 'src/as') diff --git a/src/as/boot.s b/src/as/boot.s index 907cd3c..f65cc72 100644 --- a/src/as/boot.s +++ b/src/as/boot.s @@ -10,35 +10,6 @@ .long FLAGS .long CHECKSUM -.global _start -.global load_gdt -.global load_idt -.global enable_interrupts -.global ioport_in -.global ioport_out - -load_gdt: - movl 4(%esp), %edx - lgdt (%edx) - ret - -load_idt: - movl 4(%esp), %edx - lidt (%edx) - sti - ret - -ioport_in: - movl 4(%esp),%edx - in %dx,%al - ret - -ioport_out: - movl 4(%esp),%edx - movl 8(%esp),%eax - outb %al,%dx - ret - .set CODE_SEGMENT, 0x08 .set DATA_SEGMENT, 0x10 @@ -49,6 +20,7 @@ stack_bottom: stack_top: .section .text +.global _start .type _start, @function _start: call init_gdt_table diff --git a/src/as/crti.s b/src/as/crti.s deleted file mode 100644 index 5894e2d..0000000 --- a/src/as/crti.s +++ /dev/null @@ -1,16 +0,0 @@ -/* x86 crti.s */ -.section .init -.global _init -.type _init, @function -_init: - push %ebp - movl %esp, %ebp - /* gcc will nicely put the contents of crtbegin.o's .init section here. */ - -.section .fini -.global _fini -.type _fini, @function -_fini: - push %ebp - movl %esp, %ebp - /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ diff --git a/src/as/crtn.s b/src/as/crtn.s deleted file mode 100644 index 0e1c314..0000000 --- a/src/as/crtn.s +++ /dev/null @@ -1,10 +0,0 @@ -/* x86 crtn.s */ -.section .init - /* gcc will nicely put the contents of crtend.o's .init section here. */ - popl %ebp - ret - -.section .fini - /* gcc will nicely put the contents of crtend.o's .fini section here. */ - popl %ebp - ret diff --git a/src/as/gdt.s b/src/as/gdt.s new file mode 100644 index 0000000..632bd3e --- /dev/null +++ b/src/as/gdt.s @@ -0,0 +1,6 @@ +.global load_gdt + +load_gdt: + movl 4(%esp), %edx + lgdt (%edx) + ret diff --git a/src/as/idt.s b/src/as/idt.s new file mode 100644 index 0000000..e95b42b --- /dev/null +++ b/src/as/idt.s @@ -0,0 +1,7 @@ +.global load_idt + +load_idt: + movl 4(%esp), %edx + lidt (%edx) + sti + ret diff --git a/src/as/ioport.s b/src/as/ioport.s new file mode 100644 index 0000000..f4b4dbd --- /dev/null +++ b/src/as/ioport.s @@ -0,0 +1,13 @@ +.global ioport_in +.global ioport_out + +ioport_in: + movl 4(%esp),%edx + in %dx,%al + ret + +ioport_out: + movl 4(%esp),%edx + movl 8(%esp),%eax + outb %al,%dx + ret -- cgit v1.2.3