[affinityos commit] r6 - in trunk: . kernel

0 views
Skip to first unread message

codesite...@google.com

unread,
Jul 30, 2006, 8:25:08 AM7/30/06
to affini...@googlegroups.com
Author: ownthebox.net
Date: Sun Jul 30 05:23:54 2006
New Revision: 6

Modified:
trunk/Makefile.common
trunk/kernel/start.asm
trunk/link.ld

Log:
Converted to elf32 format.

Modified: trunk/Makefile.common
==============================================================================
--- trunk/Makefile.common (original)
+++ trunk/Makefile.common Sun Jul 30 05:23:54 2006
@@ -30,14 +30,14 @@

ALL_OBJS = $(OBJECTS)

-CC = gcc
+CC = i386-elf-gcc
NASM = nasm
-LD = ld
-AR = ar
+LD = i386-elf-ld
+AR = i386-elf-ar

%.o : %.asm
@echo " [$(NASM)] Assembling $(SRC_PATH)/$(<)..."
- @$(NASM) -f aout $(<) -o $(@)
+ @$(NASM) -f elf $(<) -o $(@)

%.o : %.c
@echo " [$(CC)] Compiling $(SRC_PATH)/$(<)..."

Modified: trunk/kernel/start.asm
==============================================================================
--- trunk/kernel/start.asm (original)
+++ trunk/kernel/start.asm Sun Jul 30 05:23:54 2006
@@ -8,32 +8,24 @@
mov esp, _sys_stack
jmp stublet

-; This part MUST be 4byte aligned, solved using 'ALIGN 4'.
-ALIGN 4
-
mboot:
+ ; Setting up the multiboot header.
+ MULTIBOOT_PAGE_ALIGN equ 1 << 0
+ MULTIBOOT_MEMORY_INFO equ 1 << 1
+ MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
+ MULTIBOOT_HEADER_MAGIC equ 0x1badb002
+ MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

- MULTIBOOT_PAGE_ALIGN equ 1<<0
- MULTIBOOT_MEMORY_INFO equ 1<<1
- MULTIBOOT_AOUT_KLUDGE equ 1<<16
- MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
- MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
- MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
- EXTERN code, bss, end
-
- ; This is the GRUB multiboot header.
- dd MULTIBOOT_HEADER_MAGIC
- dd MULTIBOOT_HEADER_FLAGS
- dd MULTIBOOT_CHECKSUM
-
- ; AOUT kludge - must be physical addresses.
- ; The linker script fills in the data for these ones!.
- dd mboot
- dd code
- dd bss
- dd end
- dd start
+section .text

+; This part MUST be 4byte aligned, solved using 'ALIGN 4'.
+align 4
+
+; This is the GRUB multiboot header.
+dd MULTIBOOT_HEADER_MAGIC
+dd MULTIBOOT_HEADER_FLAGS
+dd MULTIBOOT_CHECKSUM
+
; Endless loop.
stublet:
; Push the multiboot magic number onto the stack.
@@ -45,10 +37,11 @@
call kernel_main
jmp $

-; This will set up new segment registers. We need to do something special in order to
-; set CS. We do what is called a far jump. A jump that includes a segment as well
-; as an offset. This is declared in C as 'extern void gdt_flush(void);'.
-;
+; This will set up new segment registers. It needs to do something special in
+; order to set CS. We do what is called a far jump. A jump that includes a
+; segment as well as an offset. This is declared in C
+; as 'extern void gdt_flush(void);'.
+
; Allows the C code to link to this.
global gdt_flush

@@ -530,9 +523,9 @@
add esp, 8
iret

-; Here is the definition of our BSS section. Right now, we'll use it just to store the
-; stack. Remember that a stack actually grows downwards, so we declare the size of the
-; data before declaring the identifier '_sys_stack'
+; Here is the definition of the bss section. Right now, we'll use it just to store
+; the stack. Remember that a stack actually grows downwards, so we declare the
+; size of the data before declaring the identifier '_sys_stack'
SECTION .bss
- resb 16384
+ resb 0x4000
_sys_stack:

Modified: trunk/link.ld
==============================================================================
--- trunk/link.ld (original)
+++ trunk/link.ld Sun Jul 30 05:23:54 2006
@@ -1,25 +1,29 @@
-OUTPUT_FORMAT("binary")
+OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
-phys = 0x00100000;
SECTIONS
{
- .text phys : AT(phys) {
- code = .;
- *(.text)
- *(.rodata*)
- . = ALIGN(4096);
- }
- .data : AT(phys + (data - code))
- {
- data = .;
- *(.data)
- . = ALIGN(4096);
- }
- .bss : AT(phys + (bss - code))
- {
- bss = .;
- *(.bss)
- . = ALIGN(4096);
- }
- end = .;
-}
+ . = 0x00100000;
+
+ .text :
+ {
+ *(.text)
+ }
+
+ .rodata ALIGN (0x1000) :
+ {
+ *(.rodata)
+ }
+
+ .data ALIGN (0x1000) :
+ {
+ *(.data)
+ }
+
+ .bss :
+ {
+ _sbss = .;
+ *(COMMON)
+ *(.bss)
+ _ebss = .;
+ }
+}
\ No newline at end of file

Reply all
Reply to author
Forward
0 new messages