refactor: striped more arch-related code from the kernel code base
authorMinep <lunaixsky@qq.com>
Sat, 12 Aug 2023 16:37:14 +0000 (17:37 +0100)
committerMinep <lunaixsky@qq.com>
Sat, 12 Aug 2023 16:37:14 +0000 (17:37 +0100)
feat: memory map generation from description file

50 files changed:
lunaix-os/.vscode/c_cpp_properties.json
lunaix-os/arch/i386/boot/boot.S
lunaix-os/arch/i386/boot/hhk.c
lunaix-os/arch/i386/boot/prologue.S [moved from lunaix-os/arch/i386/prologue.S with 97% similarity]
lunaix-os/arch/i386/exceptions/gdt.h [moved from lunaix-os/includes/arch/i386/gdt.h with 100% similarity]
lunaix-os/arch/i386/exceptions/i386_isrdef.c
lunaix-os/arch/i386/exceptions/interrupt.S
lunaix-os/arch/i386/exceptions/interrupts.c
lunaix-os/arch/i386/exceptions/intr_routines.c
lunaix-os/arch/i386/exceptions/intrhnds.S
lunaix-os/arch/i386/gdt.c [moved from lunaix-os/arch/i386/exceptions/gdt.c with 92% similarity]
lunaix-os/arch/i386/hal/cpu.c
lunaix-os/arch/i386/includes/sys/abi.h [moved from lunaix-os/includes/arch/i386/i386_abi.h with 97% similarity]
lunaix-os/arch/i386/includes/sys/boot/multiboot.h [moved from lunaix-os/includes/arch/i386/boot/multiboot.h with 100% similarity]
lunaix-os/arch/i386/includes/sys/interrupt.S.inc [moved from lunaix-os/includes/arch/i386/interrupt.S.inc with 100% similarity]
lunaix-os/arch/i386/includes/sys/interrupts.h [moved from lunaix-os/includes/arch/i386/interrupts.h with 96% similarity]
lunaix-os/arch/i386/includes/sys/mm/mempart.h [new file with mode: 0644]
lunaix-os/arch/i386/includes/sys/vectors.h [moved from lunaix-os/includes/arch/i386/vectors.h with 100% similarity]
lunaix-os/arch/i386/includes/sys/x86_isa.h [new file with mode: 0644]
lunaix-os/arch/i386/pfault.c
lunaix-os/arch/i386/tss.c
lunaix-os/hal/apic.c
lunaix-os/hal/ioapic.c
lunaix-os/includes/arch/abi.h [deleted file]
lunaix-os/includes/arch/exception.h [deleted file]
lunaix-os/includes/arch/i386/i386_asm.h [deleted file]
lunaix-os/includes/arch/i386/idt.h [deleted file]
lunaix-os/includes/arch/i386/tss.h [deleted file]
lunaix-os/includes/hal/acpi/acpi.h
lunaix-os/includes/lunaix/isrm.h
lunaix-os/includes/lunaix/process.h
lunaix-os/includes/lunaix/syscall.h
lunaix-os/includes/sdbg/gdbstub.h
lunaix-os/includes/sdbg/lsdbg.h
lunaix-os/kernel.mk
lunaix-os/kernel/exe/exec.c
lunaix-os/kernel/kinit.c
lunaix-os/kernel/peripheral/ps2kbd.c
lunaix-os/kernel/proc0.c
lunaix-os/kernel/process/process.c
lunaix-os/kernel/process/sched.c
lunaix-os/kernel/spike.c
lunaix-os/kernel/syscall.c
lunaix-os/kernel/time/timer.c
lunaix-os/scripts/expand.py
lunaix-os/scripts/templates/i386/config.json
lunaix-os/scripts/templates/i386/i386_intrhnds.S.j2
lunaix-os/scripts/templates/i386/i386_isrdef.c.j2
lunaix-os/scripts/templates/i386/mappings
lunaix-os/scripts/templates/i386/mempart.h.j2 [new file with mode: 0644]

index f91b0507f97eb1855d756cdfd72730099f83092c..7536e26c8a1c67c519e2cd21390d26019f94c383 100644 (file)
@@ -5,7 +5,8 @@
             "includePath": [
                 "${workspaceFolder}/includes",
                 "${workspaceFolder}/includes/usr",
             "includePath": [
                 "${workspaceFolder}/includes",
                 "${workspaceFolder}/includes/usr",
-                "${workspaceFolder}/usr/includes"
+                "${workspaceFolder}/usr/includes",
+                "${workspaceFolder}/arch/i386/includes",
             ],
             "compilerArgs": [
                 "-ffreestanding",
             ],
             "compilerArgs": [
                 "-ffreestanding",
index 452a9835d7afc75e7b515edae2dc726cd35b760c..0ef3fc645764c50967fb86049130a00597e4bcbe 100644 (file)
@@ -1,5 +1,5 @@
 #define __ASM__ 1
 #define __ASM__ 1
-#include <arch/i386/boot/multiboot.h>
+#include <sys/boot/multiboot.h>
 
 #define MB_FLAGS    (MULTIBOOT_MEMORY_INFO | MULTIBOOT_PAGE_ALIGN)
 #define KPG_SIZE    10*4096
 
 #define MB_FLAGS    (MULTIBOOT_MEMORY_INFO | MULTIBOOT_PAGE_ALIGN)
 #define KPG_SIZE    10*4096
index d97fc9128b7ce28d1c0316ba3ff73117d0f24a3f..0dfe3e2850b27f99755552f6d8365b9cf9ada331 100644 (file)
@@ -1,5 +1,4 @@
-#include <arch/i386/boot/multiboot.h>
-#include <arch/i386/idt.h>
+#include <sys/boot/multiboot.h>
 #include <lunaix/common.h>
 #include <lunaix/mm/page.h>
 
 #include <lunaix/common.h>
 #include <lunaix/mm/page.h>
 
similarity index 97%
rename from lunaix-os/arch/i386/prologue.S
rename to lunaix-os/arch/i386/boot/prologue.S
index 572401b0dc6393d76c66afeff0cb88646de2b9ea..7a516488df05fc882aa74ffdb8dd6e0d1fb6dd62 100644 (file)
@@ -1,7 +1,7 @@
 /* 高半核入口点 - 0xC0000000 */
 
 #define __ASM__
 /* 高半核入口点 - 0xC0000000 */
 
 #define __ASM__
-#include <arch/i386/i386_asm.h>
+#include <sys/x86_isa.h>
 
 .section .text
     .global hhk_entry_
 
 .section .text
     .global hhk_entry_
index f0ca965be0466354ba54c0d609eccf4a6f976176..81a4d34837b16c401e4720c190efdfd9e1e258cf 100644 (file)
@@ -1,3 +1,5 @@
+/* Generated from i386_isrdef.c.j2. Do NOT modify */
+
 #include "i386_intr.h"
 #include <lunaix/types.h>
 
 #include "i386_intr.h"
 #include <lunaix/types.h>
 
 
 #define DECLARE_ISR(iv) extern void _asm_isr##iv();
 
 
 #define DECLARE_ISR(iv) extern void _asm_isr##iv();
 
-#define ISR_INSTALL(idt, iv, isr)                                              \
-    _idt[iv] = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(0, IDT_INTERRUPT);         \
-    _idt[iv] <<= 32;                                                           \
-    _idt[iv] |= (KERNEL_CS << 16) | ((ptr_t)isr & 0x0000ffff);
+#define ISR_INSTALL(idt, iv, isr, dpl)                                   \
+    _idt[iv] = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(dpl, IDT_INTERRUPT); \
+    _idt[iv] <<= 32;                                                     \
+    _idt[iv] |= (KERNEL_CS << 16) | ((ptr_t)isr & 0x0000ffff);           \
 
 u64_t _idt[IDT_ENTRY];
 u16_t _idt_limit = sizeof(_idt) - 1;
 
 u64_t _idt[IDT_ENTRY];
 u16_t _idt_limit = sizeof(_idt) - 1;
@@ -276,260 +278,260 @@ DECLARE_ISR(255)
 void
 exception_install_handler()
 {
 void
 exception_install_handler()
 {
-    ISR_INSTALL(_idt, 0, _asm_isr0)
-    ISR_INSTALL(_idt, 1, _asm_isr1)
-    ISR_INSTALL(_idt, 2, _asm_isr2)
-    ISR_INSTALL(_idt, 3, _asm_isr3)
-    ISR_INSTALL(_idt, 4, _asm_isr4)
-    ISR_INSTALL(_idt, 5, _asm_isr5)
-    ISR_INSTALL(_idt, 6, _asm_isr6)
-    ISR_INSTALL(_idt, 7, _asm_isr7)
-    ISR_INSTALL(_idt, 8, _asm_isr8)
-    ISR_INSTALL(_idt, 9, _asm_isr9)
-    ISR_INSTALL(_idt, 10, _asm_isr10)
-    ISR_INSTALL(_idt, 11, _asm_isr11)
-    ISR_INSTALL(_idt, 12, _asm_isr12)
-    ISR_INSTALL(_idt, 13, _asm_isr13)
-    ISR_INSTALL(_idt, 14, _asm_isr14)
-    ISR_INSTALL(_idt, 15, _asm_isr15)
-    ISR_INSTALL(_idt, 16, _asm_isr16)
-    ISR_INSTALL(_idt, 17, _asm_isr17)
-    ISR_INSTALL(_idt, 18, _asm_isr18)
-    ISR_INSTALL(_idt, 19, _asm_isr19)
-    ISR_INSTALL(_idt, 20, _asm_isr20)
-    ISR_INSTALL(_idt, 21, _asm_isr21)
-    ISR_INSTALL(_idt, 22, _asm_isr22)
-    ISR_INSTALL(_idt, 23, _asm_isr23)
-    ISR_INSTALL(_idt, 24, _asm_isr24)
-    ISR_INSTALL(_idt, 25, _asm_isr25)
-    ISR_INSTALL(_idt, 26, _asm_isr26)
-    ISR_INSTALL(_idt, 27, _asm_isr27)
-    ISR_INSTALL(_idt, 28, _asm_isr28)
-    ISR_INSTALL(_idt, 29, _asm_isr29)
-    ISR_INSTALL(_idt, 30, _asm_isr30)
-    ISR_INSTALL(_idt, 31, _asm_isr31)
-    ISR_INSTALL(_idt, 32, _asm_isr32)
-    ISR_INSTALL(_idt, 33, _asm_isr33)
-    ISR_INSTALL(_idt, 34, _asm_isr34)
-    ISR_INSTALL(_idt, 35, _asm_isr35)
-    ISR_INSTALL(_idt, 36, _asm_isr36)
-    ISR_INSTALL(_idt, 37, _asm_isr37)
-    ISR_INSTALL(_idt, 38, _asm_isr38)
-    ISR_INSTALL(_idt, 39, _asm_isr39)
-    ISR_INSTALL(_idt, 40, _asm_isr40)
-    ISR_INSTALL(_idt, 41, _asm_isr41)
-    ISR_INSTALL(_idt, 42, _asm_isr42)
-    ISR_INSTALL(_idt, 43, _asm_isr43)
-    ISR_INSTALL(_idt, 44, _asm_isr44)
-    ISR_INSTALL(_idt, 45, _asm_isr45)
-    ISR_INSTALL(_idt, 46, _asm_isr46)
-    ISR_INSTALL(_idt, 47, _asm_isr47)
-    ISR_INSTALL(_idt, 48, _asm_isr48)
-    ISR_INSTALL(_idt, 49, _asm_isr49)
-    ISR_INSTALL(_idt, 50, _asm_isr50)
-    ISR_INSTALL(_idt, 51, _asm_isr51)
-    ISR_INSTALL(_idt, 52, _asm_isr52)
-    ISR_INSTALL(_idt, 53, _asm_isr53)
-    ISR_INSTALL(_idt, 54, _asm_isr54)
-    ISR_INSTALL(_idt, 55, _asm_isr55)
-    ISR_INSTALL(_idt, 56, _asm_isr56)
-    ISR_INSTALL(_idt, 57, _asm_isr57)
-    ISR_INSTALL(_idt, 58, _asm_isr58)
-    ISR_INSTALL(_idt, 59, _asm_isr59)
-    ISR_INSTALL(_idt, 60, _asm_isr60)
-    ISR_INSTALL(_idt, 61, _asm_isr61)
-    ISR_INSTALL(_idt, 62, _asm_isr62)
-    ISR_INSTALL(_idt, 63, _asm_isr63)
-    ISR_INSTALL(_idt, 64, _asm_isr64)
-    ISR_INSTALL(_idt, 65, _asm_isr65)
-    ISR_INSTALL(_idt, 66, _asm_isr66)
-    ISR_INSTALL(_idt, 67, _asm_isr67)
-    ISR_INSTALL(_idt, 68, _asm_isr68)
-    ISR_INSTALL(_idt, 69, _asm_isr69)
-    ISR_INSTALL(_idt, 70, _asm_isr70)
-    ISR_INSTALL(_idt, 71, _asm_isr71)
-    ISR_INSTALL(_idt, 72, _asm_isr72)
-    ISR_INSTALL(_idt, 73, _asm_isr73)
-    ISR_INSTALL(_idt, 74, _asm_isr74)
-    ISR_INSTALL(_idt, 75, _asm_isr75)
-    ISR_INSTALL(_idt, 76, _asm_isr76)
-    ISR_INSTALL(_idt, 77, _asm_isr77)
-    ISR_INSTALL(_idt, 78, _asm_isr78)
-    ISR_INSTALL(_idt, 79, _asm_isr79)
-    ISR_INSTALL(_idt, 80, _asm_isr80)
-    ISR_INSTALL(_idt, 81, _asm_isr81)
-    ISR_INSTALL(_idt, 82, _asm_isr82)
-    ISR_INSTALL(_idt, 83, _asm_isr83)
-    ISR_INSTALL(_idt, 84, _asm_isr84)
-    ISR_INSTALL(_idt, 85, _asm_isr85)
-    ISR_INSTALL(_idt, 86, _asm_isr86)
-    ISR_INSTALL(_idt, 87, _asm_isr87)
-    ISR_INSTALL(_idt, 88, _asm_isr88)
-    ISR_INSTALL(_idt, 89, _asm_isr89)
-    ISR_INSTALL(_idt, 90, _asm_isr90)
-    ISR_INSTALL(_idt, 91, _asm_isr91)
-    ISR_INSTALL(_idt, 92, _asm_isr92)
-    ISR_INSTALL(_idt, 93, _asm_isr93)
-    ISR_INSTALL(_idt, 94, _asm_isr94)
-    ISR_INSTALL(_idt, 95, _asm_isr95)
-    ISR_INSTALL(_idt, 96, _asm_isr96)
-    ISR_INSTALL(_idt, 97, _asm_isr97)
-    ISR_INSTALL(_idt, 98, _asm_isr98)
-    ISR_INSTALL(_idt, 99, _asm_isr99)
-    ISR_INSTALL(_idt, 100, _asm_isr100)
-    ISR_INSTALL(_idt, 101, _asm_isr101)
-    ISR_INSTALL(_idt, 102, _asm_isr102)
-    ISR_INSTALL(_idt, 103, _asm_isr103)
-    ISR_INSTALL(_idt, 104, _asm_isr104)
-    ISR_INSTALL(_idt, 105, _asm_isr105)
-    ISR_INSTALL(_idt, 106, _asm_isr106)
-    ISR_INSTALL(_idt, 107, _asm_isr107)
-    ISR_INSTALL(_idt, 108, _asm_isr108)
-    ISR_INSTALL(_idt, 109, _asm_isr109)
-    ISR_INSTALL(_idt, 110, _asm_isr110)
-    ISR_INSTALL(_idt, 111, _asm_isr111)
-    ISR_INSTALL(_idt, 112, _asm_isr112)
-    ISR_INSTALL(_idt, 113, _asm_isr113)
-    ISR_INSTALL(_idt, 114, _asm_isr114)
-    ISR_INSTALL(_idt, 115, _asm_isr115)
-    ISR_INSTALL(_idt, 116, _asm_isr116)
-    ISR_INSTALL(_idt, 117, _asm_isr117)
-    ISR_INSTALL(_idt, 118, _asm_isr118)
-    ISR_INSTALL(_idt, 119, _asm_isr119)
-    ISR_INSTALL(_idt, 120, _asm_isr120)
-    ISR_INSTALL(_idt, 121, _asm_isr121)
-    ISR_INSTALL(_idt, 122, _asm_isr122)
-    ISR_INSTALL(_idt, 123, _asm_isr123)
-    ISR_INSTALL(_idt, 124, _asm_isr124)
-    ISR_INSTALL(_idt, 125, _asm_isr125)
-    ISR_INSTALL(_idt, 126, _asm_isr126)
-    ISR_INSTALL(_idt, 127, _asm_isr127)
-    ISR_INSTALL(_idt, 128, _asm_isr128)
-    ISR_INSTALL(_idt, 129, _asm_isr129)
-    ISR_INSTALL(_idt, 130, _asm_isr130)
-    ISR_INSTALL(_idt, 131, _asm_isr131)
-    ISR_INSTALL(_idt, 132, _asm_isr132)
-    ISR_INSTALL(_idt, 133, _asm_isr133)
-    ISR_INSTALL(_idt, 134, _asm_isr134)
-    ISR_INSTALL(_idt, 135, _asm_isr135)
-    ISR_INSTALL(_idt, 136, _asm_isr136)
-    ISR_INSTALL(_idt, 137, _asm_isr137)
-    ISR_INSTALL(_idt, 138, _asm_isr138)
-    ISR_INSTALL(_idt, 139, _asm_isr139)
-    ISR_INSTALL(_idt, 140, _asm_isr140)
-    ISR_INSTALL(_idt, 141, _asm_isr141)
-    ISR_INSTALL(_idt, 142, _asm_isr142)
-    ISR_INSTALL(_idt, 143, _asm_isr143)
-    ISR_INSTALL(_idt, 144, _asm_isr144)
-    ISR_INSTALL(_idt, 145, _asm_isr145)
-    ISR_INSTALL(_idt, 146, _asm_isr146)
-    ISR_INSTALL(_idt, 147, _asm_isr147)
-    ISR_INSTALL(_idt, 148, _asm_isr148)
-    ISR_INSTALL(_idt, 149, _asm_isr149)
-    ISR_INSTALL(_idt, 150, _asm_isr150)
-    ISR_INSTALL(_idt, 151, _asm_isr151)
-    ISR_INSTALL(_idt, 152, _asm_isr152)
-    ISR_INSTALL(_idt, 153, _asm_isr153)
-    ISR_INSTALL(_idt, 154, _asm_isr154)
-    ISR_INSTALL(_idt, 155, _asm_isr155)
-    ISR_INSTALL(_idt, 156, _asm_isr156)
-    ISR_INSTALL(_idt, 157, _asm_isr157)
-    ISR_INSTALL(_idt, 158, _asm_isr158)
-    ISR_INSTALL(_idt, 159, _asm_isr159)
-    ISR_INSTALL(_idt, 160, _asm_isr160)
-    ISR_INSTALL(_idt, 161, _asm_isr161)
-    ISR_INSTALL(_idt, 162, _asm_isr162)
-    ISR_INSTALL(_idt, 163, _asm_isr163)
-    ISR_INSTALL(_idt, 164, _asm_isr164)
-    ISR_INSTALL(_idt, 165, _asm_isr165)
-    ISR_INSTALL(_idt, 166, _asm_isr166)
-    ISR_INSTALL(_idt, 167, _asm_isr167)
-    ISR_INSTALL(_idt, 168, _asm_isr168)
-    ISR_INSTALL(_idt, 169, _asm_isr169)
-    ISR_INSTALL(_idt, 170, _asm_isr170)
-    ISR_INSTALL(_idt, 171, _asm_isr171)
-    ISR_INSTALL(_idt, 172, _asm_isr172)
-    ISR_INSTALL(_idt, 173, _asm_isr173)
-    ISR_INSTALL(_idt, 174, _asm_isr174)
-    ISR_INSTALL(_idt, 175, _asm_isr175)
-    ISR_INSTALL(_idt, 176, _asm_isr176)
-    ISR_INSTALL(_idt, 177, _asm_isr177)
-    ISR_INSTALL(_idt, 178, _asm_isr178)
-    ISR_INSTALL(_idt, 179, _asm_isr179)
-    ISR_INSTALL(_idt, 180, _asm_isr180)
-    ISR_INSTALL(_idt, 181, _asm_isr181)
-    ISR_INSTALL(_idt, 182, _asm_isr182)
-    ISR_INSTALL(_idt, 183, _asm_isr183)
-    ISR_INSTALL(_idt, 184, _asm_isr184)
-    ISR_INSTALL(_idt, 185, _asm_isr185)
-    ISR_INSTALL(_idt, 186, _asm_isr186)
-    ISR_INSTALL(_idt, 187, _asm_isr187)
-    ISR_INSTALL(_idt, 188, _asm_isr188)
-    ISR_INSTALL(_idt, 189, _asm_isr189)
-    ISR_INSTALL(_idt, 190, _asm_isr190)
-    ISR_INSTALL(_idt, 191, _asm_isr191)
-    ISR_INSTALL(_idt, 192, _asm_isr192)
-    ISR_INSTALL(_idt, 193, _asm_isr193)
-    ISR_INSTALL(_idt, 194, _asm_isr194)
-    ISR_INSTALL(_idt, 195, _asm_isr195)
-    ISR_INSTALL(_idt, 196, _asm_isr196)
-    ISR_INSTALL(_idt, 197, _asm_isr197)
-    ISR_INSTALL(_idt, 198, _asm_isr198)
-    ISR_INSTALL(_idt, 199, _asm_isr199)
-    ISR_INSTALL(_idt, 200, _asm_isr200)
-    ISR_INSTALL(_idt, 201, _asm_isr201)
-    ISR_INSTALL(_idt, 202, _asm_isr202)
-    ISR_INSTALL(_idt, 203, _asm_isr203)
-    ISR_INSTALL(_idt, 204, _asm_isr204)
-    ISR_INSTALL(_idt, 205, _asm_isr205)
-    ISR_INSTALL(_idt, 206, _asm_isr206)
-    ISR_INSTALL(_idt, 207, _asm_isr207)
-    ISR_INSTALL(_idt, 208, _asm_isr208)
-    ISR_INSTALL(_idt, 209, _asm_isr209)
-    ISR_INSTALL(_idt, 210, _asm_isr210)
-    ISR_INSTALL(_idt, 211, _asm_isr211)
-    ISR_INSTALL(_idt, 212, _asm_isr212)
-    ISR_INSTALL(_idt, 213, _asm_isr213)
-    ISR_INSTALL(_idt, 214, _asm_isr214)
-    ISR_INSTALL(_idt, 215, _asm_isr215)
-    ISR_INSTALL(_idt, 216, _asm_isr216)
-    ISR_INSTALL(_idt, 217, _asm_isr217)
-    ISR_INSTALL(_idt, 218, _asm_isr218)
-    ISR_INSTALL(_idt, 219, _asm_isr219)
-    ISR_INSTALL(_idt, 220, _asm_isr220)
-    ISR_INSTALL(_idt, 221, _asm_isr221)
-    ISR_INSTALL(_idt, 222, _asm_isr222)
-    ISR_INSTALL(_idt, 223, _asm_isr223)
-    ISR_INSTALL(_idt, 224, _asm_isr224)
-    ISR_INSTALL(_idt, 225, _asm_isr225)
-    ISR_INSTALL(_idt, 226, _asm_isr226)
-    ISR_INSTALL(_idt, 227, _asm_isr227)
-    ISR_INSTALL(_idt, 228, _asm_isr228)
-    ISR_INSTALL(_idt, 229, _asm_isr229)
-    ISR_INSTALL(_idt, 230, _asm_isr230)
-    ISR_INSTALL(_idt, 231, _asm_isr231)
-    ISR_INSTALL(_idt, 232, _asm_isr232)
-    ISR_INSTALL(_idt, 233, _asm_isr233)
-    ISR_INSTALL(_idt, 234, _asm_isr234)
-    ISR_INSTALL(_idt, 235, _asm_isr235)
-    ISR_INSTALL(_idt, 236, _asm_isr236)
-    ISR_INSTALL(_idt, 237, _asm_isr237)
-    ISR_INSTALL(_idt, 238, _asm_isr238)
-    ISR_INSTALL(_idt, 239, _asm_isr239)
-    ISR_INSTALL(_idt, 240, _asm_isr240)
-    ISR_INSTALL(_idt, 241, _asm_isr241)
-    ISR_INSTALL(_idt, 242, _asm_isr242)
-    ISR_INSTALL(_idt, 243, _asm_isr243)
-    ISR_INSTALL(_idt, 244, _asm_isr244)
-    ISR_INSTALL(_idt, 245, _asm_isr245)
-    ISR_INSTALL(_idt, 246, _asm_isr246)
-    ISR_INSTALL(_idt, 247, _asm_isr247)
-    ISR_INSTALL(_idt, 248, _asm_isr248)
-    ISR_INSTALL(_idt, 249, _asm_isr249)
-    ISR_INSTALL(_idt, 250, _asm_isr250)
-    ISR_INSTALL(_idt, 251, _asm_isr251)
-    ISR_INSTALL(_idt, 252, _asm_isr252)
-    ISR_INSTALL(_idt, 253, _asm_isr253)
-    ISR_INSTALL(_idt, 254, _asm_isr254)
-    ISR_INSTALL(_idt, 255, _asm_isr255)
+    ISR_INSTALL(_idt, 0, _asm_isr0, 0)
+    ISR_INSTALL(_idt, 1, _asm_isr1, 0)
+    ISR_INSTALL(_idt, 2, _asm_isr2, 0)
+    ISR_INSTALL(_idt, 3, _asm_isr3, 0)
+    ISR_INSTALL(_idt, 4, _asm_isr4, 0)
+    ISR_INSTALL(_idt, 5, _asm_isr5, 0)
+    ISR_INSTALL(_idt, 6, _asm_isr6, 0)
+    ISR_INSTALL(_idt, 7, _asm_isr7, 0)
+    ISR_INSTALL(_idt, 8, _asm_isr8, 0)
+    ISR_INSTALL(_idt, 9, _asm_isr9, 0)
+    ISR_INSTALL(_idt, 10, _asm_isr10, 0)
+    ISR_INSTALL(_idt, 11, _asm_isr11, 0)
+    ISR_INSTALL(_idt, 12, _asm_isr12, 0)
+    ISR_INSTALL(_idt, 13, _asm_isr13, 0)
+    ISR_INSTALL(_idt, 14, _asm_isr14, 0)
+    ISR_INSTALL(_idt, 15, _asm_isr15, 0)
+    ISR_INSTALL(_idt, 16, _asm_isr16, 0)
+    ISR_INSTALL(_idt, 17, _asm_isr17, 0)
+    ISR_INSTALL(_idt, 18, _asm_isr18, 0)
+    ISR_INSTALL(_idt, 19, _asm_isr19, 0)
+    ISR_INSTALL(_idt, 20, _asm_isr20, 0)
+    ISR_INSTALL(_idt, 21, _asm_isr21, 0)
+    ISR_INSTALL(_idt, 22, _asm_isr22, 0)
+    ISR_INSTALL(_idt, 23, _asm_isr23, 0)
+    ISR_INSTALL(_idt, 24, _asm_isr24, 0)
+    ISR_INSTALL(_idt, 25, _asm_isr25, 0)
+    ISR_INSTALL(_idt, 26, _asm_isr26, 0)
+    ISR_INSTALL(_idt, 27, _asm_isr27, 0)
+    ISR_INSTALL(_idt, 28, _asm_isr28, 0)
+    ISR_INSTALL(_idt, 29, _asm_isr29, 0)
+    ISR_INSTALL(_idt, 30, _asm_isr30, 0)
+    ISR_INSTALL(_idt, 31, _asm_isr31, 0)
+    ISR_INSTALL(_idt, 32, _asm_isr32, 0)
+    ISR_INSTALL(_idt, 33, _asm_isr33, 3)
+    ISR_INSTALL(_idt, 34, _asm_isr34, 0)
+    ISR_INSTALL(_idt, 35, _asm_isr35, 0)
+    ISR_INSTALL(_idt, 36, _asm_isr36, 0)
+    ISR_INSTALL(_idt, 37, _asm_isr37, 0)
+    ISR_INSTALL(_idt, 38, _asm_isr38, 0)
+    ISR_INSTALL(_idt, 39, _asm_isr39, 0)
+    ISR_INSTALL(_idt, 40, _asm_isr40, 0)
+    ISR_INSTALL(_idt, 41, _asm_isr41, 0)
+    ISR_INSTALL(_idt, 42, _asm_isr42, 0)
+    ISR_INSTALL(_idt, 43, _asm_isr43, 0)
+    ISR_INSTALL(_idt, 44, _asm_isr44, 0)
+    ISR_INSTALL(_idt, 45, _asm_isr45, 0)
+    ISR_INSTALL(_idt, 46, _asm_isr46, 0)
+    ISR_INSTALL(_idt, 47, _asm_isr47, 0)
+    ISR_INSTALL(_idt, 48, _asm_isr48, 0)
+    ISR_INSTALL(_idt, 49, _asm_isr49, 0)
+    ISR_INSTALL(_idt, 50, _asm_isr50, 0)
+    ISR_INSTALL(_idt, 51, _asm_isr51, 0)
+    ISR_INSTALL(_idt, 52, _asm_isr52, 0)
+    ISR_INSTALL(_idt, 53, _asm_isr53, 0)
+    ISR_INSTALL(_idt, 54, _asm_isr54, 0)
+    ISR_INSTALL(_idt, 55, _asm_isr55, 0)
+    ISR_INSTALL(_idt, 56, _asm_isr56, 0)
+    ISR_INSTALL(_idt, 57, _asm_isr57, 0)
+    ISR_INSTALL(_idt, 58, _asm_isr58, 0)
+    ISR_INSTALL(_idt, 59, _asm_isr59, 0)
+    ISR_INSTALL(_idt, 60, _asm_isr60, 0)
+    ISR_INSTALL(_idt, 61, _asm_isr61, 0)
+    ISR_INSTALL(_idt, 62, _asm_isr62, 0)
+    ISR_INSTALL(_idt, 63, _asm_isr63, 0)
+    ISR_INSTALL(_idt, 64, _asm_isr64, 0)
+    ISR_INSTALL(_idt, 65, _asm_isr65, 0)
+    ISR_INSTALL(_idt, 66, _asm_isr66, 0)
+    ISR_INSTALL(_idt, 67, _asm_isr67, 0)
+    ISR_INSTALL(_idt, 68, _asm_isr68, 0)
+    ISR_INSTALL(_idt, 69, _asm_isr69, 0)
+    ISR_INSTALL(_idt, 70, _asm_isr70, 0)
+    ISR_INSTALL(_idt, 71, _asm_isr71, 0)
+    ISR_INSTALL(_idt, 72, _asm_isr72, 0)
+    ISR_INSTALL(_idt, 73, _asm_isr73, 0)
+    ISR_INSTALL(_idt, 74, _asm_isr74, 0)
+    ISR_INSTALL(_idt, 75, _asm_isr75, 0)
+    ISR_INSTALL(_idt, 76, _asm_isr76, 0)
+    ISR_INSTALL(_idt, 77, _asm_isr77, 0)
+    ISR_INSTALL(_idt, 78, _asm_isr78, 0)
+    ISR_INSTALL(_idt, 79, _asm_isr79, 0)
+    ISR_INSTALL(_idt, 80, _asm_isr80, 0)
+    ISR_INSTALL(_idt, 81, _asm_isr81, 0)
+    ISR_INSTALL(_idt, 82, _asm_isr82, 0)
+    ISR_INSTALL(_idt, 83, _asm_isr83, 0)
+    ISR_INSTALL(_idt, 84, _asm_isr84, 0)
+    ISR_INSTALL(_idt, 85, _asm_isr85, 0)
+    ISR_INSTALL(_idt, 86, _asm_isr86, 0)
+    ISR_INSTALL(_idt, 87, _asm_isr87, 0)
+    ISR_INSTALL(_idt, 88, _asm_isr88, 0)
+    ISR_INSTALL(_idt, 89, _asm_isr89, 0)
+    ISR_INSTALL(_idt, 90, _asm_isr90, 0)
+    ISR_INSTALL(_idt, 91, _asm_isr91, 0)
+    ISR_INSTALL(_idt, 92, _asm_isr92, 0)
+    ISR_INSTALL(_idt, 93, _asm_isr93, 0)
+    ISR_INSTALL(_idt, 94, _asm_isr94, 0)
+    ISR_INSTALL(_idt, 95, _asm_isr95, 0)
+    ISR_INSTALL(_idt, 96, _asm_isr96, 0)
+    ISR_INSTALL(_idt, 97, _asm_isr97, 0)
+    ISR_INSTALL(_idt, 98, _asm_isr98, 0)
+    ISR_INSTALL(_idt, 99, _asm_isr99, 0)
+    ISR_INSTALL(_idt, 100, _asm_isr100, 0)
+    ISR_INSTALL(_idt, 101, _asm_isr101, 0)
+    ISR_INSTALL(_idt, 102, _asm_isr102, 0)
+    ISR_INSTALL(_idt, 103, _asm_isr103, 0)
+    ISR_INSTALL(_idt, 104, _asm_isr104, 0)
+    ISR_INSTALL(_idt, 105, _asm_isr105, 0)
+    ISR_INSTALL(_idt, 106, _asm_isr106, 0)
+    ISR_INSTALL(_idt, 107, _asm_isr107, 0)
+    ISR_INSTALL(_idt, 108, _asm_isr108, 0)
+    ISR_INSTALL(_idt, 109, _asm_isr109, 0)
+    ISR_INSTALL(_idt, 110, _asm_isr110, 0)
+    ISR_INSTALL(_idt, 111, _asm_isr111, 0)
+    ISR_INSTALL(_idt, 112, _asm_isr112, 0)
+    ISR_INSTALL(_idt, 113, _asm_isr113, 0)
+    ISR_INSTALL(_idt, 114, _asm_isr114, 0)
+    ISR_INSTALL(_idt, 115, _asm_isr115, 0)
+    ISR_INSTALL(_idt, 116, _asm_isr116, 0)
+    ISR_INSTALL(_idt, 117, _asm_isr117, 0)
+    ISR_INSTALL(_idt, 118, _asm_isr118, 0)
+    ISR_INSTALL(_idt, 119, _asm_isr119, 0)
+    ISR_INSTALL(_idt, 120, _asm_isr120, 0)
+    ISR_INSTALL(_idt, 121, _asm_isr121, 0)
+    ISR_INSTALL(_idt, 122, _asm_isr122, 0)
+    ISR_INSTALL(_idt, 123, _asm_isr123, 0)
+    ISR_INSTALL(_idt, 124, _asm_isr124, 0)
+    ISR_INSTALL(_idt, 125, _asm_isr125, 0)
+    ISR_INSTALL(_idt, 126, _asm_isr126, 0)
+    ISR_INSTALL(_idt, 127, _asm_isr127, 0)
+    ISR_INSTALL(_idt, 128, _asm_isr128, 0)
+    ISR_INSTALL(_idt, 129, _asm_isr129, 0)
+    ISR_INSTALL(_idt, 130, _asm_isr130, 0)
+    ISR_INSTALL(_idt, 131, _asm_isr131, 0)
+    ISR_INSTALL(_idt, 132, _asm_isr132, 0)
+    ISR_INSTALL(_idt, 133, _asm_isr133, 0)
+    ISR_INSTALL(_idt, 134, _asm_isr134, 0)
+    ISR_INSTALL(_idt, 135, _asm_isr135, 0)
+    ISR_INSTALL(_idt, 136, _asm_isr136, 0)
+    ISR_INSTALL(_idt, 137, _asm_isr137, 0)
+    ISR_INSTALL(_idt, 138, _asm_isr138, 0)
+    ISR_INSTALL(_idt, 139, _asm_isr139, 0)
+    ISR_INSTALL(_idt, 140, _asm_isr140, 0)
+    ISR_INSTALL(_idt, 141, _asm_isr141, 0)
+    ISR_INSTALL(_idt, 142, _asm_isr142, 0)
+    ISR_INSTALL(_idt, 143, _asm_isr143, 0)
+    ISR_INSTALL(_idt, 144, _asm_isr144, 0)
+    ISR_INSTALL(_idt, 145, _asm_isr145, 0)
+    ISR_INSTALL(_idt, 146, _asm_isr146, 0)
+    ISR_INSTALL(_idt, 147, _asm_isr147, 0)
+    ISR_INSTALL(_idt, 148, _asm_isr148, 0)
+    ISR_INSTALL(_idt, 149, _asm_isr149, 0)
+    ISR_INSTALL(_idt, 150, _asm_isr150, 0)
+    ISR_INSTALL(_idt, 151, _asm_isr151, 0)
+    ISR_INSTALL(_idt, 152, _asm_isr152, 0)
+    ISR_INSTALL(_idt, 153, _asm_isr153, 0)
+    ISR_INSTALL(_idt, 154, _asm_isr154, 0)
+    ISR_INSTALL(_idt, 155, _asm_isr155, 0)
+    ISR_INSTALL(_idt, 156, _asm_isr156, 0)
+    ISR_INSTALL(_idt, 157, _asm_isr157, 0)
+    ISR_INSTALL(_idt, 158, _asm_isr158, 0)
+    ISR_INSTALL(_idt, 159, _asm_isr159, 0)
+    ISR_INSTALL(_idt, 160, _asm_isr160, 0)
+    ISR_INSTALL(_idt, 161, _asm_isr161, 0)
+    ISR_INSTALL(_idt, 162, _asm_isr162, 0)
+    ISR_INSTALL(_idt, 163, _asm_isr163, 0)
+    ISR_INSTALL(_idt, 164, _asm_isr164, 0)
+    ISR_INSTALL(_idt, 165, _asm_isr165, 0)
+    ISR_INSTALL(_idt, 166, _asm_isr166, 0)
+    ISR_INSTALL(_idt, 167, _asm_isr167, 0)
+    ISR_INSTALL(_idt, 168, _asm_isr168, 0)
+    ISR_INSTALL(_idt, 169, _asm_isr169, 0)
+    ISR_INSTALL(_idt, 170, _asm_isr170, 0)
+    ISR_INSTALL(_idt, 171, _asm_isr171, 0)
+    ISR_INSTALL(_idt, 172, _asm_isr172, 0)
+    ISR_INSTALL(_idt, 173, _asm_isr173, 0)
+    ISR_INSTALL(_idt, 174, _asm_isr174, 0)
+    ISR_INSTALL(_idt, 175, _asm_isr175, 0)
+    ISR_INSTALL(_idt, 176, _asm_isr176, 0)
+    ISR_INSTALL(_idt, 177, _asm_isr177, 0)
+    ISR_INSTALL(_idt, 178, _asm_isr178, 0)
+    ISR_INSTALL(_idt, 179, _asm_isr179, 0)
+    ISR_INSTALL(_idt, 180, _asm_isr180, 0)
+    ISR_INSTALL(_idt, 181, _asm_isr181, 0)
+    ISR_INSTALL(_idt, 182, _asm_isr182, 0)
+    ISR_INSTALL(_idt, 183, _asm_isr183, 0)
+    ISR_INSTALL(_idt, 184, _asm_isr184, 0)
+    ISR_INSTALL(_idt, 185, _asm_isr185, 0)
+    ISR_INSTALL(_idt, 186, _asm_isr186, 0)
+    ISR_INSTALL(_idt, 187, _asm_isr187, 0)
+    ISR_INSTALL(_idt, 188, _asm_isr188, 0)
+    ISR_INSTALL(_idt, 189, _asm_isr189, 0)
+    ISR_INSTALL(_idt, 190, _asm_isr190, 0)
+    ISR_INSTALL(_idt, 191, _asm_isr191, 0)
+    ISR_INSTALL(_idt, 192, _asm_isr192, 0)
+    ISR_INSTALL(_idt, 193, _asm_isr193, 0)
+    ISR_INSTALL(_idt, 194, _asm_isr194, 0)
+    ISR_INSTALL(_idt, 195, _asm_isr195, 0)
+    ISR_INSTALL(_idt, 196, _asm_isr196, 0)
+    ISR_INSTALL(_idt, 197, _asm_isr197, 0)
+    ISR_INSTALL(_idt, 198, _asm_isr198, 0)
+    ISR_INSTALL(_idt, 199, _asm_isr199, 0)
+    ISR_INSTALL(_idt, 200, _asm_isr200, 0)
+    ISR_INSTALL(_idt, 201, _asm_isr201, 0)
+    ISR_INSTALL(_idt, 202, _asm_isr202, 0)
+    ISR_INSTALL(_idt, 203, _asm_isr203, 0)
+    ISR_INSTALL(_idt, 204, _asm_isr204, 0)
+    ISR_INSTALL(_idt, 205, _asm_isr205, 0)
+    ISR_INSTALL(_idt, 206, _asm_isr206, 0)
+    ISR_INSTALL(_idt, 207, _asm_isr207, 0)
+    ISR_INSTALL(_idt, 208, _asm_isr208, 0)
+    ISR_INSTALL(_idt, 209, _asm_isr209, 0)
+    ISR_INSTALL(_idt, 210, _asm_isr210, 0)
+    ISR_INSTALL(_idt, 211, _asm_isr211, 0)
+    ISR_INSTALL(_idt, 212, _asm_isr212, 0)
+    ISR_INSTALL(_idt, 213, _asm_isr213, 0)
+    ISR_INSTALL(_idt, 214, _asm_isr214, 0)
+    ISR_INSTALL(_idt, 215, _asm_isr215, 0)
+    ISR_INSTALL(_idt, 216, _asm_isr216, 0)
+    ISR_INSTALL(_idt, 217, _asm_isr217, 0)
+    ISR_INSTALL(_idt, 218, _asm_isr218, 0)
+    ISR_INSTALL(_idt, 219, _asm_isr219, 0)
+    ISR_INSTALL(_idt, 220, _asm_isr220, 0)
+    ISR_INSTALL(_idt, 221, _asm_isr221, 0)
+    ISR_INSTALL(_idt, 222, _asm_isr222, 0)
+    ISR_INSTALL(_idt, 223, _asm_isr223, 0)
+    ISR_INSTALL(_idt, 224, _asm_isr224, 0)
+    ISR_INSTALL(_idt, 225, _asm_isr225, 0)
+    ISR_INSTALL(_idt, 226, _asm_isr226, 0)
+    ISR_INSTALL(_idt, 227, _asm_isr227, 0)
+    ISR_INSTALL(_idt, 228, _asm_isr228, 0)
+    ISR_INSTALL(_idt, 229, _asm_isr229, 0)
+    ISR_INSTALL(_idt, 230, _asm_isr230, 0)
+    ISR_INSTALL(_idt, 231, _asm_isr231, 0)
+    ISR_INSTALL(_idt, 232, _asm_isr232, 0)
+    ISR_INSTALL(_idt, 233, _asm_isr233, 0)
+    ISR_INSTALL(_idt, 234, _asm_isr234, 0)
+    ISR_INSTALL(_idt, 235, _asm_isr235, 0)
+    ISR_INSTALL(_idt, 236, _asm_isr236, 0)
+    ISR_INSTALL(_idt, 237, _asm_isr237, 0)
+    ISR_INSTALL(_idt, 238, _asm_isr238, 0)
+    ISR_INSTALL(_idt, 239, _asm_isr239, 0)
+    ISR_INSTALL(_idt, 240, _asm_isr240, 0)
+    ISR_INSTALL(_idt, 241, _asm_isr241, 0)
+    ISR_INSTALL(_idt, 242, _asm_isr242, 0)
+    ISR_INSTALL(_idt, 243, _asm_isr243, 0)
+    ISR_INSTALL(_idt, 244, _asm_isr244, 0)
+    ISR_INSTALL(_idt, 245, _asm_isr245, 0)
+    ISR_INSTALL(_idt, 246, _asm_isr246, 0)
+    ISR_INSTALL(_idt, 247, _asm_isr247, 0)
+    ISR_INSTALL(_idt, 248, _asm_isr248, 0)
+    ISR_INSTALL(_idt, 249, _asm_isr249, 0)
+    ISR_INSTALL(_idt, 250, _asm_isr250, 0)
+    ISR_INSTALL(_idt, 251, _asm_isr251, 0)
+    ISR_INSTALL(_idt, 252, _asm_isr252, 0)
+    ISR_INSTALL(_idt, 253, _asm_isr253, 0)
+    ISR_INSTALL(_idt, 254, _asm_isr254, 0)
+    ISR_INSTALL(_idt, 255, _asm_isr255, 0)
 }
\ No newline at end of file
 }
\ No newline at end of file
index 064e19e933679b7bb58f1244886d045fc9707c63..d2f554376f7b0e3e6a675751ff52c66fb63850fd 100644 (file)
@@ -1,9 +1,9 @@
 #define __ASM__
 #define __ASM__
-#include <arch/i386/interrupts.h>
-#include <arch/i386/i386_asm.h>
-#include <arch/i386/tss.h>
+#include <sys/interrupts.h>
+#include <sys/abi.h>
+#include <sys/interrupt.S.inc>
+
 #include <lunaix/syscall.h>
 #include <lunaix/syscall.h>
-#include <arch/i386/interrupt.S.inc>
 
 #define __ASM_INTR_DIAGNOSIS
 
 
 #define __ASM_INTR_DIAGNOSIS
 
index d63628b3803296d8f8118ddf9765ff0d28f798fc..cea822d79e2ebb73340b0221149b89d34947e52c 100644 (file)
@@ -1,11 +1,9 @@
-#include <arch/i386/interrupts.h>
-#include <arch/i386/tss.h>
+#include <sys/interrupts.h>
+#include <sys/x86_isa.h>
 
 #include <hal/apic.h>
 #include <hal/cpu.h>
 
 
 #include <hal/apic.h>
 #include <hal/cpu.h>
 
-#include <arch/exception.h>
-
 #include <lunaix/isrm.h>
 #include <lunaix/mm/page.h>
 #include <lunaix/mm/vmm.h>
 #include <lunaix/isrm.h>
 #include <lunaix/mm/page.h>
 #include <lunaix/mm/vmm.h>
index 6aae249a7da9471e593d227b8c74d0e7783dbeea..8afd22a55eb549af3416773d48938f0f68d54047 100644 (file)
@@ -1,4 +1,4 @@
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 
 #include <lunaix/isrm.h>
 #include <lunaix/lxconsole.h>
 
 #include <lunaix/isrm.h>
 #include <lunaix/lxconsole.h>
index 272c951f8149eda98e6168d28bb34a808456e696..e5fe775c49d084d00899f0aa8299ebc07b511e5c 100644 (file)
@@ -1,3 +1,5 @@
+/* Generated from i386_intrhnds.S.j2. Do NOT modify */
+
 #define __ASM__
 .macro isr_template vector, no_error_code=1
     .global _asm_isr\vector
 #define __ASM__
 .macro isr_template vector, no_error_code=1
     .global _asm_isr\vector
similarity index 92%
rename from lunaix-os/arch/i386/exceptions/gdt.c
rename to lunaix-os/arch/i386/gdt.c
index 92e31d130edb41052f021ee333a7273dc510177c..7f31c9a4be071947d269deb0591d11db95c5d5f1 100644 (file)
@@ -1,6 +1,6 @@
-#include <arch/i386/gdt.h>
-#include <arch/i386/tss.h>
+#include "gdt.h"
 #include <lunaix/types.h>
 #include <lunaix/types.h>
+#include <sys/x86_isa.h>
 
 #define GDT_ENTRY 6
 
 
 #define GDT_ENTRY 6
 
index 371d9470ac87054add8035b1849190c3fcf9e683..2ca126ae17407a5b52a80d54d955bacfc914137d 100644 (file)
@@ -1,4 +1,4 @@
-#include <arch/i386/vectors.h>
+#include <sys/vectors.h>
 #include <cpuid.h>
 #include <hal/cpu.h>
 #include <lunaix/types.h>
 #include <cpuid.h>
 #include <hal/cpu.h>
 #include <lunaix/types.h>
similarity index 97%
rename from lunaix-os/includes/arch/i386/i386_abi.h
rename to lunaix-os/arch/i386/includes/sys/abi.h
index 0383031fd1ca53cb0342e035058b52feb31feefb..f610b93465b80a0131cbadc032570c846e9a53b6 100644 (file)
@@ -1,6 +1,11 @@
 #ifndef __LUNAIX_I386ABI_H
 #define __LUNAIX_I386ABI_H
 
 #ifndef __LUNAIX_I386ABI_H
 #define __LUNAIX_I386ABI_H
 
+#include <sys/x86_isa.h>
+
+#define stack_alignment 0xfffffff0
+
+#ifndef __ASM__
 #define store_retval(retval) __current->intr_ctx->registers.eax = (retval)
 
 #define store_retval_to(proc, retval) (proc)->intr_ctx->registers.eax = (retval)
 #define store_retval(retval) __current->intr_ctx->registers.eax = (retval)
 
 #define store_retval_to(proc, retval) (proc)->intr_ctx->registers.eax = (retval)
@@ -45,5 +50,5 @@
         *((typeof((arg3))*)(stack_ptr)--) = arg3;                              \
         *((typeof((arg4))*)(stack_ptr)--) = arg4;                              \
     }
         *((typeof((arg3))*)(stack_ptr)--) = arg3;                              \
         *((typeof((arg4))*)(stack_ptr)--) = arg4;                              \
     }
-
+#endif
 #endif /* __LUNAIX_ABI_H */
 #endif /* __LUNAIX_ABI_H */
similarity index 96%
rename from lunaix-os/includes/arch/i386/interrupts.h
rename to lunaix-os/arch/i386/includes/sys/interrupts.h
index 329b0ed9252f1cf616e1631052a47e2d4f9b7525..003a2cd96bcda75b10933814b0a64ad40fe4227c 100644 (file)
@@ -49,7 +49,7 @@ struct exec_param
 #define ISR_PARAM_SIZE sizeof(isr_param)
 
 void
 #define ISR_PARAM_SIZE sizeof(isr_param)
 
 void
-intr_handler(isr_param* param);
+exception_init();
 
 #endif
 
 
 #endif
 
diff --git a/lunaix-os/arch/i386/includes/sys/mm/mempart.h b/lunaix-os/arch/i386/includes/sys/mm/mempart.h
new file mode 100644 (file)
index 0000000..50015aa
--- /dev/null
@@ -0,0 +1,45 @@
+/* Physical Adress Space Partition */
+/* Generated from mempart.h.j2. Do NOT modify */
+
+#define MEM_PAGE 0x1000UL
+#define MEM_1M 0x100000UL
+#define MEM_4M 0x400000UL
+#define MEM_HUGE 0x400000UL
+#define MEM_1G 0x40000000UL
+
+#define KERNEL_STACK 0x300000UL
+#define KERNEL_STACK_SIZE 0x100000UL
+#define KERNEL_STACK_END 0x3ffff0UL
+
+#define KERNEL_EXEC 0xc0000000UL
+#define KERNEL_EXEC_SIZE 0x4000000UL
+#define KERNEL_EXEC_END 0xc3ffffffUL
+
+#define PD_MOUNT 0xc4000000UL
+#define PD_MOUNT_SIZE 0x400000UL
+#define PD_MOUNT_END 0xc43fffffUL
+
+#define PG_MOUNT_1 0xc4400000UL
+#define PG_MOUNT_1_SIZE 0x1000UL
+#define PG_MOUNT_1_END 0xc4400fffUL
+
+#define PG_MOUNT_2 0xc4401000UL
+#define PG_MOUNT_2_SIZE 0x1000UL
+#define PG_MOUNT_2_END 0xc4401fffUL
+
+#define PG_MOUNT_3 0xc4402000UL
+#define PG_MOUNT_3_SIZE 0x1000UL
+#define PG_MOUNT_3_END 0xc4402fffUL
+
+#define PG_MOUNT_4 0xc4403000UL
+#define PG_MOUNT_4_SIZE 0x1000UL
+#define PG_MOUNT_4_END 0xc4403fffUL
+
+#define VMAP 0xc4404000UL
+#define VMAP_SIZE 0x3b7fc000UL
+#define VMAP_END 0xffbfffffUL
+
+#define PD_REF 0xffc00000UL
+#define PD_REF_SIZE 0x400000UL
+#define PD_REF_END 0xffffffffUL
+
diff --git a/lunaix-os/arch/i386/includes/sys/x86_isa.h b/lunaix-os/arch/i386/includes/sys/x86_isa.h
new file mode 100644 (file)
index 0000000..0c53d9d
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __LUNAIX_I386_ASM_H
+#define __LUNAIX_I386_ASM_H
+
+#define KCODE_SEG 0x08
+#define KDATA_SEG 0x10
+#define UCODE_SEG 0x1B
+#define UDATA_SEG 0x23
+#define TSS_SEG 0x28
+
+#define tss_esp0_off 4
+
+#ifndef __ASM__
+#include <lunaix/types.h>
+struct x86_tss
+{
+  u32_t link;
+  u32_t esp0;
+  u16_t ss0;
+  u8_t __padding[94];
+} __attribute__((packed));
+
+void tss_update_esp(u32_t esp0);
+#endif
+
+#endif /* __LUNAIX_I386_ASM_H */
index edff52599807134fe65482006bc5572ba0ddfea0..58c7ec2b23f57416560f837d33310b315fe40f96 100644 (file)
@@ -1,4 +1,4 @@
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <lunaix/common.h>
 #include <lunaix/mm/mm.h>
 #include <lunaix/mm/pmm.h>
 #include <lunaix/common.h>
 #include <lunaix/mm/mm.h>
 #include <lunaix/mm/pmm.h>
index cee33ada4e2793e0c7031bdab3e66ce21b6acf59..22a996a1fa0393d8b754aa7bc81fe91c3e7500d9 100644 (file)
@@ -1,6 +1,6 @@
-#include <arch/i386/tss.h>
 #include <lunaix/common.h>
 #include <lunaix/process.h>
 #include <lunaix/common.h>
 #include <lunaix/process.h>
+#include <sys/x86_isa.h>
 
 volatile struct x86_tss _tss = { .link = 0,
                                  .esp0 = KSTACK_TOP,
 
 volatile struct x86_tss _tss = { .link = 0,
                                  .esp0 = KSTACK_TOP,
index 29794eb11d74e715ecd663506d2d10fb77c8c422..099fd503559ef21e4ea5d52de4042e9d5a1e1823 100644 (file)
@@ -13,7 +13,7 @@
 #include <hal/pic.h>
 #include <hal/rtc.h>
 
 #include <hal/pic.h>
 #include <hal/rtc.h>
 
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 
 #include <lunaix/mm/mmio.h>
 #include <lunaix/spike.h>
 
 #include <lunaix/mm/mmio.h>
 #include <lunaix/spike.h>
index bfde8a115a2b7029ec3206cd3067dc162516a9ba..f0bd706a1aed4b41f1ff22e7256bbbc7786476f4 100644 (file)
@@ -1,4 +1,4 @@
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <hal/acpi/acpi.h>
 #include <hal/ioapic.h>
 #include <lunaix/common.h>
 #include <hal/acpi/acpi.h>
 #include <hal/ioapic.h>
 #include <lunaix/common.h>
diff --git a/lunaix-os/includes/arch/abi.h b/lunaix-os/includes/arch/abi.h
deleted file mode 100644 (file)
index 8515974..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __LUNAIX_ABI_H
-#define __LUNAIX_ABI_H
-
-/* clang-format off */
-
-#if 0
-// templates, new arch should implements these templates
-#define store_retval(retval)
-#endif
-
-#ifdef __ARCH_IA32
-    #include "i386/i386_asm.h"
-    #ifndef __ASM__
-        #include "i386/i386_abi.h"
-    #endif
-#endif
-
-/* clang-format on */
-
-#endif /* __LUNAIX_ABI_H */
diff --git a/lunaix-os/includes/arch/exception.h b/lunaix-os/includes/arch/exception.h
deleted file mode 100644 (file)
index 31c3792..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __LUNAIX_EXCEPTION_H
-#define __LUNAIX_EXCEPTION_H
-
-void
-exception_init();
-
-#endif /* __LUNAIX_EXCEPTION_H */
diff --git a/lunaix-os/includes/arch/i386/i386_asm.h b/lunaix-os/includes/arch/i386/i386_asm.h
deleted file mode 100644 (file)
index b6e8d05..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __LUNAIX_I386_ASM_H
-#define __LUNAIX_I386_ASM_H
-
-#define KCODE_SEG 0x08
-#define KDATA_SEG 0x10
-#define UCODE_SEG 0x1B
-#define UDATA_SEG 0x23
-#define TSS_SEG 0x28
-
-#define stack_alignment 0xfffffff0
-
-#endif /* __LUNAIX_I386_ASM_H */
diff --git a/lunaix-os/includes/arch/i386/idt.h b/lunaix-os/includes/arch/i386/idt.h
deleted file mode 100644 (file)
index 0d515c2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __LUNAIX_IDT_H
-#define __LUNAIX_IDT_H
-#define IDT_TRAP 0x78
-#define IDT_INTERRUPT 0x70
-#define IDT_ATTR(dpl, type) (((type) << 5) | ((dpl & 3) << 13) | (1 << 15))
-
-void
-_init_idt();
-
-#endif /* __LUNAIX_IDT_H */
\ No newline at end of file
diff --git a/lunaix-os/includes/arch/i386/tss.h b/lunaix-os/includes/arch/i386/tss.h
deleted file mode 100644 (file)
index 931ff26..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __LUNAIX_TSS_H
-#define __LUNAIX_TSS_H
-
-#define tss_esp0_off 4
-
-#ifndef __ASM__
-#include <lunaix/types.h>
-struct x86_tss
-{
-    u32_t link;
-    u32_t esp0;
-    u16_t ss0;
-    u8_t __padding[94];
-} __attribute__((packed));
-
-void
-tss_update_esp(u32_t esp0);
-#endif
-
-#endif /* __LUNAIX_TSS_H */
index f5ef5235616b941f8a8de913fab993b8563a6222..8f51a2cb18ef5ac12752fc586136be99b6178e84 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_ACPI_ACPI_H
 #define __LUNAIX_ACPI_ACPI_H
 
 #ifndef __LUNAIX_ACPI_ACPI_H
 #define __LUNAIX_ACPI_ACPI_H
 
-#include <arch/i386/boot/multiboot.h>
+#include <sys/boot/multiboot.h>
 #include <stddef.h>
 #include <stdint.h>
 
 #include <stddef.h>
 #include <stdint.h>
 
index 94b8de3cb6d83dfca2a41cc339ccb17a734f4d99..5998dd1897237455fb5864d0b13ce73bf58768f4 100644 (file)
@@ -11,7 +11,7 @@
 #ifndef __LUNAIX_ISRM_H
 #define __LUNAIX_ISRM_H
 
 #ifndef __LUNAIX_ISRM_H
 #define __LUNAIX_ISRM_H
 
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <lunaix/types.h>
 
 #define IV_BASE 32
 #include <lunaix/types.h>
 
 #define IV_BASE 32
index 5371e833925ff529128411ba52f3bfd64dabc7c1..c3ac9a5312c6e65536ed4644c2aecb8635359a5f 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_PROCESS_H
 #define __LUNAIX_PROCESS_H
 
 #ifndef __LUNAIX_PROCESS_H
 #define __LUNAIX_PROCESS_H
 
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <lunaix/clock.h>
 #include <lunaix/ds/waitq.h>
 #include <lunaix/fs.h>
 #include <lunaix/clock.h>
 #include <lunaix/ds/waitq.h>
 #include <lunaix/fs.h>
index 919f93a0c2efdf748d94af1ea055dddae86286db..3b0f0702f345a4ab4027f676754c0b958ee605d6 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_SYSCALL_H
 #define __LUNAIX_SYSCALL_H
 
 #ifndef __LUNAIX_SYSCALL_H
 #define __LUNAIX_SYSCALL_H
 
-#include <arch/i386/vectors.h>
+#include <sys/vectors.h>
 #include <usr/lunaix/syscallid.h>
 
 #ifndef __ASM__
 #include <usr/lunaix/syscallid.h>
 
 #ifndef __ASM__
index d2e329e937a75f4d9888381c481cf290362e22a7..c4c60da2c0f44a55e6ab23a62ea01900058c7cc2 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_GDBSTUB_H
 #define __LUNAIX_GDBSTUB_H
 
 #ifndef __LUNAIX_GDBSTUB_H
 #define __LUNAIX_GDBSTUB_H
 
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 
 void
 gdbstub_loop(isr_param* param);
 
 void
 gdbstub_loop(isr_param* param);
index 16999b08271d539a8392b4b41a37c753385cc2db..f4b4a49e43408068069272fdeaabcd8b77ad7e22 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_LSDBG_H
 #define __LUNAIX_LSDBG_H
 
 #ifndef __LUNAIX_LSDBG_H
 #define __LUNAIX_LSDBG_H
 
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 
 #define SDBG_CLNT_HI 0x10
 #define SDBG_CLNT_QUIT 0xff
 
 #define SDBG_CLNT_HI 0x10
 #define SDBG_CLNT_QUIT 0xff
index 81e8921201c9aae5770b2a7aab1f5644752c8587..1c07c908c0ca53730e7d5dfd888eee7513ae9df0 100644 (file)
@@ -12,6 +12,7 @@ endef
 define kinc_dirs
        includes
        includes/usr
 define kinc_dirs
        includes
        includes/usr
+       arch/$(ARCH)/includes
 endef
 
 
 endef
 
 
index 8a14c4ad0f8059694430f3cc65b98956f586e6ba..df47bb75a11ffde0e7646e718c3d3a5aed6147c7 100644 (file)
@@ -1,4 +1,3 @@
-#include <arch/abi.h>
 #include <lunaix/exec.h>
 #include <lunaix/fs.h>
 #include <lunaix/load.h>
 #include <lunaix/exec.h>
 #include <lunaix/fs.h>
 #include <lunaix/load.h>
@@ -11,6 +10,8 @@
 #include <lunaix/syscall.h>
 #include <lunaix/syscall_utils.h>
 
 #include <lunaix/syscall.h>
 #include <lunaix/syscall_utils.h>
 
+#include <sys/abi.h>
+
 #include <klibc/string.h>
 
 void
 #include <klibc/string.h>
 
 void
index 5ace096f994e941123dd53b14d46aaceba1331c6..6cb5871cc284c7de0a5e8255c90a635803781e16 100644 (file)
 #include <lunaix/tty/tty.h>
 #include <lunaix/types.h>
 
 #include <lunaix/tty/tty.h>
 #include <lunaix/types.h>
 
-#include <arch/abi.h>
-#include <arch/exception.h>
-#include <arch/i386/boot/multiboot.h>
-#include <arch/i386/interrupts.h>
+#include <sys/abi.h>
+#include <sys/boot/multiboot.h>
+#include <sys/interrupts.h>
 
 #include <klibc/stdio.h>
 #include <klibc/string.h>
 
 #include <klibc/stdio.h>
 #include <klibc/string.h>
index 02e3b679c06f5c024b0d584f02b0d43f563b2fae..1547283d0d824b2bc97e78d15a5a7ac02b968bc2 100644 (file)
@@ -8,7 +8,7 @@
 #include <lunaix/syslog.h>
 #include <lunaix/timer.h>
 
 #include <lunaix/syslog.h>
 #include <lunaix/timer.h>
 
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <hal/cpu.h>
 #include <klibc/string.h>
 
 #include <hal/cpu.h>
 #include <klibc/string.h>
 
index 15afae4c8b5daa724aa592872ec35b19d1483c55..221ec2375aea3f0ec499dfdb97d910ba1b470848 100644 (file)
@@ -26,7 +26,7 @@
 #include <hal/pci.h>
 #include <hal/rtc.h>
 
 #include <hal/pci.h>
 #include <hal/rtc.h>
 
-#include <arch/i386/boot/multiboot.h>
+#include <sys/boot/multiboot.h>
 
 #include <klibc/string.h>
 
 
 #include <klibc/string.h>
 
index 0ba6c6352db3c6a76835bb6b0597da684bebf9c1..f500cbed01890dab04a01f739f9e0b4f70837de0 100644 (file)
@@ -1,4 +1,3 @@
-#include <arch/abi.h>
 #include <klibc/string.h>
 #include <lunaix/clock.h>
 #include <lunaix/common.h>
 #include <klibc/string.h>
 #include <lunaix/clock.h>
 #include <lunaix/common.h>
@@ -12,6 +11,7 @@
 #include <lunaix/status.h>
 #include <lunaix/syscall.h>
 #include <lunaix/syslog.h>
 #include <lunaix/status.h>
 #include <lunaix/syscall.h>
 #include <lunaix/syslog.h>
+#include <sys/abi.h>
 
 LOG_MODULE("PROC")
 
 
 LOG_MODULE("PROC")
 
index 2fa5ca686bd85d17a8d9f7bec584d59f98cb2212..ec5d6c0fe5edc9f4700cc3566f28b4f94ab7dd24 100644 (file)
@@ -1,5 +1,5 @@
-#include <arch/abi.h>
-#include <arch/i386/interrupts.h>
+#include <sys/abi.h>
+#include <sys/interrupts.h>
 
 #include <hal/apic.h>
 #include <hal/cpu.h>
 
 #include <hal/apic.h>
 #include <hal/cpu.h>
index 8d55b58d46ffec89ff9783388290c9825e6b2344..231b85d6f375a97692b374b351cc77f968c14b50 100644 (file)
@@ -1,4 +1,4 @@
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <klibc/stdio.h>
 #include <lunaix/spike.h>
 
 #include <klibc/stdio.h>
 #include <lunaix/spike.h>
 
index d62464d313b685c6d219dbbefca274e8c4366383..1c0110de3fa74427436c5743696d25838b285b46 100644 (file)
@@ -1,4 +1,4 @@
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <lunaix/isrm.h>
 #include <lunaix/process.h>
 #include <lunaix/sched.h>
 #include <lunaix/isrm.h>
 #include <lunaix/process.h>
 #include <lunaix/sched.h>
index 2aca8d588014eba5517808863523226651958c58..61f6d410cca59d4f232a571907454f7fba231c25 100644 (file)
@@ -9,7 +9,7 @@
  * @copyright Copyright (c) 2022
  *
  */
  * @copyright Copyright (c) 2022
  *
  */
-#include <arch/i386/interrupts.h>
+#include <sys/interrupts.h>
 #include <hal/apic.h>
 #include <hal/rtc.h>
 
 #include <hal/apic.h>
 #include <hal/rtc.h>
 
index eac983f31d7f0f37caaf865b74cd9b9c9b413daf..cd621646d4b929983d56ab4dac33656b42847da9 100644 (file)
@@ -1,71 +1,46 @@
 import jinja2
 import re
 import argparse
 import jinja2
 import re
 import argparse
-import sys
+import math
 import json
 from pathlib import Path
 from abc import ABC, abstractmethod
 
 import json
 from pathlib import Path
 from abc import ABC, abstractmethod
 
-class ControlAction(ABC):
-    def __init__(self, record) -> None:
-        self.__record = record
-        self._parse(record)
-
-    @staticmethod
-    def create(field, value):
-        if field == "$range":
-            return RangeAction(value)
-        else:
-            return value
-    
-    @abstractmethod
-    def _parse(self, record):
+class Preprocessor:
+    reHex = re.compile(r"^0x([0-9a-fA-F]+)$")
+    reGranuel = re.compile(r"^(?P<num>[0-9]+)@(?P<g>.+)$")
+    reMacroRef = re.compile(r"^\*(?P<var>[a-zA-z0-9]+)$")
+    reInt = re.compile(r"^[0-9]+$")
+    def __init__(self) -> None:
         pass
 
         pass
 
-    @abstractmethod
-    def action(self, data, param):
-        pass
-
-    def get(self):
-        return self.__record
-
-class RangeAction(ControlAction):
-    def __init__(self, record) -> None:
-        self.__ranged_component = re.compile(r"^(?P<index>[0-9]+)$|^(?P<start>[0-9]+)..(?P<end>[0-9]+)$")
-        super().__init__(record)
-
-    def _parse(self, record):
-        if not (record.startswith('[') and record.endswith(']')):
-            raise Exception(f"'{record}' is not valid range expression")
-        record = record.strip('[]')
+    @staticmethod
+    def expand_str(s: str, param_dict):
+        if Preprocessor.reInt.match(s) is not None:
+            return int(s)
         
         
-        self.__value=[]
-        for component in record.split(','):
-            component = component.strip()
-            mo = self.__ranged_component.match(component)
-            if mo is None:
-                raise Exception(f"value '{component}' is not valid range component")
-            
-            mo = mo.groupdict()
-            if mo["index"] is not None:
-                self.__value.append(int(mo['index']))
-            else:
-                start = int(mo['start'])
-                end = int(mo['end'])
-                self.__value += [x for x in range(start, end + 1)]
-
-        self.__value = sorted(self.__value)
-
-    def action(self, data, param):
-        return super().action(data, param)
+        mo = Preprocessor.reHex.match(s)
+        if mo is not None:
+            return int(s, 16)
+        
+        mo = Preprocessor.reGranuel.match(s)
+        if mo is not None:
+            mg = mo.groupdict()
+            num = int(mg['num'])
+            granuel = param_dict["granule"][mg['g']]
+            return num * granuel
+        
+        mo = Preprocessor.reMacroRef.match(s)
+        if mo is not None:
+            mg = mo.groupdict()
+            return param_dict[mg['var']]
 
 
-    def get(self):
-        return self.__value
-    
+        return s.format_map(param_dict)
 
 class DataObject(ABC):
     def __init__(self, name, record):
         self.key = name
 
 class DataObject(ABC):
     def __init__(self, name, record):
         self.key = name
+        self._record = record
         self.user_field = {}
         self.ctrl_field = {}
         self._parse(record)
         self.user_field = {}
         self.ctrl_field = {}
         self._parse(record)
@@ -76,8 +51,8 @@ class DataObject(ABC):
 
     @staticmethod
     def create(key, record):
 
     @staticmethod
     def create(key, record):
-        if not isinstance(record, dict):
-            return record
+        if PrimitiveType.can_create(record):
+            return PrimitiveType(record)
         
         name = key
         t = name if "$type" not in record else record['$type']
         
         name = key
         t = name if "$type" not in record else record['$type']
@@ -97,27 +72,128 @@ class DataObject(ABC):
             return Condition(record)
         elif t == "data":
             return PlainOldObject(name, record)
             return Condition(record)
         elif t == "data":
             return PlainOldObject(name, record)
+        elif t == "define":
+            return VariableDeclarationObject(record)
+        elif t == "memory_map":
+            return MemoryMapObject(record)
         else:
             return RawObject(name, record)
 
         else:
             return RawObject(name, record)
 
-    @abstractmethod
     def _parse(self, record):
         for k, v in record.items():
             if k.startswith("$"):
     def _parse(self, record):
         for k, v in record.items():
             if k.startswith("$"):
-                self.ctrl_field[k.strip("$")] = ControlAction.create(k, v)
+                self.ctrl_field[k.strip("$")] = FieldType.create(k, v)
             elif k.startswith("@"):
                 self.ctrl_field[k.strip("@")] = DataObject.create(k, v)
             else:
                 self.user_field[k] = DataObject.create(k, v)
 
             elif k.startswith("@"):
                 self.ctrl_field[k.strip("@")] = DataObject.create(k, v)
             else:
                 self.user_field[k] = DataObject.create(k, v)
 
-    @abstractmethod
     def expand(self, param={}):
     def expand(self, param={}):
-        obj = { **self.user_field }
+        obj2 = {}
         for f in self.ctrl_field.values():
             if not isinstance(f, DataObject):
                 continue
         for f in self.ctrl_field.values():
             if not isinstance(f, DataObject):
                 continue
-            obj.update(**f.expand(param))
-        return obj
+            obj2.update(**f.expand(param))
+
+        obj = {}
+        _param = {**param, **obj2}
+        for k, v in self.user_field.items():
+            if isinstance(v, DataObject):
+                obj[k] = v.expand(_param)
+            else:
+                obj[k] = v
+
+        return {**obj, **obj2}
+    
+
+class FieldType:
+    def __init__(self, record) -> None:
+        self._record = record
+        self._parse(record)
+
+    @staticmethod
+    def create(field, value):
+        if field == "$range":
+            return RangeType(value)
+        else:
+            return value
+    
+    @abstractmethod
+    def _parse(self, record):
+        pass
+
+    @abstractmethod
+    def get(self, param):
+        pass
+
+    def getraw(self):
+        return self.__record
+
+class PrimitiveType(DataObject):
+    def __init__(self, record) -> None:
+        super().__init__("", record)
+
+    @staticmethod
+    def can_create(value):
+        return type(value) in (str, int, bool)
+
+    def _parse(self, record):
+        if type(record) not in (str, int, bool):
+            raise Exception(f"{type(self).__name__} require primitive type input")
+        self.val = record
+
+        if type(record) == str:
+            self.__get_fn = self.__process_str
+        else:
+            self.__get_fn = lambda x: self.val
+
+    def __process_str(self, param):
+        return Preprocessor.expand_str(self.val, param)
+    
+    def expand(self, param={}):
+        return self.__get_fn(param)
+
+class RangeType(FieldType):
+    def __init__(self, record) -> None:
+        self.__ranged_component = re.compile(r"^(?P<index>[^.]+)$|^(?P<start>.+?)\.\.(?P<end>.+)$")
+        super().__init__(record)
+
+    def _parse(self, record):
+        return super()._parse(record)
+    
+    def get(self, param):
+        record = self._record.strip('[]')
+        
+        self.__value=[]
+        for component in record.split(','):
+            component = component.strip()
+            mo = self.__ranged_component.match(component)
+            if mo is None:
+                raise Exception(f"value '{component}' is not valid range component")
+            
+            mo = mo.groupdict()
+            if mo["index"] is not None:
+                self.__value.append(Preprocessor.expand_str(mo['index'], param))
+            else:
+                start = Preprocessor.expand_str(mo['start'], param)
+                end = Preprocessor.expand_str(mo['end'], param)
+                self.__value += [x for x in range(start, end + 1)]
+        return self.__value
+
+    def getraw(self):
+        return self._record
+    
+class VariableDeclarationObject(DataObject):
+    def __init__(self, record):
+        super().__init__("", record)
+    
+    def _parse(self, record):
+        return super()._parse(record)
+    
+    def expand(self, param={}):
+        obj = super().expand(param)
+        param.update(**obj)
+        return {}
 
 class Condition(DataObject):
     def __init__(self, record):
 
 class Condition(DataObject):
     def __init__(self, record):
@@ -130,21 +206,133 @@ class Condition(DataObject):
         if "true" not in self.ctrl_field:
             raise Exception("condition body must contains 'True' handling case")
         
         if "true" not in self.ctrl_field:
             raise Exception("condition body must contains 'True' handling case")
         
-        self.__range_lst = self.ctrl_field["range"].get()
     
     def expand(self, param={}):
     
     def expand(self, param={}):
+        self.__range_lst = self.ctrl_field["range"].get(param)
         if param["index"] in self.__range_lst:
             return self.ctrl_field["true"].expand(param)
         elif "else" in self.ctrl_field:
             return self.ctrl_field["else"].expand(param)
         return {}
         if param["index"] in self.__range_lst:
             return self.ctrl_field["true"].expand(param)
         elif "else" in self.ctrl_field:
             return self.ctrl_field["else"].expand(param)
         return {}
+    
+class ArrayObject(DataObject):
+    def __init__(self, record, 
+                 nested_array = False, 
+                 el_factory = lambda x: DataObject.create("", x)):
+        self._el_factory = el_factory
+        self._nested_array = nested_array
+
+        super().__init__("", record)
+    
+    def _parse(self, record):
+        if not isinstance(record, list):
+            raise Exception(f"{type(self).__name__} require array input")
+        
+        self.content = []
+        for x in record:
+            self.content.append(self._el_factory(x))
+    
+    def expand(self, param={}):
+        result = []
+        for x in self.content:
+            obj = x.expand(param)
+            if isinstance(obj, list) and not self._nested_array:
+                result += [*obj]
+            else:
+                result.append(obj)
+        
+        return result
+    
+class MemoryMapObject(DataObject):
+    class GranuleObject(DataObject):
+        def __init__(self, record):
+            super().__init__("", record)
+            
+        def _parse(self, record):
+            self.__granules = {}
+            for k, v in record.items():
+                self.__granules[k] = DataObject.create(k, v)
+
+        def expand(self, param={}):
+            granules = {}
+            for k, v in self.__granules.items():
+                val = v.expand(param)
+
+                if not isinstance(val, int):
+                    raise Exception("The granule definition must be either integer or int-castable string")
+                
+                granules[k] = val
+                
+            return {**granules}
+        
+    def __init__(self, record):
+        super().__init__("", record)
+
+    def _parse(self, record):
+        if "granule" in self._record:
+            self.__g = MemoryMapObject.GranuleObject(self._record["granule"])
+        if "regions" in self._record:
+            self.__regions = ArrayObject(self._record["regions"])
+        if "width" in self._record:
+            self.__width = DataObject.create("width", self._record["width"])
+
+    def __process(self, start_addr, idx, regions, size_lookahead = False):
+        if idx >= len(regions):
+            raise Exception("Unbounded region definition")
+        
+        e = regions[idx]
+
+        if "boundary" in e:
+            b = e["boundary"] - 1
+            start_addr = (start_addr + b) & ~b
+
+        if "start" not in e:
+            e["start"] = start_addr
+        elif e["start"] < start_addr:
+            raise Exception(f"starting addr {hex(e['start'])} overrlapping with {hex(start_addr)}")
+        else:
+            start_addr = e["start"]
+        
+        if "size" not in e:
+            if size_lookahead:
+                raise Exception("could not infer size from unbounded region")
+            tmp_addr = self.__process(start_addr, idx + 1, regions, size_lookahead=True)
+            e["size"] = tmp_addr - start_addr
+        
+        if not size_lookahead:
+            start_addr += e["size"]
+        
+        return start_addr
+    
+    def expand(self, param={}):
+        g = self.__g.expand(param)
+
+        param["granule"] = g
+
+        width = self.__width.expand(param)
+        if not isinstance(width, int):
+            raise Exception("'width' attribute must be integer")
+
+        regions = self.__regions.expand(param)
+        
+        start_addr = 0
+        for i in range(len(regions)):
+            start_addr = self.__process(start_addr, i, regions)
+        
+        if math.log2(start_addr) > width:
+            raise Exception("memory size larger than speicified address width")
+
+        return {
+            "granule": g,
+            "regions": regions
+        }
 
 class ForEachIndexObject(DataObject):
     def __init__(self, name, record):
         super().__init__(name, record)
 
 class ForEachIndexObject(DataObject):
     def __init__(self, name, record):
         super().__init__(name, record)
-        self.conditions = []
+        self.steps = []
         for k, v in record.items():
         for k, v in record.items():
-            self.conditions.append(DataObject.create(k, v))
+            self.steps.append(DataObject.create(k, v))
 
     def _parse(self, record):
         super()._parse(record)
 
     def _parse(self, record):
         super()._parse(record)
@@ -153,7 +341,7 @@ class ForEachIndexObject(DataObject):
         if "index" not in param:
             raise Exception(f"'{type(self).__name__}' require parameter 'index'.")
         obj = {}
         if "index" not in param:
             raise Exception(f"'{type(self).__name__}' require parameter 'index'.")
         obj = {}
-        for cond in self.conditions:
+        for cond in self.steps:
             obj.update(**cond.expand(param))
         return obj
     
             obj.update(**cond.expand(param))
         return obj
     
@@ -175,9 +363,7 @@ class PlainOldObject(DataObject):
         return super()._parse(record)
 
     def expand(self, param={}):
         return super()._parse(record)
 
     def expand(self, param={}):
-        return {
-            self.key: super().expand(param)
-        }
+        return super().expand(param)
 
 class RangedObject(DataObject):
     def __init__(self, name, record):
 
 class RangedObject(DataObject):
     def __init__(self, name, record):
@@ -191,15 +377,15 @@ class RangedObject(DataObject):
             raise Exception("RangedObject with ranged type must have 'range' field defined")
         
         out_lst = []
             raise Exception("RangedObject with ranged type must have 'range' field defined")
         
         out_lst = []
-        indices = self.ctrl_field["range"].get()
+        indices = self.ctrl_field["range"].get(param)
         for i in indices:
             param["index"] = i
         for i in indices:
             param["index"] = i
-            self.user_field["index"] = i
             out_lst.append(super().expand(param))
         
             out_lst.append(super().expand(param))
         
-        return {
-            self.key: out_lst
-        }
+        return out_lst
+    
+def aligned(v, a):
+    return v & ~(a - 1)
     
 class TemplateExpander:
     def __init__(self, template_path, project_path, arch) -> None:
     
 class TemplateExpander:
     def __init__(self, template_path, project_path, arch) -> None:
@@ -207,6 +393,11 @@ class TemplateExpander:
         self.tbase_path = template_path.joinpath(arch)
         self.pbase_path = project_path
 
         self.tbase_path = template_path.joinpath(arch)
         self.pbase_path = project_path
 
+        self.__helper_fns = {
+            "align": aligned,
+            "hex": lambda x: hex(x)
+        }
+
         self.__load_config()
         self.__load_mappings()
 
         self.__load_config()
         self.__load_mappings()
 
@@ -219,7 +410,7 @@ class TemplateExpander:
         obj = json.loads(cfg_file.read_text())
         for k, v in obj.items():
             o = DataObject.create(k, v).expand()
         obj = json.loads(cfg_file.read_text())
         for k, v in obj.items():
             o = DataObject.create(k, v).expand()
-            self.data.update(**o)
+            self.data[k] = o
 
     def __load_mappings(self):
         self.mapping = {}
 
     def __load_mappings(self):
         self.mapping = {}
@@ -229,6 +420,11 @@ class TemplateExpander:
         
         with mapping_file.open() as f:
             for l in f:
         
         with mapping_file.open() as f:
             for l in f:
+                l = l.strip()
+
+                if not l:
+                    continue
+
                 src, dest = l.split("->")
                 src = src.strip()
 
                 src, dest = l.split("->")
                 src = src.strip()
 
@@ -243,14 +439,20 @@ class TemplateExpander:
             dest: Path = self.pbase_path.joinpath(v)
             if not src.is_file():
                 continue
             dest: Path = self.pbase_path.joinpath(v)
             if not src.is_file():
                 continue
+
+            if not dest.parent.exists():
+                dest.parent.mkdir(parents=True)
             
             
+            self.data["template"] = k
             template = jinja2.Template(src.read_text(), trim_blocks=True)
             template = jinja2.Template(src.read_text(), trim_blocks=True)
+            template.globals.update(**self.__helper_fns)
             out = template.render(data=self.data)
 
             dest.write_text(out)
 
             print(f"rendered: {k} -> {v}")
 
             out = template.render(data=self.data)
 
             dest.write_text(out)
 
             print(f"rendered: {k} -> {v}")
 
+import pprint
 
 def main():
     parser = argparse.ArgumentParser()
 
 def main():
     parser = argparse.ArgumentParser()
@@ -261,7 +463,9 @@ def main():
     args = parser.parse_args()
 
     expander = TemplateExpander(Path(args.template_dir), Path(args.project_dir), args.arch)
     args = parser.parse_args()
 
     expander = TemplateExpander(Path(args.template_dir), Path(args.project_dir), args.arch)
+    
     expander.render()
     expander.render()
+    # pprint.pprint(expander.data)
 
 if __name__ == "__main__":
     main()
\ No newline at end of file
 
 if __name__ == "__main__":
     main()
\ No newline at end of file
index 97089c814714129578f6115a9515dbc5ba5a45e6..7a0a702b44f5356ed142e22836d79a537c13c386 100644 (file)
@@ -1,19 +1,82 @@
 {
     "exception": {
 {
     "exception": {
-        "$type": "list",
-        "$range": "[0..255]",
+        "@define": {
+            "syscall_iv": 33,
+            "iv_counts": 255
+        },
+        "ivdefs": {
+            "$type": "list",
+            "$range": "[0..*iv_counts]",
 
 
-        "@foreach": {
-            "@case_range_index": {
-                "$range": "[8,10..14,17]",
-
-                "@true": {
-                    "has_errcode": true
+            "iv": "{index}",
+    
+            "@foreach": {
+                "errcode": {
+                    "$type": "case_range_index",
+                    "$range": "[8,10..14,17]",
+    
+                    "@true": {
+                        "has_errcode": true
+                    },
+                    "@else": {
+                        "has_errcode": false
+                    }
                 },
                 },
-                "@else": {
-                    "has_errcode": false
+                "dpl": {
+                    "$type": "case_range_index",
+                    "$range": "[*syscall_iv]",
+    
+                    "@true": {
+                        "dpl": 3
+                    },
+                    "@else": {
+                        "dpl": 0
+                    }
                 }
             }
         }
                 }
             }
         }
+    },
+    "sys_mmap": {
+        "$type": "memory_map",
+        "width": 32,
+        "granule": {
+            "page": "0x1000",
+            "1M": "0x100000",
+            "4M": "0x400000",
+            "huge": "0x400000",
+            "1G": "0x40000000"
+        },
+        "regions": [
+            {
+                "name": "kernel_stack",
+                "start": "3@1M",
+                "size": "1@1M",
+                "stk_align": 16
+            },
+            {
+                "name": "kernel_exec",
+                "start": "3@1G",
+                "size": "16@4M"
+            },
+            {
+                "name": "pd_mount",
+                "size": "1@4M"
+            },
+            {
+                "$type": "list",
+                "$range": "[1..4]",
+                "size": "1@page",
+                "name": "pg_mount_{index}"
+            },
+            {
+                "name": "vmap",
+                "block": "1@huge"
+            },
+            {
+                "name": "pd_ref",
+                "start": "1023@4M",
+                "size": "1@4M"
+            }
+        ]
     }
 }
\ No newline at end of file
     }
 }
\ No newline at end of file
index 3f9b58561dae2d0f08654eaf376a2030230a6268..26067ac5149276768474fd35cab2e4f67e70072c 100644 (file)
@@ -1,3 +1,5 @@
+/* Generated from {{ data["template"] }}. Do NOT modify */
+
 #define __ASM__
 .macro isr_template vector, no_error_code=1
     .global _asm_isr\vector
 #define __ASM__
 .macro isr_template vector, no_error_code=1
     .global _asm_isr\vector
         jmp interrupt_wrapper
 .endm
 .section .text
         jmp interrupt_wrapper
 .endm
 .section .text
-{% for isrdef in data["exception"] %}
+{% for isrdef in data["exception"]["ivdefs"] %}
 {% if isrdef["has_errcode"] %}
 {% if isrdef["has_errcode"] %}
-    isr_template {{ isrdef["index"] }}, no_error_code=0
+    isr_template {{ isrdef["iv"] }}, no_error_code=0
 {% else %}
 {% else %}
-    isr_template {{ isrdef["index"] }}, no_error_code=1
+    isr_template {{ isrdef["iv"] }}, no_error_code=1
 {% endif %}
 {% endfor %}
 {% endif %}
 {% endfor %}
index 01ab6391bd47d60d6cc26cc08a214da6b768c675..936263f4285758479b1cb05b9b40b92f8b2cf477 100644 (file)
@@ -1,3 +1,5 @@
+/* Generated from {{ data["template"] }}. Do NOT modify */
+
 #include "i386_intr.h"
 #include <lunaix/types.h>
 
 #include "i386_intr.h"
 #include <lunaix/types.h>
 
 
 #define DECLARE_ISR(iv) extern void _asm_isr##iv();
 
 
 #define DECLARE_ISR(iv) extern void _asm_isr##iv();
 
-#define ISR_INSTALL(idt, iv, isr)                                        \
-    _idt[iv] = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(0, IDT_INTERRUPT);   \
+#define ISR_INSTALL(idt, iv, isr, dpl)                                   \
+    _idt[iv] = ((ptr_t)isr & 0xffff0000) | IDT_ATTR(dpl, IDT_INTERRUPT); \
     _idt[iv] <<= 32;                                                     \
     _idt[iv] |= (KERNEL_CS << 16) | ((ptr_t)isr & 0x0000ffff);           \
 
 u64_t _idt[IDT_ENTRY];
 u16_t _idt_limit = sizeof(_idt) - 1;
 
     _idt[iv] <<= 32;                                                     \
     _idt[iv] |= (KERNEL_CS << 16) | ((ptr_t)isr & 0x0000ffff);           \
 
 u64_t _idt[IDT_ENTRY];
 u16_t _idt_limit = sizeof(_idt) - 1;
 
-{% for isrdef in data["exception"] -%}
-    DECLARE_ISR({{ isrdef["index"] }})
+{% for isrdef in data["exception"]["ivdefs"] -%}
+    DECLARE_ISR({{ isrdef["iv"] }})
 {% endfor %}
 
 void
 exception_install_handler()
 {
 {% endfor %}
 
 void
 exception_install_handler()
 {
-{% for isrdef in data["exception"] %}
-    ISR_INSTALL(_idt, {{ isrdef["index"] }}, _asm_isr{{ isrdef["index"] }})
+{% for isrdef in data["exception"]["ivdefs"] %}
+    ISR_INSTALL(_idt, {{ isrdef["iv"] }}, _asm_isr{{ isrdef["iv"] }}, {{ isrdef["dpl"] }})
 {% endfor %}
 }
\ No newline at end of file
 {% endfor %}
 }
\ No newline at end of file
index 9c2c9d589b056018497bf34e09cc2f9889464d80..04d7560c2b94de193780b1067c3bd5a1c832e856 100644 (file)
@@ -1,2 +1,3 @@
 i386_isrdef.c.j2 -> arch/i386/exceptions/i386_isrdef.c
 i386_isrdef.c.j2 -> arch/i386/exceptions/i386_isrdef.c
-i386_intrhnds.S.j2 -> arch/i386/exceptions/intrhnds.S
\ No newline at end of file
+i386_intrhnds.S.j2 -> arch/i386/exceptions/intrhnds.S
+mempart.h.j2 -> arch/i386/includes/sys/mm/mempart.h
\ No newline at end of file
diff --git a/lunaix-os/scripts/templates/i386/mempart.h.j2 b/lunaix-os/scripts/templates/i386/mempart.h.j2
new file mode 100644 (file)
index 0000000..1fb6f2c
--- /dev/null
@@ -0,0 +1,17 @@
+/* Physical Adress Space Partition */
+/* Generated from {{ data["template"] }}. Do NOT modify */
+
+{% for k, v in data["sys_mmap"]["granule"].items() %}
+#define MEM_{{ k.upper() }} {{ hex(v) }}UL
+{% endfor %}
+
+{% for region in data["sys_mmap"]["regions"] %}
+#define {{ region["name"].upper() }} {{ hex(region["start"]) }}UL
+#define {{ region["name"].upper() }}_SIZE {{ hex(region["size"]) }}UL
+{% if "stk_align" in region %}
+#define {{ region["name"].upper() }}_END {{ hex(align(region["start"] + region["size"] - 1, region["stk_align"])) }}UL
+{% else %}
+#define {{ region["name"].upper() }}_END {{ hex((region["start"] + region["size"] - 1)) }}UL
+{% endif %}
+
+{% endfor %}
\ No newline at end of file