[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] kernel: Assembler-Code von nasm zu as-Code umschreiben



* kernel: Fuer den Assembler-Code nicht mehr nasm sondern as benutzen,
          damit muesste dann auch das Kompilieren unter tyndur klappen,
          und es sieht erst noch besser aus. ;-)

Signed-off-by: Antoine Kaufmann <toni@xxxxxxxxxx>
---
 src/kernel/src/header.S   |   76 +++++++++++++++++++++++
 src/kernel/src/header.asm |   89 ---------------------------
 src/kernel/src/stubs.S    |  147 +++++++++++++++++++++++++++++++++++++++++++++
 src/kernel/src/stubs.asm  |  145 --------------------------------------------
 4 files changed, 223 insertions(+), 234 deletions(-)
 create mode 100644 src/kernel/src/header.S
 delete mode 100644 src/kernel/src/header.asm
 create mode 100644 src/kernel/src/stubs.S
 delete mode 100644 src/kernel/src/stubs.asm

diff --git a/src/kernel/src/header.S b/src/kernel/src/header.S
new file mode 100644
index 0000000..b1b4b83
--- /dev/null
+++ b/src/kernel/src/header.S
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2006 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Kevin Wolf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the tyndur Project
+ *     and its contributors.
+ * 4. Neither the name of the tyndur Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Initialisiert esp und ruft main() auf
+
+.extern init
+.globl _start
+
+.section .text
+_start:
+    // Stack initalisieren
+    lea kernelstack, %esp
+
+    // Damit die Stack Traces hier enden ein Stack Frame mit Nullwerten fuer die
+    // Ruecksprungadresse und den alten Stack Frame erstellen
+    pushl $0
+    pushl $0
+    movl %esp, %ebp
+
+    // Die vom Multiboot Loader übergebenen Informationen auf den Stack legen
+    // (init benötigt sie)
+    pushl %ebx
+    pushl %eax
+
+    call init
+
+    cli
+    hlt
+
+
+multiboot_header:
+.align 4
+    .set MULTIBOOT_MAGIC,   	0x1BADB002
+    .set MULTIBOOT_FLAGS,   	0x03
+    .set MULTIBOOT_CHECKSUM,	(-MULTIBOOT_MAGIC-MULTIBOOT_FLAGS)
+
+    .int MULTIBOOT_MAGIC
+    .int MULTIBOOT_FLAGS
+    .int MULTIBOOT_CHECKSUM
+
+
+.section .bss
+  .space  16384
+kernelstack:
diff --git a/src/kernel/src/header.asm b/src/kernel/src/header.asm
deleted file mode 100644
index 760e0c1..0000000
--- a/src/kernel/src/header.asm
+++ /dev/null
@@ -1,89 +0,0 @@
-;
-; Copyright (c) 2006 The tyndur Project. All rights reserved.
-;
-; This code is derived from software contributed to the tyndur Project
-; by Kevin Wolf.
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-; 1. Redistributions of source code must retain the above copyright
-;    notice, this list of conditions and the following disclaimer.
-; 2. Redistributions in binary form must reproduce the above copyright
-;    notice, this list of conditions and the following disclaimer in the
-;    documentation and/or other materials provided with the distribution.
-; 3. All advertising materials mentioning features or use of this software
-;    must display the following acknowledgement:
-;     This product includes software developed by the tyndur Project
-;     and its contributors.
-; 4. Neither the name of the tyndur Project nor the names of its
-;    contributors may be used to endorse or promote products derived
-;    from this software without specific prior written permission.
-;
-; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-;
-
-; Initialisiert esp und ruft main() auf
-;
-; Aenderungen:
-;
-; 2006-04-09: taljeth
-;   + Erste Version erstellt
-;
-; 2006-04-09: Golum
-;   + Uebergabe der von GRUB bereitgestellten Informationen
-;
-; 2006-04-13: nore
-;   ! falsch gesetztes "kernelstack" Label an die richtige Stelle gesetzt
-;
-; 2006-07-12: Jidder
-;   ! via Paging (statt Segmentation) den Kernel nach 0xc0000000 mappen
-;   ! das log wird mir zu lang, deswegen hab ich mein Zeug mal zensiert ;)
-;
-
-extern init
-global _start
-
-section .text
-_start:
-
-	; Stack initalisieren
-	mov esp, kernelstack
-
-	; Damit die Stack Traces hier enden ein Stack Frame mit Nullwerten für die Rücksprungadresse und den alten Stack Frame erstellen
-	push 0
-	push 0
-	mov ebp, esp
-
-	; Die vom Multiboot Loader übergebenen Informationen auf den Stack legen (init benötigt sie)
-	push ebx
-	push eax
-
-	mov eax, init
-	call eax
-	cli
-	hlt
-
-multiboot_header:
-align 4
-  MULTIBOOT_MAGIC     equ 0x1BADB002
-  MULTIBOOT_FLAGS     equ 0x03
-  MULTIBOOT_CHECKSUM  equ -MULTIBOOT_MAGIC-MULTIBOOT_FLAGS
-
-  dd MULTIBOOT_MAGIC
-  dd MULTIBOOT_FLAGS
-  dd MULTIBOOT_CHECKSUM
-
-section .bss
-  resb  16384
-kernelstack:
diff --git a/src/kernel/src/stubs.S b/src/kernel/src/stubs.S
new file mode 100644
index 0000000..e4470f8
--- /dev/null
+++ b/src/kernel/src/stubs.S
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2006 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Burkhard Weseloh.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the tyndur Project
+ *     and its contributors.
+ * 4. Neither the name of the tyndur Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.section .text
+
+.set IRQ_BASE,0x20
+
+.extern handle_int
+
+.macro exception_stub nr
+.globl exception_stub_\nr
+exception_stub_\nr:
+    pushl $0
+    pushl $\nr
+    jmp int_bottom
+.endm
+
+.macro exception_stub_error_code nr
+.globl exception_stub_\nr
+exception_stub_\nr:
+    pushl $\nr
+    jmp int_bottom
+.endm
+
+.macro irq_stub nr
+.globl irq_stub_\nr
+irq_stub_\nr:
+    pushl $0
+    pushl $(\nr + IRQ_BASE)
+    jmp int_bottom
+.endm
+
+.globl null_handler
+null_handler:
+    pushl $0
+    pushl $0x1337
+    jmp int_bottom
+
+.globl syscall_stub
+syscall_stub:
+    pushl $0
+    pushl $0x30
+    jmp int_bottom
+
+exception_stub 0
+exception_stub 1
+exception_stub 2
+exception_stub 3
+exception_stub 4
+exception_stub 5
+exception_stub 6
+exception_stub 7
+exception_stub_error_code 8
+exception_stub 9
+exception_stub_error_code 10
+exception_stub_error_code 11
+exception_stub_error_code 12
+exception_stub_error_code 13
+exception_stub_error_code 14
+exception_stub 16
+exception_stub_error_code 17
+exception_stub 18
+exception_stub 19
+
+irq_stub 0
+irq_stub 1
+irq_stub 2
+irq_stub 3
+irq_stub 4
+irq_stub 5
+irq_stub 6
+irq_stub 7
+irq_stub 8
+irq_stub 9
+irq_stub 10
+irq_stub 11
+irq_stub 12
+irq_stub 13
+irq_stub 14
+irq_stub 15
+
+int_bottom:
+    // register sichern
+    pusha
+    pushl %ds
+    pushl %es
+    pushl %fs
+    pushl %gs
+
+    // ring 0 segment register laden
+    cld
+    movw $0x10, %ax
+    movw %ax, %ds
+    movw %ax, %es
+
+    // c-handler aufrufen
+    pushl %esp
+    call handle_int
+    addl $4, %esp
+
+
+    // den stack wechseln
+    movl %eax, %esp
+
+    // register laden
+    popl %gs
+    popl %fs
+    popl %es
+    popl %ds
+    popa
+
+    // fehlercode und interrupt nummer ueberspringen
+    addl $8, %esp
+    iret
+
diff --git a/src/kernel/src/stubs.asm b/src/kernel/src/stubs.asm
deleted file mode 100644
index 681baee..0000000
--- a/src/kernel/src/stubs.asm
+++ /dev/null
@@ -1,145 +0,0 @@
-;
-; Copyright (c) 2006 The tyndur Project. All rights reserved.
-;
-; This code is derived from software contributed to the tyndur Project
-; by Burkhard Weseloh.
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-; 1. Redistributions of source code must retain the above copyright
-;    notice, this list of conditions and the following disclaimer.
-; 2. Redistributions in binary form must reproduce the above copyright
-;    notice, this list of conditions and the following disclaimer in the
-;    documentation and/or other materials provided with the distribution.
-; 3. All advertising materials mentioning features or use of this software
-;    must display the following acknowledgement:
-;     This product includes software developed by the tyndur Project
-;     and its contributors.
-; 4. Neither the name of the tyndur Project nor the names of its
-;    contributors may be used to endorse or promote products derived
-;    from this software without specific prior written permission.
-;
-; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-; PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-;
-
-section .text
-
-%define IRQ_BASE 0x20
-
-extern handle_int
-
-%macro exception_stub 1
-global exception_stub_%1
-exception_stub_%1:
-	push dword 0
-	push dword %1
-	jmp int_bottom
-%endmacro
-
-%macro exception_stub_error_code 1
-global exception_stub_%1
-exception_stub_%1:
-	push dword %1
-	jmp int_bottom
-%endmacro
-
-%macro irq_stub 1
-global irq_stub_%1
-irq_stub_%1:
-	push dword 0
-	push dword %1 + IRQ_BASE
-	jmp int_bottom
-%endmacro
-
-global null_handler
-null_handler:
-	push dword 0
-	push dword 0x1337
-	jmp int_bottom
-
-global syscall_stub
-syscall_stub:
-  push dword 0
-  push dword 0x30
-	jmp int_bottom
-
-exception_stub 0
-exception_stub 1
-exception_stub 2
-exception_stub 3
-exception_stub 4
-exception_stub 5
-exception_stub 6
-exception_stub 7
-exception_stub_error_code 8
-exception_stub 9
-exception_stub_error_code 10
-exception_stub_error_code 11
-exception_stub_error_code 12
-exception_stub_error_code 13
-exception_stub_error_code 14
-exception_stub 16
-exception_stub_error_code 17
-exception_stub 18
-exception_stub 19
-
-irq_stub 0
-irq_stub 1
-irq_stub 2
-irq_stub 3
-irq_stub 4
-irq_stub 5
-irq_stub 6
-irq_stub 7
-irq_stub 8
-irq_stub 9
-irq_stub 10
-irq_stub 11
-irq_stub 12
-irq_stub 13
-irq_stub 14
-irq_stub 15
-
-int_bottom:
-	; register sichern
-	pusha
-	push ds
-	push es
-	push fs
-	push gs
-
-	; ring 0 segment register laden
-	cld
-	mov ax, 0x10
-	mov ds, ax
-	mov es, ax
-
-	; c-handler aufrufen
-	push esp
-	call handle_int
-	add esp, 4
-
-	; den stack wechseln
-	mov esp, eax
-	
-	; register laden
-	pop gs
-	pop fs
-	pop es
-	pop ds
-	popa
-
-	add esp, 8 ; fehlercode und interrupt nummer überspringen
-
-	iret
-- 
1.6.0.6