diff --git a/.gitignore b/.gitignore index 8e24b65..39a13af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ -.idea -cmake-build-debug +.idea +cmake-build-debug +*.o +*.a +CMakeLists.txt +*.iso +*.elf +*.dmp diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c3d6a31..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8.4) -project(Workspace) - -include_directories(src/include) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - -file(GLOB_RECURSE SOURCE_FILES ./*.h ./*.c) - -add_executable(Workspace ${SOURCE_FILES}) \ No newline at end of file diff --git a/LICENSE b/LICENSE index 95073df..b71b600 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2018 secXsQuared - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +MIT License + +Copyright (c) 2018 secXsQuared + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile index 1176d28..96815f4 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,16 @@ -ASM := nasm -CC := /opt/x86_64-elf-gcc -LD := /opt/x86_64-elf-gcc -DUMP := /opt/x86_64-elf-objdump +CROSS_DIR = ~/opt/cross/bin +AS = nasm +CC = $(CROSS_DIR)/x86_64-elf-gcc +LD = $(CROSS_DIR)/x86_64-elf-gcc +DAS = $(CROSS_DIR)/x86_64-elf-objdump -LD_SCRIPT := linker.ld +INCLUDE_DIR = include +MK = mk -GRUB_CFG := grub.cfg +LD_SCRIPT = $(MK)/linker.ld +GRUB_CFG = $(MK)/grub.cfg -INCLUDE_DIR := include - -MK := mk - -C_WARNINGS := -Wall \ +C_WARNINGS = -Wall \ -Werror \ -Wextra \ -Wpedantic \ @@ -26,7 +25,7 @@ C_WARNINGS := -Wall \ -Wpointer-arith \ -Wno-comment -C_FLAGS := -std=c11 \ +C_FLAGS = -std=c11 \ -g \ -c \ -O2 \ @@ -41,22 +40,22 @@ C_FLAGS := -std=c11 \ $(C_WARNINGS) \ $(addprefix -I, $(INCLUDE_DIR)) -ASM_FLAGS := -w+all \ +AS_FLAGS = -w+all \ -f elf64 \ -F dwarf \ -g \ - $(addprefix -I, $(ASM_HEADER_DIRS)) + $(addprefix -I, $(INCLUDE_DIR)/) -LD_FLAGS := -lgcc \ +LD_FLAGS = -lgcc \ -nodefaultlibs \ -nostartfiles \ -nostdlib \ -Wl,-n \ -Wl,--build-id=none -COMP := -LINK := -COMPAS := -PACK := +COMP = $(CC) $(C_FLAGS) $^ -o $@ +COMPAS = $(AS) $(AS_FLAGS) $^ -o $@ +LINK = $(LD) $(LD_FLAGS) $^ -o $@ +DUMP = $(DAS) -M intel -D $^ > $@ -include Rules.mk \ No newline at end of file +include Rules.top \ No newline at end of file diff --git a/OVMF_x86-64_bios.bin b/OVMF_x86-64_bios.bin new file mode 100644 index 0000000..455e121 Binary files /dev/null and b/OVMF_x86-64_bios.bin differ diff --git a/Rules.mk b/Rules.mk deleted file mode 100644 index 139c449..0000000 --- a/Rules.mk +++ /dev/null @@ -1,14 +0,0 @@ -include $(MK)/prologue.mk - -#OBJ var holds all object files - -dir := $(d)/hal -include $(dir)/Rules.mk -dir := $(d)/kernel -include $(dir)/Rules.mk -dir := $(d)/lib -include $(dir)/Rules.mk - -TGT := - -include $(MK)/epilogue.mk \ No newline at end of file diff --git a/Rules.top b/Rules.top new file mode 100644 index 0000000..8ab0e54 --- /dev/null +++ b/Rules.top @@ -0,0 +1,49 @@ +include $(MK)/prologue.mk + +.DEFAULT_GOAL := all + +#OBJ var holds all object files + +dir := hal +include $(dir)/Rules.mk +dir := kernel +include $(dir)/Rules.mk +dir := lib +include $(dir)/Rules.mk +dir := test +include $(dir)/Rules.mk + +TGT := secxkrnl.elf +DMP := secxkrnl.dmp +ISO := secxkrnl.iso + +$(TGT): $(OBJ) + $(LINK) -T $(LD_SCRIPT) + +$(DMP): $(TGT) + $(DUMP) + +.PHONY: clean +clean: + rm $(OBJ) $(TGT) $(DMP) $(ISO) + +.PHONY: compile +compile: $(TGT) + +.PHONY: dump +dump: $(DMP) + +.PHONY: iso +iso: $(TGT) + mkdir -p temp/secX + mkdir -p temp/boot + mkdir -p temp/boot/grub + cp $(TGT) temp/secX/ + cp $(GRUB_CFG) temp/boot/grub/ + grub-mkrescue -o $(ISO) temp + rm -r temp + +.PHONY: all +all: compile dump iso + +include $(MK)/epilogue.mk \ No newline at end of file diff --git a/dbg.bat b/dbg.bat new file mode 100644 index 0000000..dc8ffea --- /dev/null +++ b/dbg.bat @@ -0,0 +1 @@ +qemu-system-x86_64 -bios OVMF_x86-64_bios.bin -cdrom secxkrnl.iso -s -S \ No newline at end of file diff --git a/gdbcmd b/gdbcmd new file mode 100644 index 0000000..84433aa --- /dev/null +++ b/gdbcmd @@ -0,0 +1,3 @@ +target remote localhost:1234 +symbol-file secxkrnl.elf +break *0x1003000 diff --git a/grub.cfg b/grub.cfg deleted file mode 100644 index 72644ad..0000000 --- a/grub.cfg +++ /dev/null @@ -1,3 +0,0 @@ -menuentry "secX" { - multiboot2 /secX/kernel.elf -} \ No newline at end of file diff --git a/hal/Rules.mk b/hal/Rules.mk index 30abf41..0cac8d3 100644 --- a/hal/Rules.mk +++ b/hal/Rules.mk @@ -13,7 +13,9 @@ SRCAS_$(d) := boot.asm \ cpu.asm \ intr.asm -OBJAS_$(d) := $(SRCAS_$(d):.c=.a) +SRCAS_$(d) := $(addprefix $(d)/, $(SRCAS_$(d))) + +OBJAS_$(d) := $(SRCAS_$(d):.asm=.a) $(OBJ_$(d)): %.o: %.c $(COMP) diff --git a/hal/boot.asm b/hal/boot.asm index 8bcd607..42b0c3f 100644 --- a/hal/boot.asm +++ b/hal/boot.asm @@ -11,9 +11,10 @@ MULTIBOOT_MAGIC_NUMBER equ 0xE85250D6 MULTIBOOT_ARCH equ 0 ; NASM does not like MULTIBOOT_CHECK_SUM equ (0xFFFFFFFF - (MULTIBOOT_MAGIC_NUMBER + MULTIBOOT_HEADER_SIZE + MULTIBOOT_ARCH) + 1) -MULTIBOOT_REQ_MINFO equ 4 +MULTIBOOT_REQ_LOADERNAME equ 2 MULTIBOOT_REQ_MMAP equ 6 -MULTIBOOT_REQ_APM equ 10 +MULTIBOOT_REQ_EFI_64 equ 12 +MULTIBOOT_REQ_EFI_MMAP equ 17 [SECTION .multiboot_header] [BITS 32] @@ -32,9 +33,10 @@ multiboot_info_tag: dw 0x1 ; type=1 dw 0x0 ; flag=0 dd MULTIBOOT_INFO_TAG_SIZE -;dd MULTIBOOT_REQ_MINFO +dd MULTIBOOT_REQ_LOADERNAME dd MULTIBOOT_REQ_MMAP -dd MULTIBOOT_REQ_APM +dd MULTIBOOT_REQ_EFI_64 +dd MULTIBOOT_REQ_EFI_MMAP MULTIBOOT_INFO_TAG_SIZE equ ($ - multiboot_info_tag) ;==================== ;MODULE ALIGNMENT TAG diff --git a/hal/intr.c b/hal/intr.c index c1364fb..289a821 100644 --- a/hal/intr.c +++ b/hal/intr.c @@ -14,6 +14,7 @@ static exc_handler_t _exc_handler_table[HAL_CORE_COUNT][IDT_ENTRY_NUM]; irql_t KABI hal_set_irql(irql_t irql) { + UNREFERENCED(irql) hal_assert(false,"Unimplemented function called."); return 0; } @@ -105,7 +106,7 @@ void KABI hal_deregister_exception_handler(uint32_t coreid, uint32_t index) return; } -static void KABI hal_interrupt_dispatcher(uint64_t int_vec, hal_interrupt_context_t *context) +void KABI hal_interrupt_dispatcher(uint64_t int_vec, hal_interrupt_context_t *context) { uint32_t coreid = hal_get_core_id(); if (_intr_handler_table[int_vec] == NULL) @@ -119,7 +120,7 @@ static void KABI hal_interrupt_dispatcher(uint64_t int_vec, hal_interrupt_contex return; } -static void KABI hal_exception_dispatcher(uint64_t exc_vec, hal_interrupt_context_t* context, uint64_t errorcode) +void KABI hal_exception_dispatcher(uint64_t exc_vec, hal_interrupt_context_t* context, uint64_t errorcode) { uint32_t coreid = hal_get_core_id(); if (_exc_handler_table[exc_vec] == NULL) @@ -133,7 +134,7 @@ static void KABI hal_exception_dispatcher(uint64_t exc_vec, hal_interrupt_contex return; } -static void KABI halp_populate_idt() +static void KABI halp_populate_idt(void) { hal_set_interrupt_handler(0, hal_interrupt_handler_0); hal_set_interrupt_handler(1, hal_interrupt_handler_1); @@ -439,6 +440,7 @@ int32_t KABI hal_interrupt_init(void) hal_read_msr(&ecx, &edx, &eax); apic_base_reg = ((uint64_t) edx << 32) + (uint64_t) eax; apic_base = apic_base_reg & lb_bit_field_mask(12, 35); + UNREFERENCED(apic_base); //hal_printf("APIC Base: 0x%X\n", apic_base); //hal_printf("APIC Enabled: %s\n", apic_base_reg & bit_mask_64(11) ? "Yes" : "No"); diff --git a/hal/mem.c b/hal/mem.c index da3cc87..cc681a1 100644 --- a/hal/mem.c +++ b/hal/mem.c @@ -106,7 +106,7 @@ void KABI hfree(void *ptr) return; } -static void KABI _hal_init_gdt() +static void KABI _hal_init_gdt(void) { uint32_t coreid = hal_get_core_id(); // get gdt ready @@ -135,7 +135,7 @@ static void KABI _hal_init_gdt() _gdt_ptrs[coreid].base = (uint64_t) &_gdts[coreid]; _gdt_ptrs[coreid].limit = GDT_ENTRY_NUM * GDT_ENTRY_SIZE - 1; hal_flush_gdt(&_gdt_ptrs[coreid], seg_selector(1, 0), seg_selector(2, 0)); -}; +} void KABI hal_mem_init() { diff --git a/hal/print.c b/hal/print.c index f1893d4..7b523aa 100644 --- a/hal/print.c +++ b/hal/print.c @@ -14,12 +14,12 @@ static uint64_t text_pos; -static void KABI hal_print_init() +void KABI hal_print_init(void) { text_pos = 0; } -static void KABI halp_print_scroll() +static void KABI halp_print_scroll(void) { lb_mem_move((void *) (0xb8000 + get_pos(1, 0) * 2), (void *) (0xb8000 + get_pos(0, 0) * 2), (80 * 24) * 2); return; @@ -139,10 +139,9 @@ void KABI hal_clear_screen(void) void KABI hal_vprintf(char const * format, va_list args) { - va_start(args, format); char buf[2] = {0, 0}; - int32_t d; - uint32_t u; + int64_t d; + uint64_t u; char* s; char c; for(;*format != '\0';format++) @@ -169,7 +168,7 @@ void KABI hal_vprintf(char const * format, va_list args) halp_print_str(s); break; case 'c': - c = va_arg(args, int64_t); + c = (char)va_arg(args, int64_t); buf[0] = c; halp_print_str(buf); break; diff --git a/include/hal/mem.h b/include/hal/mem.h index 2e27ad2..8facb50 100644 --- a/include/hal/mem.h +++ b/include/hal/mem.h @@ -98,6 +98,6 @@ void *KABI halloc(uint32_t size); void KABI hfree(void *ptr); -void KABI hal_mem_init(); +void KABI hal_mem_init(void); #endif \ No newline at end of file diff --git a/include/hal/print.h b/include/hal/print.h index aaa5643..5766ed4 100644 --- a/include/hal/print.h +++ b/include/hal/print.h @@ -8,8 +8,8 @@ void KABI hal_assert(uint32_t expression, char *message); void KABI hal_printf(const char *str, ...); -void KABI hal_clear_screen(); +void KABI hal_clear_screen(void); -void KABI hal_print_init(); +void KABI hal_print_init(void); #endif \ No newline at end of file diff --git a/include/kernel/ke/alloc.h b/include/kernel/ke/alloc.h index 926a915..af8a523 100644 --- a/include/kernel/ke/alloc.h +++ b/include/kernel/ke/alloc.h @@ -3,7 +3,7 @@ #include "type.h" -void KABI ke_alloc_init(); +void KABI ke_alloc_init(void); void* KABI ke_alloc(uint32_t size); diff --git a/include/kernel/ke/intr.h b/include/kernel/ke/intr.h index 3271b84..941e4e5 100644 --- a/include/kernel/ke/intr.h +++ b/include/kernel/ke/intr.h @@ -8,10 +8,8 @@ irql_t KABI ke_raise_irql(irql_t irql); irql_t KABI ke_lower_irql(irql_t irql); -int KABI ke_get_current_core(); +int KABI ke_get_current_core(void); -irql_t KABI ke_get_irql(); - -void KABI ke_halt_cpu(); +irql_t KABI ke_get_irql(void); #endif \ No newline at end of file diff --git a/include/kernel/rf/ref.h b/include/kernel/rf/ref.h index 3f66f56..0290e65 100644 --- a/include/kernel/rf/ref.h +++ b/include/kernel/rf/ref.h @@ -19,7 +19,7 @@ typedef struct // specifying where the allocations take place // -status_t KABI rf_reference_setup(); +status_t KABI rf_reference_setup(void); status_t KABI rf_reference_create(ref_node_t *ref, callback_func_t free_func); diff --git a/include/lib/sxtdlib.h b/include/lib/sxtdlib.h index c0e50a5..ee3748c 100644 --- a/include/lib/sxtdlib.h +++ b/include/lib/sxtdlib.h @@ -8,11 +8,11 @@ #include "type.h" -uint32_t KABI rand( void ); +uint32_t KABI lb_rand(void); -void KABI srand(uint32_t _seed ); +void KABI lb_srand(uint32_t _seed); -void KABI mrand(uint32_t max); +void KABI lb_mrand(uint32_t max); uint64_t KABI lb_str_len(char const *str); @@ -22,7 +22,7 @@ void KABI lb_mem_copy(void *src, void *dst, uint64_t size); void KABI lb_mem_move(void *src, void *dst, uint64_t size); -void KABI lb_mem_set(void *src, int8_t const val, uint64_t size); +void KABI lb_mem_set(void *src, uint8_t const val, uint64_t size); static inline uint64_t KABI lb_align_down(uint64_t val, uint64_t alignment) { @@ -61,32 +61,34 @@ static inline int32_t KABI lb_min_32(int32_t a, int32_t b) return (a) < (b) ? a : b; } -//static inline uint64_t KAPI round_up_power_of_2(uint64_t num) -//{ -// num--; -// num |= num >> 1; -// num |= num >> 2; -// num |= num >> 4; -// num |= num >> 8; -// num |= num >> 16; -// num |= num >> 32; -// num++; -// return (uint64_t)num; -//} -// -//static inline uint32_t KAPI log_base_2(uint64_t num) -//{ -// uint32_t result = 0; -// -// while (num >>= 1) -// { -// result++; -// } -// -// return result; -//} +/* +static inline uint64_t KAPI round_up_power_of_2(uint64_t num) +{ + num--; + num |= num >> 1; + num |= num >> 2; + num |= num >> 4; + num |= num >> 8; + num |= num >> 16; + num |= num >> 32; + num++; + return (uint64_t)num; +} -#define OBTAIN_STRUCT_ADDR(member_addr, struct_name, member_name) ((struct_name*)((void*)(member_addr)-(void*)(&(((struct_name*)0)->member_name)))) +static inline uint32_t KAPI log_base_2(uint64_t num) +{ + uint32_t result = 0; + + while (num >>= 1) + { + result++; + } + + return result; +} +*/ + +#define OBTAIN_STRUCT_ADDR(member_addr, struct_name, member_name) ((struct_name*)((uintptr_t)(member_addr) - (uintptr_t)(&(((struct_name*)0)->member_name)))) static inline uint64_t KABI lb_bit_mask(uint32_t bit) { diff --git a/include/test/driver.h b/include/test/driver.h index 8563333..a45382d 100644 --- a/include/test/driver.h +++ b/include/test/driver.h @@ -5,7 +5,7 @@ void KABI test_begin(char *name); -void KABI test_end(); +void KABI test_end(void); void *KABI talloc(uint32_t size); diff --git a/kernel/ke/Rules.mk b/kernel/ke/Rules.mk index c854f2b..c4fa70a 100644 --- a/kernel/ke/Rules.mk +++ b/kernel/ke/Rules.mk @@ -1,6 +1,6 @@ include $(MK)/prologue.mk -SRC_$(d) := allo.c \ +SRC_$(d) := alloc.c \ assert.c \ atomic.c \ boot.c \ diff --git a/kernel/ke/alloc.c b/kernel/ke/alloc.c index 15a5595..c2ff01e 100644 --- a/kernel/ke/alloc.c +++ b/kernel/ke/alloc.c @@ -7,7 +7,7 @@ static _Bool alloc_initialized; static uint8_t alloc_heap[K_KERNEL_HEAP_SIZE]; -void KABI ke_alloc_init() +void KABI ke_alloc_init(void) { if (!alloc_initialized) { diff --git a/kernel/ke/intr.c b/kernel/ke/intr.c index 80c2ae3..4202ada 100644 --- a/kernel/ke/intr.c +++ b/kernel/ke/intr.c @@ -14,12 +14,12 @@ irql_t KABI ke_lower_irql(irql_t irql) return hal_set_irql(irql); } -irql_t KABI ke_get_irql() +irql_t KABI ke_get_irql(void) { return hal_get_irql(); } -int KABI ke_get_current_core() +int KABI ke_get_current_core(void) { return hal_get_core_id(); } \ No newline at end of file diff --git a/kernel/rf/ref.c b/kernel/rf/ref.c index f5cc608..6e14b65 100644 --- a/kernel/rf/ref.c +++ b/kernel/rf/ref.c @@ -51,7 +51,7 @@ static handle_node_t *rfp_search_handle_node(handle_t handle) return result == NULL ? NULL : OBTAIN_STRUCT_ADDR(result, handle_node_t, tree_node); } -status_t KABI rf_reference_setup() +status_t KABI rf_reference_setup(void) { if (!initialized) { diff --git a/lib/salloc.c b/lib/salloc.c index ab12822..0c91aaf 100644 --- a/lib/salloc.c +++ b/lib/salloc.c @@ -2,8 +2,6 @@ * Distributed under GPL license * See COPYING under root for details */ - -#include "abi.h" #include "type.h" #include "lib/sxtdlib.h" diff --git a/lib/sxtdlib.c b/lib/sxtdlib.c index 11ab991..afcee6b 100644 --- a/lib/sxtdlib.c +++ b/lib/sxtdlib.c @@ -4,7 +4,6 @@ */ #include "type.h" -#include "abi.h" #include "lib/sxtdlib.h" void KABI lb_mem_copy(void *src, void *dst, uint64_t size) @@ -22,7 +21,7 @@ void KABI lb_mem_copy(void *src, void *dst, uint64_t size) return; } -void KABI lb_mem_set(void *src, int8_t const val, uint64_t size) +void KABI lb_mem_set(void *src, uint8_t const val, uint64_t size) { if (src == NULL) { @@ -30,7 +29,8 @@ void KABI lb_mem_set(void *src, int8_t const val, uint64_t size) } while (size--) { - *((int8_t *) src++) = val; + *(uint8_t *)src = val; + src = (void*)((uintptr_t)src + 1); } return; } @@ -43,13 +43,16 @@ void KABI lb_mem_move(void *src, void *dst, uint64_t size) } if (src >= dst) { - return lb_mem_copy(src, dst, size); + lb_mem_copy(src, dst, size); + return; } - src += size; - dst += size; + src = (void*)((uintptr_t)src + size - 1); + dst = (void*)((uintptr_t)dst + size - 1); while (size--) { - *((char *) --dst) = *((char *) --src); + *(char*)dst = *(char*)src; + dst = (void*)((uintptr_t)dst - 1); + src = (void*)((uintptr_t)src - 1); } return; } @@ -60,18 +63,18 @@ void KABI lb_mem_move(void *src, void *dst, uint64_t size) static uint32_t seed = 1; static uint32_t max = 16777215; -uint32_t KABI rand(void) +uint32_t KABI lb_rand(void) { seed = seed * 1103512986 + 29865; return (unsigned int) (seed / 65536) % (max + 1); } -void KABI srand(uint32_t _seed) +void KABI lb_srand(uint32_t _seed) { seed = _seed; } -void KABI mrand(uint32_t _max) +void KABI lb_mrand(uint32_t _max) { max = _max; } @@ -95,7 +98,7 @@ uint64_t KABI lb_str_len(char const *str) return length; } -uint64_t KABI rtl_str_cmp(char const *str1, char const *str2) +uint64_t KABI lb_str_cmp(char const *str1, char const *str2) { if (str1 == NULL || str2 == NULL) { diff --git a/misc/balloc/balloc.c b/misc/balloc/balloc.c deleted file mode 100644 index 5076682..0000000 --- a/misc/balloc/balloc.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2016 secXsQuared - * Distributed under GPL license - * See COPYING under root for details - */ - -#include "balloc.h" -#include "std_lib.h" -#include "bit_ops.h" - -int32_t balloc_init(balloc_desc_t *desc, - uint64_t base, - uint64_t end, - uint64_t page_size, - balloc_alloc_func alloc, - balloc_free_func free, - balloc_lock_func lock, - balloc_unlock_func unlock) -{ - if(desc == NULL || base >= end || page_size == 0 || alloc == 0 - || free == 0 || lock == 0 || unlock == 0) - return BALLOC_STATUS_INVALID_ARGUMENTS; - - if(((end - base) % page_size) != 0) - return BALLOC_STATUS_INVALID_ALIGNMENT; - - desc->alloc = alloc; - desc->free = free; - desc->lock = lock; - desc->unlock = unlock; - - desc->base = base; - desc->page_size = page_size; - uint64_t quot = (end-base) / page_size; - uint32_t order = log_base_2(quot); - if(quot & bit_mask_64(order) != 0) - { - order++; - } - desc->order = order; - - // allocate linked lists and bit maps - desc->free_lists = (linked_list_t*)desc->alloc((order + 1) * sizeof(linked_list_t)); - if(desc->free_lists == NULL || desc->bit_map == NULL) - return BALLOC_STATUS_CANT_ALLOC_MEM; - - return BALLOC_STATUS_SUCCESS; -} - -int32_t balloc_alloc(balloc_desc_t* desc, uint32_t page_num, uint64_t* out) -{ - -} - -int32_t balloc_free(balloc_desc_t* desc, uint64_t addr) -{ - -} - -int32_t balloc_mark_used(balloc_desc_t* desc, uint64_t start, uint64_t end) -{ - -} - -int32_t balloc_mark_free(balloc_desc_t* desc, uint64_t start, uint64_t end) -{ - -} \ No newline at end of file diff --git a/misc/balloc/inc/balloc.h b/misc/balloc/inc/balloc.h deleted file mode 100644 index 541fb13..0000000 --- a/misc/balloc/inc/balloc.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _BALLOC_H_ -#define _BALLOC_H_ - -#include "linked_list.h" -#include "avl_tree.h" - -/* - * A tree allocator for page-size allocation - * All - */ - -#define BALLOC_STATUS_SUCCESS 0 -#define BALLOC_STATUS_INVALID_ARGUMENTS 1 -#define BALLOC_STATUS_NO_AVAILABLE_MEM 2 -#define BALLOC_STATUS_CANT_ALLOC_MEM 3 -#define BALLOC_STATUS_INVALID_ALIGNMENT 4 - -typedef void *(*balloc_alloc_func)(uint64_t size); - -typedef void (*balloc_free_func)(void *ptr); - -typedef void (*balloc_lock_func)(void); - -typedef void (*balloc_unlock_func)(void); - -typedef struct -{ - uint64_t base; - uint64_t order; - uint64_t page_size; - - linked_list_t *free_lists; - uint8_t *bit_map; - - balloc_alloc_func alloc; - balloc_free_func free; - balloc_lock_func lock; - balloc_unlock_func unlock; -} balloc_desc_t; - - -int32_t balloc_init(balloc_desc_t *desc, - uint64_t base, - uint64_t end, - uint64_t page_size, - balloc_alloc_func alloc, - balloc_free_func free, - balloc_lock_func lock, - balloc_unlock_func unlock); - -int32_t balloc_alloc(balloc_desc_t* desc, uint32_t page_num, uint64_t* out); - -int32_t balloc_free(balloc_desc_t* desc, uint64_t addr); - -int32_t balloc_mark_used(balloc_desc_t* desc, uint64_t start, uint64_t end); - -int32_t balloc_mark_free(balloc_desc_t* desc, uint64_t start, uint64_t end); - -#endif \ No newline at end of file diff --git a/misc/bochs/bochs.bxrc b/misc/bochs/bochs.bxrc deleted file mode 100644 index 611dfe1..0000000 --- a/misc/bochs/bochs.bxrc +++ /dev/null @@ -1,1226 +0,0 @@ -# You may now use double quotes around pathnames, in case -# your pathname includes spaces. - -#======================================================================= -# PLUGIN_CTRL: -# Controls the presence of optional device plugins. These plugins are loaded -# directly with this option and some of them install a config option that is -# only available when the plugin device is loaded. The value "1" means to load -# the plugin and "0" will unload it (if loaded before). -# -# These plugins will be loaded by default (if present): 'biosdev', 'extfpuirq', -# 'gameport', 'iodebug','parallel', 'serial', 'speaker' and 'unmapped'. -# -# These plugins are also supported, but they are usually loaded directly with -# their bochsrc option: 'e1000', 'es1370', 'ne2k', 'pcidev', 'pcipnic', 'sb16', -# 'usb_ohci', 'usb_uhci', 'usb_xhci' and 'voodoo'. -#======================================================================= -#plugin_ctrl: unmapped=0, e1000=1 # unload 'unmapped' and load 'e1000' - -#======================================================================= -# CONFIG_INTERFACE -# -# The configuration interface is a series of menus or dialog boxes that -# allows you to change all the settings that control Bochs's behavior. -# Depending on the platform there are up to 3 choices of configuration -# interface: a text mode version called "textconfig" and two graphical versions -# called "win32config" and "wx". The text mode version uses stdin/stdout and -# is always compiled in, unless Bochs is compiled for wx only. The choice -# "win32config" is only available on win32 and it is the default there. -# The choice "wx" is only available when you use "--with-wx" on the configure -# command. If you do not write a config_interface line, Bochs will -# choose a default for you. -# -# NOTE: if you use the "wx" configuration interface, you must also use -# the "wx" display library. -#======================================================================= -#config_interface: textconfig -#config_interface: win32config -#config_interface: wx - -#======================================================================= -# DISPLAY_LIBRARY -# -# The display library is the code that displays the Bochs VGA screen. Bochs -# has a selection of about 10 different display library implementations for -# different platforms. If you run configure with multiple --with-* options, -# the display_library command lets you choose which one you want to run with. -# If you do not write a display_library line, Bochs will choose a default for -# you. -# -# The choices are: -# x use X windows interface, cross platform -# win32 use native win32 libraries -# carbon use Carbon library (for MacOS X) -# macintosh use MacOS pre-10 -# amigaos use native AmigaOS libraries -# sdl use SDL 1.2.x library, cross platform -# sdl2 use SDL 2.x library, cross platform -# svga use SVGALIB library for Linux, allows graphics without X11 -# term text only, uses curses/ncurses library, cross platform -# rfb provides an interface to AT&T's VNC viewer, cross platform -# vncsrv use LibVNCServer for extended RFB(VNC) support -# wx use wxWidgets library, cross platform -# nogui no display at all -# -# NOTE: if you use the "wx" configuration interface, you must also use -# the "wx" display library. -# -# Specific options: -# Some display libraries now support specific options to control their -# behaviour. These options are supported by more than one display library: -# -# "gui_debug" - use GTK debugger gui (sdl, sdl2, x) / Win32 debugger gui (sdl, -# sdl2, win32) -# "hideIPS" - disable IPS output in status bar (rfb, sdl, sdl2, vncsrv, -# win32, wx, x) -# "nokeyrepeat" - turn off host keyboard repeat (sdl, sdl2, win32, x) -# "timeout" - time (in seconds) to wait for client (rfb, vncsrv) -# -# See the examples below for other currently supported options. -#======================================================================= -#display_library: amigaos -#display_library: carbon -#display_library: macintosh -#display_library: nogui -#display_library: rfb -display_library: sdl, options="gui_debug" -#display_library: sdl2 -#display_library: term -#display_library: vncsrv -#display_library: win32 -#display_library: wx -#display_library: x - -#======================================================================= -# CPU: -# This defines cpu-related parameters inside Bochs: -# -# MODEL: -# Selects CPU configuration to emulate from pre-defined list of all -# supported configurations. When this option is used and the value -# is different from 'bx_generic', the parameters of the CPUID option -# have no effect anymore. -# -# CPU configurations that can be selected: -# ----------------------------------------------------------------- -# pentium Intel Pentium (P54C) -# pentium_mmx Intel Pentium MMX -# amd_k6_2_chomper AMD-K6(tm) 3D processor (Chomper) -# p2_klamath Intel Pentium II (Klamath) -# p3_katmai Intel Pentium III (Katmai) -# p4_willamette Intel(R) Pentium(R) 4 (Willamette) -# core_duo_t2400_yonah Intel(R) Core(TM) Duo CPU T2400 (Yonah) -# atom_n270 Intel(R) Atom(TM) CPU N270 -# p4_prescott_celeron_336 Intel(R) Celeron(R) 336 (Prescott) -# athlon64_clawhammer AMD Athlon(tm) 64 Processor 2800+ (Clawhammer) -# athlon64_venice AMD Athlon(tm) 64 Processor 3000+ (Venice) -# turion64_tyler AMD Turion(tm) 64 X2 Mobile TL-60 (Tyler) -# phenom_8650_toliman AMD Phenom X3 8650 (Toliman) -# core2_penryn_t9600 Intel Mobile Core 2 Duo T9600 (Penryn) -# corei5_lynnfield_750 Intel(R) Core(TM) i5 750 (Lynnfield) -# corei5_arrandale_m520 Intel(R) Core(TM) i5 M 520 (Arrandale) -# zambezi AMD FX(tm)-4100 Quad-Core Processor (Zambezi) -# trinity_apu AMD A8-5600K APU (Trinity) -# corei7_sandy_bridge_2600k Intel(R) Core(TM) i7-2600K (Sandy Bridge) -# corei7_ivy_bridge_3770k Intel(R) Core(TM) i7-3770K CPU (Ivy Bridge) -# corei7_haswell_4770 Intel(R) Core(TM) i7-4770 CPU (Haswell) -# broadwell_ult Intel(R) Processor 5Y70 CPU (Broadwell) -# -# COUNT: -# Set the number of processors:cores per processor:threads per core when -# Bochs is compiled for SMP emulation. Bochs currently supports up to -# 14 threads (legacy APIC) or 254 threads (xAPIC or higher) running -# simultaniosly. If Bochs is compiled without SMP support, it won't accept -# values different from 1. -# -# QUANTUM: -# Maximum amount of instructions allowed to execute by processor before -# returning control to another cpu. This option exists only in Bochs -# binary compiled with SMP support. -# -# RESET_ON_TRIPLE_FAULT: -# Reset the CPU when triple fault occur (highly recommended) rather than -# PANIC. Remember that if you trying to continue after triple fault the -# simulation will be completely bogus ! -# -# CPUID_LIMIT_WINNT: -# Determine whether to limit maximum CPUID function to 2. This mode is -# required to workaround WinNT installation and boot issues. -# -# MSRS: -# Define path to user CPU Model Specific Registers (MSRs) specification. -# See example in msrs.def. -# -# IGNORE_BAD_MSRS: -# Ignore MSR references that Bochs does not understand; print a warning -# message instead of generating #GP exception. This option is enabled -# by default but will not be avaiable if configurable MSRs are enabled. -# -# MWAIT_IS_NOP: -# When this option is enabled MWAIT will not put the CPU into a sleep state. -# This option exists only if Bochs compiled with --enable-monitor-mwait. -# -# IPS: -# Emulated Instructions Per Second. This is the number of IPS that bochs -# is capable of running on your machine. You can recompile Bochs with -# --enable-show-ips option enabled, to find your host's capability. -# Measured IPS value will then be logged into your log file or shown -# in the status bar (if supported by the gui). -# -# IPS is used to calibrate many time-dependent events within the bochs -# simulation. For example, changing IPS affects the frequency of VGA -# updates, the duration of time before a key starts to autorepeat, and -# the measurement of BogoMips and other benchmarks. -# -# Examples: -# -# Bochs Machine/Compiler Mips -# ______________________________________________________________________ -# 2.4.6 3.4Ghz Intel Core i7 2600 with Win7x64/g++ 4.5.2 85 to 95 Mips -# 2.3.7 3.2Ghz Intel Core 2 Q9770 with WinXP/g++ 3.4 50 to 55 Mips -# 2.3.7 2.6Ghz Intel Core 2 Duo with WinXP/g++ 3.4 38 to 43 Mips -# 2.2.6 2.6Ghz Intel Core 2 Duo with WinXP/g++ 3.4 21 to 25 Mips -# 2.2.6 2.1Ghz Athlon XP with Linux 2.6/g++ 3.4 12 to 15 Mips -#======================================================================= -cpu: count=1, ips=4000000, reset_on_triple_fault=1, ignore_bad_msrs=1 - -#======================================================================= -# CPUID: -# -# This defines features and functionality supported by Bochs emulated CPU. -# The option has no offect if CPU model was selected in CPU option. -# -# MMX: -# Select MMX instruction set support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5. -# -# APIC: -# Select APIC configuration (LEGACY/XAPIC/XAPIC_EXT/X2APIC). -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 5. -# -# SEP: -# Select SYSENTER/SYSEXIT instruction set support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# SIMD: -# Select SIMD instructions support. -# Any of NONE/SSE/SSE2/SSE3/SSSE3/SSE4_1/SSE4_2/AVX/AVX2/AVX512 -# could be selected. -# -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# The AVX choises exists only if Bochs compiled with --enable-avx option. -# -# SSE4A: -# Select AMD SSE4A instructions support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# MISALIGNED_SSE: -# Select AMD Misaligned SSE mode support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# AES: -# Select AES instruction set support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# SHA: -# Select SHA instruction set support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# MOVBE: -# Select MOVBE Intel(R) Atom instruction support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# ADX: -# Select ADCX/ADOX instructions support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# XSAVE: -# Select XSAVE extensions support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# XSAVEOPT: -# Select XSAVEOPT instruction support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# AVX_F16C: -# Select AVX float16 convert instructions support. -# This option exists only if Bochs compiled with --enable-avx option. -# -# AVX_FMA: -# Select AVX fused multiply add (FMA) instructions support. -# This option exists only if Bochs compiled with --enable-avx option. -# -# BMI: -# Select BMI1/BMI2 instructions support. -# This option exists only if Bochs compiled with --enable-avx option. -# -# XOP: -# Select AMD XOP instructions support. -# This option exists only if Bochs compiled with --enable-avx option. -# -# FMA4: -# Select AMD four operand FMA instructions support. -# This option exists only if Bochs compiled with --enable-avx option. -# -# TBM: -# Select AMD Trailing Bit Manipulation (TBM) instructions support. -# This option exists only if Bochs compiled with --enable-avx option. -# -# X86-64: -# Enable x86-64 and long mode support. -# This option exists only if Bochs compiled with x86-64 support. -# -# 1G_PAGES: -# Enable 1G page size support in long mode. -# This option exists only if Bochs compiled with x86-64 support. -# -# PCID: -# Enable Process-Context Identifiers (PCID) support in long mode. -# This option exists only if Bochs compiled with x86-64 support. -# -# FSGSBASE: -# Enable GS/GS BASE access instructions support in long mode. -# This option exists only if Bochs compiled with x86-64 support. -# -# SMEP: -# Enable Supervisor Mode Execution Protection (SMEP) support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# SMAP: -# Enable Supervisor Mode Access Prevention (SMAP) support. -# This option exists only if Bochs compiled with BX_CPU_LEVEL >= 6. -# -# MWAIT: -# Select MONITOR/MWAIT instructions support. -# This option exists only if Bochs compiled with --enable-monitor-mwait. -# -# VMX: -# Select VMX extensions emulation support. -# This option exists only if Bochs compiled with --enable-vmx option. -# -# SVM: -# Select AMD SVM (Secure Virtual Machine) extensions emulation support. -# This option exists only if Bochs compiled with --enable-svm option. -# -# VENDOR_STRING: -# Set the CPUID vendor string returned by CPUID(0x0). This should be a -# twelve-character ASCII string. -# -# BRAND_STRING: -# Set the CPUID vendor string returned by CPUID(0x80000002 .. 0x80000004). -# This should be at most a forty-eight-character ASCII string. -# -# LEVEL: -# Set emulated CPU level information returned by CPUID. Default value is -# determined by configure option --enable-cpu-level. Currently supported -# values are 5 (for Pentium and similar processors) and 6 (for P6 and -# later processors). -# -# FAMILY: -# Set model information returned by CPUID. Default family value determined -# by configure option --enable-cpu-level. -# -# MODEL: -# Set model information returned by CPUID. Default model value is 3. -# -# STEPPING: -# Set stepping information returned by CPUID. Default stepping value is 3. -#======================================================================= -#cpuid: x86_64=1, mmx=1, sep=1, simd=sse4_2, apic=xapic, aes=1, movbe=1, xsave=1 -#cpuid: family=6, model=0x1a, stepping=5 -cpuid: mmx=1, sse=sse2, sep=1, aes=0, xsave=0, movbe=0, 1g_pages=1, pcid=0 fsgsbase=0 -cpuid: stepping=3, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU " - - -#======================================================================= -# MEMORY -# Set the amount of physical memory you want to emulate. -# -# GUEST: -# Set amount of guest physical memory to emulate. The default is 32MB, -# the maximum amount limited only by physical address space limitations. -# -# HOST: -# Set amount of host memory you want to allocate for guest RAM emulation. -# It is possible to allocate less memory than you want to emulate in guest -# system. This will fake guest to see the non-existing memory. Once guest -# system touches new memory block it will be dynamically taken from the -# memory pool. You will be warned (by FATAL PANIC) in case guest already -# used all allocated host memory and wants more. -# -#======================================================================= -memory: guest=512, host=256 - -#======================================================================= -# ROMIMAGE: -# The ROM BIOS controls what the PC does when it first powers on. -# Normally, you can use a precompiled BIOS in the source or binary -# distribution called BIOS-bochs-latest. The default ROM BIOS is usually loaded -# starting at address 0xfffe0000, and it is exactly 128k long. The legacy -# version of the Bochs BIOS is usually loaded starting at address 0xffff0000, -# and it is exactly 64k long. -# You can use the environment variable $BXSHARE to specify the location -# of the BIOS. -# The usage of external large BIOS images (up to 512k) at memory top is -# now supported, but we still recommend to use the BIOS distributed with Bochs. -# The start address is optional, since it can be calculated from image size. -#======================================================================= -romimage: file=$BXSHARE/BIOS-bochs-latest -#romimage: file=$BXSHARE/bios.bin-1.7.5 # http://www.seabios.org/SeaBIOS -#romimage: file=mybios.bin, address=0xfff80000 # 512k at memory top - -#======================================================================= -# VGAROMIMAGE -# You now need to load a VGA ROM BIOS into C0000. -#======================================================================= -#vgaromimage: file=bios/VGABIOS-elpin-2.40 -vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest -#vgaromimage: file=bios/VGABIOS-lgpl-latest-cirrus - -#======================================================================= -# OPTROMIMAGE[1-4]: -# You may now load up to 4 optional ROM images. Be sure to use a -# read-only area, typically between C8000 and EFFFF. These optional -# ROM images should not overwrite the rombios (located at -# F0000-FFFFF) and the videobios (located at C0000-C7FFF). -# Those ROM images will be initialized by the bios if they contain -# the right signature (0x55AA) and a valid checksum. -# It can also be a convenient way to upload some arbitrary code/data -# in the simulation, that can be retrieved by the boot loader -#======================================================================= -#optromimage1: file=optionalrom.bin, address=0xd0000 -#optromimage2: file=optionalrom.bin, address=0xd1000 -#optromimage3: file=optionalrom.bin, address=0xd2000 -#optromimage4: file=optionalrom.bin, address=0xd3000 - -#optramimage1: file=/path/file1.img, address=0x0010000 -#optramimage2: file=/path/file2.img, address=0x0020000 -#optramimage3: file=/path/file3.img, address=0x0030000 -#optramimage4: file=/path/file4.img, address=0x0040000 - -#======================================================================= -# VGA: -# This defines parameters related to the VGA display -# -# EXTENSION -# Here you can specify the display extension to be used. With the value -# 'none' you can use standard VGA with no extension. Other supported -# values are 'vbe' for Bochs VBE and 'cirrus' for Cirrus SVGA support. -# -# UPDATE_FREQ -# This parameter specifies the number of display updates per second. -# The VGA update timer now uses the realtime engine and the default -# value is 5. This parameter can be changed at runtime. -# -# REALTIME -# If set to 1, the VGA timer is based on realtime, otherwise it is based -# on the ips setting. If the host is slow (low ips, update_freq) and the -# guest uses HLT appropriately, setting this to 0 and "clock: sync=none" -# may improve the responsiveness of the guest GUI when the guest is -# otherwise idle. The default value is 1. -# -# Examples: -# vga: extension=cirrus, update_freq=10 -#======================================================================= -#vga: extension=vbe, update_freq=5, realtime=1 - -#======================================================================= -# VOODOO: -# This defines the Voodoo Graphics emulation (experimental). Currently -# supported models are 'voodoo1' and 'voodoo2'. The Voodoo2 support is -# not yet complete. -# -# Examples: -# voodoo: enabled=1, model=voodoo1 -#======================================================================= -#voodoo: enabled=1, model=voodoo1 - -#======================================================================= -# KEYBOARD: -# This defines parameters related to the emulated keyboard -# -# TYPE: -# Type of keyboard return by a "identify keyboard" command to the -# keyboard controller. It must be one of "xt", "at" or "mf". -# Defaults to "mf". It should be ok for almost everybody. A known -# exception is french macs, that do have a "at"-like keyboard. -# -# SERIAL_DELAY: -# Approximate time in microseconds that it takes one character to -# be transferred from the keyboard to controller over the serial path. -# -# PASTE_DELAY: -# Approximate time in microseconds between attempts to paste -# characters to the keyboard controller. This leaves time for the -# guest os to deal with the flow of characters. The ideal setting -# depends on how your operating system processes characters. The -# default of 100000 usec (.1 seconds) was chosen because it works -# consistently in Windows. -# If your OS is losing characters during a paste, increase the paste -# delay until it stops losing characters. -# -# KEYMAP: -# This enables a remap of a physical localized keyboard to a -# virtualized us keyboard, as the PC architecture expects. -# -# USER_SHORTCUT: -# This defines the keyboard shortcut to be sent when you press the "user" -# button in the headerbar. The shortcut string is a combination of maximum -# 3 key names (listed below) separated with a '-' character. -# Valid key names: -# "alt", "bksl", "bksp", "ctrl", "del", "down", "end", "enter", "esc", -# "f1", ... "f12", "home", "ins", "left", "menu", "minus", "pgdwn", "pgup", -# "plus", "power", "print", "right", "scrlck", "shift", "space", "tab", "up" -# and "win". - -# Examples: -# keyboard: type=mf, serial_delay=200, paste_delay=100000 -# keyboard: keymap=gui/keymaps/x11-pc-de.map -# keyboard: user_shortcut=ctrl-alt-del -#======================================================================= -#keyboard: type=mf, serial_delay=250 - -#======================================================================= -# MOUSE: -# This defines parameters for the emulated mouse type, the initial status -# of the mouse capture and the runtime method to toggle it. -# -# TYPE: -# With the mouse type option you can select the type of mouse to emulate. -# The default value is 'ps2'. The other choices are 'imps2' (wheel mouse -# on PS/2), 'serial', 'serial_wheel', 'serial_msys' (one com port requires -# setting 'mode=mouse') and 'bus' (if present). To connect a mouse to an -# USB port, see the 'usb_uhci', 'usb_ohci' or 'usb_xhci' options (requires -# PCI and USB support). -# -# ENABLED: -# The Bochs gui creates mouse "events" unless the 'enabled' option is -# set to 0. The hardware emulation itself is not disabled by this. -# Unless you have a particular reason for enabling the mouse by default, -# it is recommended that you leave it off. You can also toggle the mouse -# usage at runtime (RFB, SDL, Win32, wxWidgets and X11 - see below). -# -# TOGGLE: -# The default method to toggle the mouse capture at runtime is to press the -# CTRL key and the middle mouse button ('ctrl+mbutton'). This option allows -# to change the method to 'ctrl+f10' (like DOSBox), 'ctrl+alt' (like QEMU) -# or 'f12' (replaces win32 'legacyF12' option). -# -# Examples: -# mouse: enabled=1 -# mouse: type=imps2, enabled=1 -# mouse: type=serial, enabled=1 -# mouse: enabled=0, toggle=ctrl+f10 -#======================================================================= -mouse: enabled=0 - -#======================================================================= -# PCI: -# This option controls the presence of a PCI chipset in Bochs. Currently it only -# supports the i430FX and i440FX chipsets. You can also specify the devices -# connected to PCI slots. Up to 5 slots are available. For these combined PCI/ISA -# devices assigning to slot is mandatory if you want to emulate the PCI model: -# cirrus, ne2k and pcivga. These PCI-only devices are also supported, but they -# are auto-assigned if you don't use the slot configuration: e1000, es1370, -# pcidev, pcipnic, usb_ohci, usb_xhci and voodoo. -# -# Example: -# pci: enabled=1, chipset=i440fx, slot1=pcivga, slot2=ne2k -#======================================================================= -#pci: enabled=1, chipset=i440fx - -#======================================================================= -# CLOCK: -# This defines the parameters of the clock inside Bochs: -# -# SYNC: -# This defines the method how to synchronize the Bochs internal time -# with realtime. With the value 'none' the Bochs time relies on the IPS -# value and no host time synchronization is used. The 'slowdown' method -# sacrifices performance to preserve reproducibility while allowing host -# time correlation. The 'realtime' method sacrifices reproducibility to -# preserve performance and host-time correlation. -# It is possible to enable both synchronization methods. -# -# RTC_SYNC: -# If this option is enabled together with the realtime synchronization, -# the RTC runs at realtime speed. This feature is disabled by default. -# -# TIME0: -# Specifies the start (boot) time of the virtual machine. Use a time -# value as returned by the time(2) system call or a string as returned -# by the ctime(3) system call. If no time0 value is set or if time0 -# equal to 1 (special case) or if time0 equal 'local', the simulation -# will be started at the current local host time. If time0 equal to 2 -# (special case) or if time0 equal 'utc', the simulation will be started -# at the current utc time. -# -# Syntax: -# clock: sync=[none|slowdown|realtime|both], time0=[timeValue|local|utc] -# -# Example: -# clock: sync=none, time0=local # Now (localtime) -# clock: sync=slowdown, time0=315529200 # Tue Jan 1 00:00:00 1980 -# clock: sync=none, time0="Mon Jan 1 00:00:00 1990" # 631148400 -# clock: sync=realtime, time0=938581955 # Wed Sep 29 07:12:35 1999 -# clock: sync=realtime, time0="Sat Jan 1 00:00:00 2000" # 946681200 -# clock: sync=none, time0=1 # Now (localtime) -# clock: sync=none, time0=utc # Now (utc/gmt) -# -# Default value are sync=none, rtc_sync=0, time0=local -#======================================================================= -#clock: sync=none, time0=local - -#======================================================================= -# CMOSIMAGE: -# This defines image file that can be loaded into the CMOS RAM at startup. -# The rtc_init parameter controls whether initialize the RTC with values stored -# in the image. By default the time0 argument given to the clock option is used. -# With 'rtc_init=image' the image is the source for the initial time. -# -# Example: -# cmosimage: file=cmos.img, rtc_init=image -#======================================================================= -#cmosimage: file=cmos.img, rtc_init=time0 - -#======================================================================= -# private_colormap: Request that the GUI create and use it's own -# non-shared colormap. This colormap will be used -# when in the bochs window. If not enabled, a -# shared colormap scheme may be used. Not implemented -# on all GUI's. -# -# Examples: -# private_colormap: enabled=1 -# private_colormap: enabled=0 -#======================================================================= -private_colormap: enabled=0 - -#======================================================================= -# FLOPPYA: -# Point this to pathname of floppy image file or device -# This should be of a bootable floppy(image/device) if you're -# booting from 'a' (or 'floppy'). -# -# You can set the initial status of the media to 'ejected' or 'inserted'. -# floppya: 2_88=path, status=ejected (2.88M 3.5" media) -# floppya: 1_44=path, status=inserted (1.44M 3.5" media) -# floppya: 1_2=path, status=ejected (1.2M 5.25" media) -# floppya: 720k=path, status=inserted (720K 3.5" media) -# floppya: 360k=path, status=inserted (360K 5.25" media) -# floppya: 320k=path, status=inserted (320K 5.25" media) -# floppya: 180k=path, status=inserted (180K 5.25" media) -# floppya: 160k=path, status=inserted (160K 5.25" media) -# floppya: image=path, status=inserted (guess media type from image size) -# floppya: 1_44=vvfat:path, status=inserted (use directory as VFAT media) -# floppya: type=1_44 (1.44M 3.5" floppy drive, no media) -# -# The path should be the name of a disk image file. On Unix, you can use a raw -# device name such as /dev/fd0 on Linux. On win32 platforms, use drive letters -# such as a: or b: as the path. The parameter 'image' works with image files -# only. In that case the size must match one of the supported types. -# The parameter 'type' can be used to enable the floppy drive without media -# and status specified. Usually the drive type is set up based on the media type. -# The optional parameter 'write_protected' can be used to control the media -# write protect switch. By default it is turned off. -#======================================================================= -#floppya: 1_44=/dev/fd0, status=inserted -#floppya: image=../1.44, status=inserted -#floppya: 1_44=/dev/fd0H1440, status=inserted -#floppya: 1_2=../1_2, status=inserted -#floppya: 1_44=a:, status=inserted -#floppya: 1_44=a.img, status=inserted, write_protected=1 -#floppya: 1_44=/dev/rfd0a, status=inserted - -#======================================================================= -# FLOPPYB: -# See FLOPPYA above for syntax -#======================================================================= -#floppyb: 1_44=b:, status=inserted -#floppyb: 1_44=b.img, status=inserted - -#======================================================================= -# ATA0, ATA1, ATA2, ATA3 -# ATA controller for hard disks and cdroms -# -# ata[0-3]: enabled=[0|1], ioaddr1=addr, ioaddr2=addr, irq=number -# -# These options enables up to 4 ata channels. For each channel -# the two base io addresses and the irq must be specified. -# -# ata0 and ata1 are enabled by default with the values shown below -# -# Examples: -# ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 -# ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15 -# ata2: enabled=1, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11 -# ata3: enabled=1, ioaddr1=0x168, ioaddr2=0x360, irq=9 -#======================================================================= -ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 -ata1: enabled=0, ioaddr1=0x170, ioaddr2=0x370, irq=15 -ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11 -ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9 - -#======================================================================= -# ATA[0-3]-MASTER, ATA[0-3]-SLAVE -# -# This defines the type and characteristics of all attached ata devices: -# type= type of attached device [disk|cdrom] -# mode= only valid for disks [flat|concat|external|dll|sparse|vmware3] -# [vmware4|undoable|growing|volatile|vpc] -# [vbox|vvfat] -# path= path of the image / directory -# cylinders= only valid for disks -# heads= only valid for disks -# spt= only valid for disks -# status= only valid for cdroms [inserted|ejected] -# biosdetect= type of biosdetection [none|auto], only for disks on ata0 [cmos] -# translation=type of translation of the bios, only for disks [none|lba|large|rechs|auto] -# model= string returned by identify device command -# journal= optional filename of the redolog for undoable, volatile and vvfat disks -# -# Point this at a hard disk image file, cdrom iso file, or physical cdrom -# device. To create a hard disk image, try running bximage. It will help you -# choose the size and then suggest a line that works with it. -# -# In UNIX it may be possible to use a raw device as a Bochs hard disk, -# but WE DON'T RECOMMEND IT. In Windows there is no easy way. -# -# In windows, the drive letter + colon notation should be used for cdroms. -# Depending on versions of windows and drivers, you may only be able to -# access the "first" cdrom in the system. On MacOSX, use path="drive" -# to access the physical drive. -# -# The path is mandatory for hard disks. Disk geometry autodetection works with -# images created by bximage if CHS is set to 0/0/0 (cylinders are calculated -# using heads=16 and spt=63). For other hard disk images and modes the -# cylinders, heads, and spt are mandatory. In all cases the disk size reported -# from the image must be exactly C*H*S*512. -# -# Default values are: -# mode=flat, biosdetect=auto, translation=auto, model="Generic 1234" -# -# The biosdetect option has currently no effect on the bios -# -# Examples: -# ata0-master: type=disk, mode=flat, path=10M.sample, cylinders=306, heads=4, spt=17 -# ata0-slave: type=disk, mode=flat, path=20M.sample, cylinders=615, heads=4, spt=17 -# ata1-master: type=disk, mode=flat, path=30M.sample, cylinders=615, heads=6, spt=17 -# ata1-slave: type=disk, mode=flat, path=46M.sample, cylinders=940, heads=6, spt=17 -# ata2-master: type=disk, mode=flat, path=62M.sample, cylinders=940, heads=8, spt=17 -# ata2-slave: type=disk, mode=flat, path=112M.sample, cylinders=900, heads=15, spt=17 -# ata3-master: type=disk, mode=flat, path=483M.sample, cylinders=1024, heads=15, spt=63 -# ata3-slave: type=cdrom, path=iso.sample, status=inserted -#======================================================================= -ata0-master: type=cdrom, path="secX.iso", status=inserted, biosdetect=auto -#ata0-master: type=disk, mode=flat, path="30M.sample" -#ata0-master: type=disk, mode=flat, path="30M.sample", cylinders=615, heads=6, spt=17 -#ata0-master: type=disk, mode=flat, path="c.img", cylinders=0 # autodetect -#ata0-slave: type=disk, mode=vvfat, path=/bochs/images/vvfat, journal=vvfat.redolog -#ata0-slave: type=cdrom, path=D:, status=inserted -#ata0-slave: type=cdrom, path=/dev/cdrom, status=inserted -#ata0-slave: type=cdrom, path="drive", status=inserted -#ata0-slave: type=cdrom, path=/dev/rcd0d, status=inserted - -#======================================================================= -# BOOT: -# This defines the boot sequence. Now you can specify up to 3 boot drives, -# which can be 'floppy', 'disk', 'cdrom' or 'network' (boot ROM). -# Legacy 'a' and 'c' are also supported. -# Examples: -# boot: floppy -# boot: cdrom, disk -# boot: network, disk -# boot: cdrom, floppy, disk -#======================================================================= -#boot: floppy -boot: cdrom - -#======================================================================= -# FLOPPY_BOOTSIG_CHECK: disabled=[0|1] -# Enables or disables the 0xaa55 signature check on boot floppies -# Defaults to disabled=0 -# Examples: -# floppy_bootsig_check: disabled=0 -# floppy_bootsig_check: disabled=1 -#======================================================================= -floppy_bootsig_check: disabled=0 - -#======================================================================= -# LOG: -# Give the path of the log file you'd like Bochs debug and misc. verbiage -# to be written to. If you don't use this option or set the filename to -# '-' the output is written to the console. If you really don't want it, -# make it "/dev/null" (Unix) or "nul" (win32). :^( -# -# Examples: -# log: ./bochs.out -# log: /dev/tty -#======================================================================= -log: /dev/null -#log: results.log - -#======================================================================= -# LOGPREFIX: -# This handles the format of the string prepended to each log line. -# You may use those special tokens : -# %t : 11 decimal digits timer tick -# %i : 8 hexadecimal digits of cpu current eip (ignored in SMP configuration) -# %e : 1 character event type ('i'nfo, 'd'ebug, 'p'anic, 'e'rror) -# %d : 5 characters string of the device, between brackets -# -# Default : %t%e%d -# Examples: -# logprefix: %t-%e-@%i-%d -# logprefix: %i%e%d -#======================================================================= -#logprefix: %t%i%e%d - -#======================================================================= -# LOG CONTROLS -# -# Bochs has four severity levels for event logging. -# panic: cannot proceed. If you choose to continue after a panic, -# don't be surprised if you get strange behavior or crashes. -# error: something went wrong, but it is probably safe to continue the -# simulation. -# info: interesting or useful messages. -# debug: messages useful only when debugging the code. This may -# spit out thousands per second. -# -# For events of each level, you can choose to exit Bochs ('fatal'), 'report' -# or 'ignore'. On some guis you have the additional choice 'ask'. A gui dialog -# appears asks how to proceed. -# -# It is also possible to specify the 'action' to do for each Bochs facility -# separately (e.g. crash on panics from everything except the cdrom, and only -# report those). See the 'log function' module list in the user documentation. -# -# If you are experiencing many panics, it can be helpful to change -# the panic action to report instead of fatal. However, be aware -# that anything executed after a panic is uncharted territory and can -# cause bochs to become unstable. The panic is a "graceful exit," so -# if you disable it you may get a spectacular disaster instead. -#======================================================================= -panic: action=ask -error: action=report -info: action=report -#debug: action=ignore, pci=report # report BX_DEBUG from module 'pci' - -#======================================================================= -# DEBUGGER_LOG: -# Give the path of the log file you'd like Bochs to log debugger output. -# If you really don't want it, make it /dev/null or '-'. :^( -# -# Examples: -# debugger_log: ./debugger.out -#======================================================================= -#debugger_log: /dev/null -#debugger_log: debug.log -#debugger_log: debug.log - -#======================================================================= -# COM1, COM2, COM3, COM4: -# This defines a serial port (UART type 16550A). In the 'term' mode you can -# specify a device to use as com1. This can be a real serial line, or a pty. -# To use a pty (under X/Unix), create two windows (xterms, usually). One of -# them will run bochs, and the other will act as com1. Find out the tty the com1 -# window using the `tty' command, and use that as the `dev' parameter. -# Then do `sleep 1000000' in the com1 window to keep the shell from -# messing with things, and run bochs in the other window. Serial I/O to -# com1 (port 0x3f8) will all go to the other window. -# In socket* and pipe* (win32 only) modes Bochs becomes either socket/named pipe -# client or server. In client mode it connects to an already running server (if -# connection fails Bochs treats com port as not connected). In server mode it -# opens socket/named pipe and waits until a client application connects to it -# before starting simulation. This mode is useful for remote debugging (e.g. -# with gdb's "target remote host:port" command or windbg's command line option -# -k com:pipe,port=\\.\pipe\pipename). Socket modes use simple TCP communication, -# pipe modes use duplex byte mode pipes. -# Other serial modes are 'null' (no input/output), 'file' (output to a file -# specified as the 'dev' parameter), 'raw' (use the real serial port - under -# construction for win32), 'mouse' (standard serial mouse - requires -# mouse option setting 'type=serial', 'type=serial_wheel' or 'type=serial_msys'). -# -# Examples: -# com1: enabled=1, mode=null -# com1: enabled=1, mode=mouse -# com2: enabled=1, mode=file, dev=serial.out -# com3: enabled=1, mode=raw, dev=com1 -# com3: enabled=1, mode=socket-client, dev=localhost:8888 -# com3: enabled=1, mode=socket-server, dev=localhost:8888 -# com4: enabled=1, mode=pipe-client, dev=\\.\pipe\mypipe -# com4: enabled=1, mode=pipe-server, dev=\\.\pipe\mypipe -#======================================================================= -#com1: enabled=1, mode=term, dev=/dev/ttyp9 - - -#======================================================================= -# PARPORT1, PARPORT2: -# This defines a parallel (printer) port. When turned on and an output file is -# defined the emulated printer port sends characters printed by the guest OS -# into the output file. On some platforms a device filename can be used to -# send the data to the real parallel port (e.g. "/dev/lp0" on Linux, "lpt1" on -# win32 platforms). -# -# Examples: -# parport1: enabled=1, file="parport.out" -# parport2: enabled=1, file="/dev/lp0" -# parport1: enabled=0 -#======================================================================= -# parport1: enabled=1, file="parport.out" - -#======================================================================= -# SOUND: -# This defines the lowlevel sound driver(s) for the wave (PCM) input / output -# and the MIDI output feature and (if necessary) the devices to be used. -# It can have several of the following properties. -# All properties are in the format sound: property=value -# -# waveoutdrv: -# This defines the driver to be used for the waveout feature. -# Possible values are 'file' (all wave data sent to file), 'dummy' (no -# output) and the platform-dependant drivers 'alsa', 'oss', 'osx', 'sdl' -# and 'win'. -# waveout: -# This defines the device to be used for wave output (if necessary) or -# the output file for the 'file' driver. -# waveindrv: -# This defines the driver to be used for the wavein feature. -# Possible values are 'dummy' (recording silence) and platform-dependent -# drivers 'alsa', 'oss' and 'win'. -# wavein: -# This defines the device to be used for wave output (if necessary). -# midioutdrv: -# This defines the driver to be used for the MIDI output feature. -# Possible values are 'file' (all MIDI data sent to file), 'dummy' (no -# output) and platform-dependent drivers 'alsa', 'oss', 'osx' and 'win'. -# midiout: -# This defines the device to be used for MIDI output (if necessary). -# driver: -# This defines the driver to be used for all sound features with one -# property. Possible values are 'default' (platform default) and all -# other choices described above. Overriding one or more settings with -# the specific driver parameter is possible. -# -# Example for different drivers: -# sound: waveoutdrv=sdl, waveindrv=alsa, midioutdrv=dummy -#======================================================================= -# sound: driver=default, waveout=/dev/dsp. wavein=, midiout= - -#======================================================================= -# SPEAKER: -# This defines the PC speaker output mode. In the 'sound' mode the beep -# is generated by the square wave generator which is a part of the -# lowlevel sound support. The 'system' mode is only available on Linux -# and Windows. On Linux /dev/console is used for output and on Windows -# the Beep() function. The 'gui' mode forwards the beep to the related -# gui methods (currently only used by the Carbon gui). -#======================================================================= -#speaker: enabled=0, mode=sound - -#======================================================================= -# SB16: -# This defines the SB16 sound emulation. It can have several of the -# following properties. -# All properties are in the format sb16: property=value -# -# enabled: -# This optional property controls the presence of the SB16 emulation. -# The emulation is turned on unless this property is used and set to 0. -# midimode: This parameter specifies what to do with the MIDI output. -# 0 = no output -# 1 = output to device specified with the sound option (system dependent) -# 2 = MIDI or raw data output to file (depends on file name extension) -# 3 = dual output (mode 1 and 2 at the same time) -# midifile: This is the file where the midi output is stored (midimode 2 or 3). -# wavemode: This parameter specifies what to do with the PCM output. -# 0 = no output -# 1 = output to device specified with the sound option (system dependent) -# 2 = VOC, WAV or raw data output to file (depends on file name extension) -# 3 = dual output (mode 1 and 2 at the same time) -# wavefile: This is the file where the wave output is stored (wavemode 2 or 3). -# loglevel: -# 0=no log -# 1=resource changes, midi program and bank changes -# 2=severe errors -# 3=all errors -# 4=all errors plus all port accesses -# 5=all errors and port accesses plus a lot of extra info -# log: The file to write the sb16 emulator messages to. -# dmatimer: -# microseconds per second for a DMA cycle. Make it smaller to fix -# non-continuous sound. 750000 is usually a good value. This needs a -# reasonably correct setting for the IPS parameter of the CPU option. -# -# Examples for output modes: -# sb16: midimode=2, midifile="output.mid", wavemode=1 # MIDI to file -# sb16: midimode=1, wavemode=3, wavefile="output.wav" # wave to file and device -#======================================================================= -#sb16: midimode=1, wavemode=1, loglevel=2, log=sb16.log, dmatimer=600000 - -#======================================================================= -# ES1370: -# This defines the ES1370 sound emulation (recording and playback - except -# DAC1+DAC2 output at the same time). The parameter 'enabled' controls the -# presence of the device. The wave and MIDI output can be sent to device, file -# or both using the parameters 'wavemode', 'wavefile', 'midimode' and -# 'midifile'. See the description of these parameters at the SB16 directive. -# -# Examples: -# es1370: enabled=1, wavemode=1 # use 'sound' parameters -# es1370: enabled=1, wavemode=2, wavefile=output.voc # send output to file -#======================================================================= -#es1370: enabled=1, wavemode=1 - -#======================================================================= -# ne2k: NE2000 compatible ethernet adapter -# -# Format: -# ne2k: enabled=1, ioaddr=IOADDR, irq=IRQ, mac=MACADDR, ethmod=MODULE, -# ethdev=DEVICE, script=SCRIPT, bootrom=BOOTROM -# -# IOADDR, IRQ: You probably won't need to change ioaddr and irq, unless there -# are IRQ conflicts. These arguments are ignored when assign the ne2k to a -# PCI slot. -# -# MAC: The MAC address MUST NOT match the address of any machine on the net. -# Also, the first byte must be an even number (bit 0 set means a multicast -# address), and you cannot use ff:ff:ff:ff:ff:ff because that's the broadcast -# address. For the ethertap module, you must use fe:fd:00:00:00:01. There may -# be other restrictions too. To be safe, just use the b0:c4... address. -# -# ETHDEV: The ethdev value is the name of the network interface on your host -# platform. On UNIX machines, you can get the name by running ifconfig. On -# Windows machines, you must run niclist to get the name of the ethdev. -# Niclist source code is in misc/niclist.c and it is included in Windows -# binary releases. -# -# SCRIPT: The script value is optional, and is the name of a script that -# is executed after bochs initialize the network interface. You can use -# this script to configure this network interface, or enable masquerading. -# This is mainly useful for the tun/tap devices that only exist during -# Bochs execution. The network interface name is supplied to the script -# as first parameter. The 'slirp' module uses this parameter to specify -# a config file for setting up an alternative IP configuration or additional -# features. -# -# BOOTROM: The bootrom value is optional, and is the name of the ROM image -# to load. Note that this feature is only implemented for the PCI version of -# the NE2000. -# -# If you don't want to make connections to any physical networks, -# you can use the following 'ethmod's to simulate a virtual network. -# null: All packets are discarded, but logged to a few files. -# vde: Virtual Distributed Ethernet -# vnet: ARP, ICMP-echo(ping), DHCP and read/write TFTP are simulated. -# The virtual host uses 192.168.10.1. -# DHCP assigns 192.168.10.2 to the guest. -# TFTP uses the 'ethdev' value for the root directory and doesn't -# overwrite files. -# -#======================================================================= -# ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=fbsd, ethdev=en0 #macosx -# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:00, ethmod=fbsd, ethdev=xl0 -# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:00, ethmod=linux, ethdev=eth0 -# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=win32, ethdev=MYCARD -# ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=tap, ethdev=tap0 -# ne2k: ioaddr=0x300, irq=9, mac=fe:fd:00:00:00:01, ethmod=tuntap, ethdev=/dev/net/tun0, script=./tunconfig -# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=null, ethdev=eth0 -# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=vde, ethdev="/tmp/vde.ctl" -# ne2k: ioaddr=0x300, irq=9, mac=b0:c4:20:00:00:01, ethmod=vnet, ethdev="c:/temp" -# ne2k: mac=b0:c4:20:00:00:01, ethmod=slirp, script=slirp.conf, bootrom=ne2k_pci.rom - -#======================================================================= -# pcipnic: Bochs/Etherboot pseudo-NIC -# -# Format: -# pcipnic: enabled=1, mac=MACADDR, ethmod=MODULE, ethdev=DEVICE, script=SCRIPT, -# bootrom=BOOTROM -# -# The pseudo-NIC accepts the same syntax (for mac, ethmod, ethdev, script, -# bootrom) and supports the same networking modules as the NE2000 adapter. -#======================================================================= -#pcipnic: enabled=1, mac=b0:c4:20:00:00:00, ethmod=vnet - -#======================================================================= -# e1000: Intel(R) 82540EM Gigabit Ethernet adapter -# -# Format: -# e1000: enabled=1, mac=MACADDR, ethmod=MODULE, ethdev=DEVICE, script=SCRIPT -# bootrom=BOOTROM -# -# The E1000 accepts the same syntax (for mac, ethmod, ethdev, script, bootrom) -# and supports the same networking modules as the NE2000 adapter. -#======================================================================= -#e1000: enabled=1, mac=52:54:00:12:34:56, ethmod=slirp, script=slirp.conf - -#======================================================================= -# USB_UHCI: -# This option controls the presence of the USB root hub which is a part -# of the i440FX PCI chipset. With the portX parameter you can connect devices -# to the hub (currently supported: 'mouse', 'tablet', 'keypad', 'disk', 'cdrom' -# 'hub' and 'printer'). -# -# If you connect the mouse or tablet to one of the ports, Bochs forwards the -# mouse movement data to the USB device instead of the selected mouse type. -# When connecting the keypad to one of the ports, Bochs forwards the input of -# the numeric keypad to the USB device instead of the PS/2 keyboard. -# -# To connect a 'flat' mode image as an USB hardisk you can use the 'disk' device -# with the path to the image separated with a colon. To use other disk image modes -# similar to ATA disks the syntax 'disk:mode:filename' must be used (see below). -# -# To emulate an USB cdrom you can use the 'cdrom' device name and the path to -# an ISO image or raw device name also separated with a colon. An option to -# insert/eject media is available in the runtime configuration. -# -# The device name 'hub' connects an external hub with max. 8 ports (default: 4) -# to the root hub. To specify the number of ports you have to add the value -# separated with a colon. Connecting devices to the external hub ports is only -# available in the runtime configuration. -# -# The device 'printer' emulates the HP Deskjet 920C printer. The PCL data is -# sent to a file specified in bochsrc.txt. The current code appends the PCL -# code to the file if the file already existed. It would probably be nice to -# overwrite the file instead, asking user first. -# -# The optionsX parameter can be used to assign specific options to the device -# connected to the corresponding USB port. Currently this feature is used to -# set the speed reported by device ('low', 'full', 'high' or 'super'). The -# availabe speed choices depend on both HC and device. For the USB 'disk' device -# the optionsX parameter can be used to specify an alternative redolog file -# (journal) of some image modes. For 'vvfat' mode USB disks the optionsX -# parameter can be used to specify the disk size (range 128M ... 128G). If the -# size is not specified, it defaults to 504M. -#======================================================================= -#usb_uhci: enabled=1 -#usb_uhci: enabled=1, port1=mouse, port2=disk:usbstick.img -#usb_uhci: enabled=1, port1=hub:7, port2=disk:growing:usbdisk.img -#usb_uhci: enabled=1, port2=disk:undoable:usbdisk.img, options2=journal:redo.log -#usb_uhci: enabled=1, port2=disk:vvfat:vvfat, options2=speed:full -#usb_uhci: enabled=1, port1=printer:printdata.bin, port2=cdrom:image.iso - -#======================================================================= -# USB_OHCI: -# This option controls the presence of the USB OHCI host controller with a -# 2-port hub. The portX parameter accepts the same device types with the same -# syntax as the UHCI controller (see above). The optionsX parameter is also -# available on OHCI. -#======================================================================= -#usb_ohci: enabled=1 -#usb_ohci: enabled=1, port1=printer:usbprinter.bin - -#======================================================================= -# USB_XHCI: -# This option controls the presence of the experimental USB xHCI host controller -# with a 4-port hub. The portX parameter accepts the same device types with the -# same syntax as the UHCI controller (see above). The optionsX parameter is -# also available on xHCI. NOTE: port 1 and 2 are USB3 and only support -# super-speed devices, but port 3 and 4 are USB2 and support speed settings -# low, full and high. -#======================================================================= -#usb_xhci: enabled=1 - -#======================================================================= -# PCIDEV: -# PCI host device mapping -#======================================================================= -#pcidev: vendor=0x1234, device=0x5678 - -#======================================================================= -# GDBSTUB: -# Enable GDB stub. See user documentation for details. -# Default value is enabled=0. -#======================================================================= -#gdbstub: enabled=0, port=1234, text_base=0, data_base=0, bss_base=0 - -#======================================================================= -# MAGIC_BREAK: -# This enables the "magic breakpoint" feature when using the debugger. -# The useless cpu instruction XCHG BX, BX causes Bochs to enter the -# debugger mode. This might be useful for software development. -# -# Example: -# magic_break: enabled=1 -#======================================================================= -magic_break: enabled=1 - -#======================================================================= -# DEBUG_SYMBOLS: -# This loads symbols from the specified file for use in Bochs' internal -# debugger. Symbols are loaded into global context. This is equivalent to -# issuing ldsym debugger command at start up. -# -# Example: -# debug_symbols: file="kernel.sym" -# debug_symbols: file="kernel.sym", offset=0x80000000 -#======================================================================= -#debug_symbols: file="kernel.sym" - -#print_timestamps: enabled=1 - -#======================================================================= -# PORT_E9_HACK: -# The 0xE9 port doesn't exists in normal ISA architecture. However, we -# define a convention here, to display on the console of the system running -# Bochs anything that is written to it. The idea is to provide debug output -# very early when writing BIOS or OS code for example, without having to -# bother with setting up a serial port or etc. Reading from port 0xE9 will -# will return 0xe9 to let you know if the feature is available. -# Leave this 0 unless you have a reason to use it. -# -# Example: -# port_e9_hack: enabled=1 -#======================================================================= -#port_e9_hack: enabled=1 - -#======================================================================= -# other stuff -#======================================================================= -#load32bitOSImage: os=nullkernel, path=../kernel.img, iolog=../vga_io.log -#load32bitOSImage: os=linux, path=../linux.img, iolog=../vga_io.log, initrd=../initrd.img - -#======================================================================= -# fullscreen: ONLY IMPLEMENTED ON AMIGA -# Request that Bochs occupy the entire screen instead of a -# window. -# -# Examples: -# fullscreen: enabled=0 -# fullscreen: enabled=1 -#======================================================================= -#fullscreen: enabled=0 -#screenmode: name="sample" - -#======================================================================= -# USER_PLUGIN: -# Load user-defined plugin. This option is available only if Bochs is -# compiled with plugin support. Maximum 8 different plugins are supported. -# See the example in the Bochs sources how to write a plugin device. -#======================================================================= -#user_plugin: name=testdev - -#======================================================================= -# for Macintosh, use the style of pathnames in the following -# examples. -# -# vgaromimage: :bios:VGABIOS-elpin-2.40 -# romimage: file=:bios:BIOS-bochs-latest, address=0xf0000 -# floppya: 1_44=[fd:], status=inserted -#======================================================================= - -#======================================================================= -# MEGS -# Set the number of Megabytes of physical memory you want to emulate. -# The default is 32MB, most OS's won't need more than that. -# The maximum amount of memory supported is 2048Mb. -# The 'MEGS' option is deprecated. Use 'MEMORY' option instead. -#======================================================================= -#megs: 256 -#megs: 128 -#megs: 64 -#megs: 32 -#megs: 16 -#megs: 8 diff --git a/misc/bochs/bochs_win.bxrc b/misc/bochs/bochs_win.bxrc deleted file mode 100644 index fc2d72f..0000000 --- a/misc/bochs/bochs_win.bxrc +++ /dev/null @@ -1,50 +0,0 @@ -# configuration file generated by Bochs -plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1 -config_interface: win32config -display_library: win32, options="gui_debug" -memory: host=256, guest=256 -romimage: file="C:\Program Files (x86)\Bochs-2.6.8\BIOS-bochs-latest" -vgaromimage: file="C:\Program Files (x86)\Bochs-2.6.8\VGABIOS-lgpl-latest" -boot: cdrom -magic_break: enabled=1 -floppy_bootsig_check: disabled=0 -debug_symbols: file="target\kernel.sym" -# no floppya -# no floppyb -ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 -ata0-master: type=cdrom, path="target\secX.iso", status=inserted, model="Generic 1234", biosdetect=auto -ata0-slave: type=none -ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15 -ata1-master: type=none -ata1-slave: type=none -ata2: enabled=0 -ata3: enabled=0 -pci: enabled=1, chipset=i440fx -vga: extension=vbe, update_freq=5 -cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=0, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0 -cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU " -cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0 -cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, x86_64=1, 1g_pages=1, pcid=0, fsgsbase=1 -cpuid: smep=0, smap=0, mwait=1, vmx=1 -print_timestamps: enabled=0 -port_e9_hack: enabled=0 -private_colormap: enabled=0 -clock: sync=none, time0=local, rtc_sync=0 -# no cmosimage -# no loader -log: - -logprefix: %t%e%d -debug: action=ignore -info: action=report -error: action=report -panic: action=ask -keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none -mouse: type=ps2, enabled=0, toggle=ctrl+mbutton -sound: driver="default", waveout=none, wavein=none -speaker: enabled=1, mode=sound -parport1: enabled=1, file=none -parport2: enabled=0 -com1: enabled=1, mode=null -com2: enabled=0 -com3: enabled=0 -com4: enabled=0 diff --git a/misc/bochs/bootstrap.sh b/misc/bochs/bootstrap.sh deleted file mode 100644 index f1de690..0000000 --- a/misc/bochs/bootstrap.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -export PATH="~/opt/cross/bin:$PATH" diff --git a/misc/bochs/compile_gdb.sh b/misc/bochs/compile_gdb.sh deleted file mode 100755 index 2a1fa05..0000000 --- a/misc/bochs/compile_gdb.sh +++ /dev/null @@ -1,20 +0,0 @@ -cd src -./configure --enable-cpu-level=6 \ - --enable-all-optimizations \ - --enable-x86-64 \ - --enable-pci \ - --enable-vmx \ - --enable-disasm \ - --enable-logging \ - --enable-fpu \ - --enable-3dnow \ - --enable-sb16=dummy \ - --enable-cdrom \ - --enable-iodebug \ - --disable-plugins \ - --disable-docbook \ - --enable-gdb-stub \ - --with-x --with-x11 --with-term --with-sdl - -make - diff --git a/misc/bochs/compile_idb.sh b/misc/bochs/compile_idb.sh deleted file mode 100755 index e80009c..0000000 --- a/misc/bochs/compile_idb.sh +++ /dev/null @@ -1,23 +0,0 @@ -cd src -./configure --enable-smp \ - --enable-cpu-level=6 \ - --enable-all-optimizations \ - --enable-x86-64 \ - --enable-pci \ - --enable-vmx \ - --enable-debugger \ - --enable-disasm \ - --enable-debugger-gui \ - --enable-logging \ - --enable-fpu \ - --enable-3dnow \ - --enable-sb16=dummy \ - --enable-cdrom \ - --enable-x86-debugger \ - --enable-iodebug \ - --disable-plugins \ - --disable-docbook \ - --with-x --with-x11 --with-term --with-sdl - -make - diff --git a/misc/legacy_bootloader/inc/FAT12Header.inc b/misc/legacy_bootloader/inc/FAT12Header.inc deleted file mode 100644 index 158fd02..0000000 --- a/misc/legacy_bootloader/inc/FAT12Header.inc +++ /dev/null @@ -1,25 +0,0 @@ - nop - BS_OEMName DB 'HYPERASM' - BPB_BytsPerSec DW 512 - BPB_SecPerClus DB 1 - BPB_RsvdSecCnt DW 1 - BPB_NumFATs DB 2 - BPB_RootEntCnt DW 224 - BPB_TotSec16 DW 2880 - BPB_Media DB 0xF0 - BPB_FATSz16 DW 9 - BPB_SecPerTrk DW 18 - BPB_NumHeads DW 2 - BPB_HiddSec DD 0 - BPB_TotSec32 DD 0 - BS_DrvNum DB 0 - BS_Reserved1 DB 0 - BS_BootSig DB 29h - BS_VolID DD 0 - BS_VolLab DB 'HYPER_ASM ' - BS_FileSysType DB 'FAT12 ' - - RootDirSectors equ 14 - SectorNoOfRootDirectory equ 19 - SectorNoOfFAT1 equ 1 - DeltaSectorNo equ 17 \ No newline at end of file diff --git a/misc/legacy_bootloader/inc/boot/boot.asm b/misc/legacy_bootloader/inc/boot/boot.asm deleted file mode 100644 index f6391a0..0000000 --- a/misc/legacy_bootloader/inc/boot/boot.asm +++ /dev/null @@ -1,25 +0,0 @@ -org 07c00h - -BaseOfStack equ 07c00h -BaseOfLoader equ 09000h -OffsetOfLoader equ 0100h - jmp short START - %include "FAT12Header.inc" - -START: - mov ax, cs - mov ds, ax - mov es, ax - mov ss, ax - mov sp, BaseOfStack - ;FAT12ReadFile(ULONG16 Base,ULONG16 Offset,ULONG16 OffsetFileName) - push LoaderFileName - push OffsetOfLoader - push BaseOfLoader - call near FAT12ReadFile - add sp,6 - jmp BaseOfLoader:OffsetOfLoader - %include "fat12readfile.lib" -LoaderFileName: db 'LOADER BIN',0 -times 510-($-$$) db 0 -dw 0xaa55 diff --git a/misc/legacy_bootloader/inc/boot/loader.asm b/misc/legacy_bootloader/inc/boot/loader.asm deleted file mode 100644 index 950f1ca..0000000 --- a/misc/legacy_bootloader/inc/boot/loader.asm +++ /dev/null @@ -1,248 +0,0 @@ -org 0100h -jmp BEGIN -%include "pm.inc" -;GDT -DESC_VOID: Descriptor 0,0,0 -DESC_GRAPH: Descriptor 0b8000h,0ffffh,DA_DRW | DA_DPL3 -DESC_FLAT_C: Descriptor 0,0fffffh,DA_CR | DA_32 | DA_LIMIT_4K -DESC_FLAT_RW: Descriptor 0,0fffffh,DA_DRW | DA_32 | DA_LIMIT_4K -DESC_FLAT_USER_C: Descriptor 0,0fffffh,DA_CR | DA_32| DA_LIMIT_4K | DA_DPL3 -DESC_FLAT_USER_RW: Descriptor 0,0fffffh,DA_DRW | DA_32 | DA_LIMIT_4K | DA_DPL3 - -GDTLEN equ $ - DESC_VOID - -GDTPTR: dw GDTLEN - 1 -dd LOADERINFLAT + DESC_VOID - -;Paging -PDEBASE equ 100000h -PTEBASE equ 101000h - -;kernel -LOADERBASE equ 09000h -LOADEROFFSET equ 0100h -LOADERINFLAT equ LOADERBASE*10h - -KERNELFILENAME db 'KERNEL BIN',0 -KERNELBASE equ 03000h -KERNELOFFSET equ 0000h -KERNELINFLAT equ KERNELBASE*10h + KERNELOFFSET - -;Selectors -SLCT_FLAT_C equ DESC_FLAT_C - DESC_VOID -SLCT_GRAPH equ DESC_GRAPH - DESC_VOID -SLCT_FLAT_RW equ DESC_FLAT_RW - DESC_VOID - -;==================Section .DATA============================== -;Variables -;Operating System Information -;OS: -OSINFO1: db 'Hyper-Assembler Operating System 1.0',0 -OSINFO2: db "Loader written by Orange'S, Kernel written by Hyper-Assembler",0 -KERNELFILELOADCOMPLETE db 'Kernel.bin Loaded to 0x30000',0 - -;GETMEMORY -RAMINFO1: db "Memory Information:",0 -RAMTABLE16: db ' BASE L BASE H Length L Length H Type ',0 -RAMSIZE: db 'RAM SIZE:',0 -GETMEMFAIL: db 'Failed to Get The Memory',0 -RAMAVAILABLE: db ' - Available',0 -RAMRESERVED: db ' - Reserved',0 - -;Protected Mode: -PMINFO: db 'Protected Mode Entered...',0 -PMINFO32 equ PMINFO + LOADERINFLAT - -;PAGING: -PGINFO: db 'Paging Started...',0 -PGINFO32 equ PGINFO + LOADERINFLAT -PTEINFO: db 'PTE Table BASE: ',0 -PTEINFO32 equ PTEINFO + LOADERINFLAT -PDEINFO: db 'PDE Table BASE: ',0 -PDEINFO32 equ PDEINFO + LOADERINFLAT -CR3INFO: db 'cr3: ',0 -CR3INFO32 equ CR3INFO + LOADERINFLAT - -;Variables Used in Functions -IO16_SPACE: db ' ',0 -IO32_SPACE equ IO16_SPACE + LOADERINFLAT -IO16_RETURN: db 0Ah,0 -IO32_RETURN equ IO16_RETURN + LOADERINFLAT -GRAPHPOS: dd 0 -GRAPHPOS_32 equ GRAPHPOS + LOADERINFLAT -GETMEMBUFF: times 1024 db 0 -GETMEMNUM: dd 0 -GETMEMNUM_32 equ GETMEMBUFF + LOADERINFLAT -DISPMEMTOTAL: dd 0 -DISPMEMTOTAL_32 equ DISPMEMTOTAL + LOADERINFLAT -KERNELLOADED: db 'KERNEL LOADED IN MEM.',0 -KERNELLOADED_32 equ KERNELLOADED + LOADERINFLAT -%include "FAT12Header.inc" -;=========================STACK32============================= -[bits 32] -STACK32BASE: -times 1024 db 0 -TOP: -STACK32TOP equ LOADERINFLAT + TOP - -;==========================CODE16============================== -[bits 16] -%include "io16.lib" -%include "fat12readfile.lib" -BEGIN: -mov ax,cs -mov ds,ax -mov ss,ax -mov es,ax - -mov ax,0003h -int 10h ;clear - -xor eax,eax -mov eax,OSINFO1 -push eax -call DISPSTR16 -add esp,4 - -call DISPRETURN16 - -xor eax,eax -mov eax,OSINFO2 -push eax -call DISPSTR16 -add esp,4 - -call DISPRETURN16 - -call DISPRETURN16 - -xor eax,eax -mov eax,RAMINFO1 -push eax -call DISPSTR16 -add esp,4 - -call DISPRETURN16 - -call GETMEM16 - -mov eax,dword [ds:GETMEMNUM] -cmp eax,0 -jne GETMEMSUCCESSFUL -xor eax,eax -mov eax,GETMEMFAIL -push eax -call DISPSTR16 -pop eax - -GETMEMSUCCESSFUL: - -call DISPMEM16 -call DISPRETURN16 - -;FAT12ReadFile(ULONG16 Base,ULONG16 Offset,ULONG16 OffsetFileName) -push KERNELFILENAME -push KERNELOFFSET -push KERNELBASE -call FAT12ReadFile -add esp,6 - -xor eax,eax -mov eax,KERNELFILELOADCOMPLETE -push eax -call DISPSTR16 -add esp,4 - -call DISPRETURN16 - -;load gdt -lgdt [GDTPTR] - -;close interupt -cli - -;open A20 -in al,92h -or al,00000010b -out 92h,al - -;prepare to switch to the protected mode -mov eax,cr0 -or eax,1 -mov cr0,eax - -jmp dword SLCT_FLAT_C:(CODE32_START + LOADERINFLAT) - - - -;===================CODE32====================== -[bits 32] -%include "mem32.lib" -%include "io32.lib" -CODE32_START: -mov ax,SLCT_FLAT_RW -mov ss,ax -mov ds,ax -mov es,ax -mov gs,ax - -mov ax,SLCT_GRAPH -mov gs,ax - -mov sp,STACK32TOP - -mov eax,PMINFO32 -push eax -call near DISPSTR32 -pop eax - - -;Setup paging -call PAGINGINIT32 - -call DISPRETURN32 - -mov eax,PGINFO32 -push eax -call near DISPSTR32 -pop eax - -call DISPRETURN32 -;Print PDE Table Base -mov eax,PDEINFO32 -push eax -call DISPSTR32 -pop eax - -mov eax,PDEBASE -push eax -call DISPINTEAX32 -pop eax - -call DISPRETURN32 -;Print PTE table base -mov eax,PTEINFO32 -push eax -call DISPSTR32 -pop eax - -mov eax,PTEBASE -push eax -call DISPINTEAX32 -pop eax - -call DISPRETURN32 -;Print cr3 -mov eax,CR3INFO32 -push eax -call DISPSTR32 -pop eax - -mov eax,cr3 -push eax -call DISPINTEAX32 -pop eax - -;Jump to The Kernel - -jmp SLCT_FLAT_C:KERNELINFLAT diff --git a/misc/legacy_bootloader/inc/pm.inc b/misc/legacy_bootloader/inc/pm.inc deleted file mode 100644 index 93e14ef..0000000 --- a/misc/legacy_bootloader/inc/pm.inc +++ /dev/null @@ -1,324 +0,0 @@ - -; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; pm.inc -; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -; Forrest Yu, 2005 -; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - -; 描述符图示 - -; 图示一 -; -; ------ ┏━━┳━━┓高地址 -; ┃ 7 ┃ 段 ┃ -; ┣━━┫ ┃ -; 基 -; 字节 7 ┆ ┆ ┆ -; 址 -; ┣━━┫ ② ┃ -; ┃ 0 ┃ ┃ -; ------ ┣━━╋━━┫ -; ┃ 7 ┃ G ┃ -; ┣━━╉──┨ -; ┃ 6 ┃ D ┃ -; ┣━━╉──┨ -; ┃ 5 ┃ 0 ┃ -; ┣━━╉──┨ -; ┃ 4 ┃ AVL┃ -; 字节 6 ┣━━╉──┨ -; ┃ 3 ┃ ┃ -; ┣━━┫ 段 ┃ -; ┃ 2 ┃ 界 ┃ -; ┣━━┫ 限 ┃ -; ┃ 1 ┃ ┃ -; ┣━━┫ ② ┃ -; ┃ 0 ┃ ┃ -; ------ ┣━━╋━━┫ -; ┃ 7 ┃ P ┃ -; ┣━━╉──┨ -; ┃ 6 ┃ ┃ -; ┣━━┫ DPL┃ -; ┃ 5 ┃ ┃ -; ┣━━╉──┨ -; ┃ 4 ┃ S ┃ -; 字节 5 ┣━━╉──┨ -; ┃ 3 ┃ ┃ -; ┣━━┫ T ┃ -; ┃ 2 ┃ Y ┃ -; ┣━━┫ P ┃ -; ┃ 1 ┃ E ┃ -; ┣━━┫ ┃ -; ┃ 0 ┃ ┃ -; ------ ┣━━╋━━┫ -; ┃ 23 ┃ ┃ -; ┣━━┫ ┃ -; ┃ 22 ┃ ┃ -; ┣━━┫ 段 ┃ -; -; 字节 ┆ ┆ 基 ┆ -; 2, 3, 4 -; ┣━━┫ 址 ┃ -; ┃ 1 ┃ ① ┃ -; ┣━━┫ ┃ -; ┃ 0 ┃ ┃ -; ------ ┣━━╋━━┫ -; ┃ 15 ┃ ┃ -; ┣━━┫ ┃ -; ┃ 14 ┃ ┃ -; ┣━━┫ 段 ┃ -; -; 字节 0,1┆ ┆ 界 ┆ -; -; ┣━━┫ 限 ┃ -; ┃ 1 ┃ ① ┃ -; ┣━━┫ ┃ -; ┃ 0 ┃ ┃ -; ------ ┗━━┻━━┛低地址 -; - - -; 图示二 - -; 高地址………………………………………………………………………低地址 - -; | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | -; |7654321076543210765432107654321076543210765432107654321076543210| <- 共 8 字节 -; |--------========--------========--------========--------========| -; ┏━━━┳━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓ -; ┃31..24┃ (见下图) ┃ 段基址(23..0) ┃ 段界限(15..0)┃ -; ┃ ┃ ┃ ┃ ┃ -; ┃ 基址2┃③│②│ ①┃基址1b│ 基址1a ┃ 段界限1 ┃ -; ┣━━━╋━━━┳━━━╋━━━━━━━━━━━╋━━━━━━━┫ -; ┃ %6 ┃ %5 ┃ %4 ┃ %3 ┃ %2 ┃ %1 ┃ -; ┗━━━┻━━━┻━━━┻━━━┻━━━━━━━┻━━━━━━━┛ -; │ \_________ -; │ \__________________ -; │ \________________________________________________ -; │ \ -; ┏━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┓ -; ┃ 7 ┃ 6 ┃ 5 ┃ 4 ┃ 3 ┃ 2 ┃ 1 ┃ 0 ┃ 7 ┃ 6 ┃ 5 ┃ 4 ┃ 3 ┃ 2 ┃ 1 ┃ 0 ┃ -; ┣━━╋━━╋━━╋━━╋━━┻━━┻━━┻━━╋━━╋━━┻━━╋━━╋━━┻━━┻━━┻━━┫ -; ┃ G ┃ D ┃ 0 ┃ AVL┃ 段界限 2 (19..16) ┃ P ┃ DPL ┃ S ┃ TYPE ┃ -; ┣━━┻━━┻━━┻━━╋━━━━━━━━━━━╋━━┻━━━━━┻━━┻━━━━━━━━━━━┫ -; ┃ ③: 属性 2 ┃ ②: 段界限 2 ┃ ①: 属性1 ┃ -; ┗━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━┛ -; 高地址 低地址 -; -; - -; 说明: -; -; (1) P: 存在(Present)位。 -; P=1 表示描述符对地址转换是有效的,或者说该描述符所描述的段存在,即在内存中; -; P=0 表示描述符对地址转换无效,即该段不存在。使用该描述符进行内存访问时会引起异常。 -; -; (2) DPL: 表示描述符特权级(Descriptor Privilege level),共2位。它规定了所描述段的特权级,用于特权检查,以决定对该段能否访问。 -; -; (3) S: 说明描述符的类型。 -; 对于存储段描述符而言,S=1,以区别与系统段描述符和门描述符(S=0)。 -; -; (4) TYPE: 说明存储段描述符所描述的存储段的具体属性。 -; -; -; 数据段类型 类型值 说明 -; ---------------------------------- -; 0 只读 -; 1 只读、已访问 -; 2 读/写 -; 3 读/写、已访问 -; 4 只读、向下扩展 -; 5 只读、向下扩展、已访问 -; 6 读/写、向下扩展 -; 7 读/写、向下扩展、已访问 -; -; -; 类型值 说明 -; 代码段类型 ---------------------------------- -; 8 只执行 -; 9 只执行、已访问 -; A 执行/读 -; B 执行/读、已访问 -; C 只执行、一致码段 -; D 只执行、一致码段、已访问 -; E 执行/读、一致码段 -; F 执行/读、一致码段、已访问 -; -; -; 系统段类型 类型编码 说明 -; ---------------------------------- -; 0 <未定义> -; 1 可用286TSS -; 2 LDT -; 3 忙的286TSS -; 4 286调用门 -; 5 任务门 -; 6 286中断门 -; 7 286陷阱门 -; 8 未定义 -; 9 可用386TSS -; A <未定义> -; B 忙的386TSS -; C 386调用门 -; D <未定义> -; E 386中断门 -; F 386陷阱门 -; -; (5) G: 段界限粒度(Granularity)位。 -; G=0 表示界限粒度为字节; -; G=1 表示界限粒度为4K 字节。 -; 注意,界限粒度只对段界限有效,对段基地址无效,段基地址总是以字节为单位。 -; -; (6) D: D位是一个很特殊的位,在描述可执行段、向下扩展数据段或由SS寄存器寻址的段(通常是堆栈段)的三种描述符中的意义各不相同。 -; ⑴ 在描述可执行段的描述符中,D位决定了指令使用的地址及操作数所默认的大小。 -; ① D=1表示默认情况下指令使用32位地址及32位或8位操作数,这样的代码段也称为32位代码段; -; ② D=0 表示默认情况下,使用16位地址及16位或8位操作数,这样的代码段也称为16位代码段,它与80286兼容。可以使用地址大小前缀和操作数大小前缀分别改变默认的地址或操作数的大小。 -; ⑵ 在向下扩展数据段的描述符中,D位决定段的上部边界。 -; ① D=1表示段的上部界限为4G; -; ② D=0表示段的上部界限为64K,这是为了与80286兼容。 -; ⑶ 在描述由SS寄存器寻址的段描述符中,D位决定隐式的堆栈访问指令(如PUSH和POP指令)使用何种堆栈指针寄存器。 -; ① D=1表示使用32位堆栈指针寄存器ESP; -; ② D=0表示使用16位堆栈指针寄存器SP,这与80286兼容。 -; -; (7) AVL: 软件可利用位。80386对该位的使用未左规定,Intel公司也保证今后开发生产的处理器只要与80386兼容,就不会对该位的使用做任何定义或规定。 -; - - -;---------------------------------------------------------------------------- -; 描述符类型值说明 -; 其中: -; DA_ : Descriptor Attribute -; D : 数据段 -; C : 代码段 -; S : 系统段 -; R : 只读 -; RW : 读写 -; A : 已访问 -; 其它 : 可按照字面意思理解 -;---------------------------------------------------------------------------- -DA_32 EQU 4000h ; 32 位段 -DA_LIMIT_4K EQU 8000h ; 段界限粒度为 4K 字节 - -DA_DPL0 EQU 00h ; DPL = 0 -DA_DPL1 EQU 20h ; DPL = 1 -DA_DPL2 EQU 40h ; DPL = 2 -DA_DPL3 EQU 60h ; DPL = 3 -;---------------------------------------------------------------------------- -; 存储段描述符类型值说明 -;---------------------------------------------------------------------------- -DA_DR EQU 90h ; 存在的只读数据段类型值 -DA_DRW EQU 92h ; 存在的可读写数据段属性值 -DA_DRWA EQU 93h ; 存在的已访问可读写数据段类型值 -DA_C EQU 98h ; 存在的只执行代码段属性值 -DA_CR EQU 9Ah ; 存在的可执行可读代码段属性值 -DA_CCO EQU 9Ch ; 存在的只执行一致代码段属性值 -DA_CCOR EQU 9Eh ; 存在的可执行可读一致代码段属性值 -;---------------------------------------------------------------------------- -; 系统段描述符类型值说明 -;---------------------------------------------------------------------------- -DA_LDT EQU 82h ; 局部描述符表段类型值 -DA_TaskGate EQU 85h ; 任务门类型值 -DA_386TSS EQU 89h ; 可用 386 任务状态段类型值 -DA_386CGate EQU 8Ch ; 386 调用门类型值 -DA_386IGate EQU 8Eh ; 386 中断门类型值 -DA_386TGate EQU 8Fh ; 386 陷阱门类型值 -;---------------------------------------------------------------------------- - - -; 选择子图示: -; ┏━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┓ -; ┃ 15 ┃ 14 ┃ 13 ┃ 12 ┃ 11 ┃ 10 ┃ 9 ┃ 8 ┃ 7 ┃ 6 ┃ 5 ┃ 4 ┃ 3 ┃ 2 ┃ 1 ┃ 0 ┃ -; ┣━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━╋━━╋━━┻━━┫ -; ┃ 描述符索引 ┃ TI ┃ RPL ┃ -; ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━┻━━━━━┛ -; -; RPL(Requested Privilege Level): 请求特权级,用于特权检查。 -; -; TI(Table Indicator): 引用描述符表指示位 -; TI=0 指示从全局描述符表GDT中读取描述符; -; TI=1 指示从局部描述符表LDT中读取描述符。 -; - -;---------------------------------------------------------------------------- -; 选择子类型值说明 -; 其中: -; SA_ : Selector Attribute - -SA_RPL0 EQU 0 ; ┓ -SA_RPL1 EQU 1 ; ┣ RPL -SA_RPL2 EQU 2 ; ┃ -SA_RPL3 EQU 3 ; ┛ - -SA_TIG EQU 0 ; ┓TI -SA_TIL EQU 4 ; ┛ -;---------------------------------------------------------------------------- - - -;---------------------------------------------------------------------------- -; 分页机制使用的常量说明 -;---------------------------------------------------------------------------- -PG_P EQU 1 ; 页存在属性位 -PG_RWR EQU 0 ; R/W 属性位值, 读/执行 -PG_RWW EQU 2 ; R/W 属性位值, 读/写/执行 -PG_USS EQU 0 ; U/S 属性位值, 系统级 -PG_USU EQU 4 ; U/S 属性位值, 用户级 -;---------------------------------------------------------------------------- - - - - -; ========================================= -; FLAGS - Intel 8086 Family Flags Register -; ========================================= -; -; |11|10|F|E|D|C|B|A|9|8|7|6|5|4|3|2|1|0| -; | | | | | | | | | | | | | | | | | '--- CF……Carry Flag -; | | | | | | | | | | | | | | | | '--- 1 -; | | | | | | | | | | | | | | | '--- PF……Parity Flag -; | | | | | | | | | | | | | | '--- 0 -; | | | | | | | | | | | | | '--- AF……Auxiliary Flag -; | | | | | | | | | | | | '--- 0 -; | | | | | | | | | | | '--- ZF……Zero Flag -; | | | | | | | | | | '--- SF……Sign Flag -; | | | | | | | | | '--- TF……Trap Flag (Single Step) -; | | | | | | | | '--- IF……Interrupt Flag -; | | | | | | | '--- DF……Direction Flag -; | | | | | | '--- OF……Overflow flag -; | | | | '----- IOPL……I/O Privilege Level (286+ only) -; | | | '----- NT……Nested Task Flag (286+ only) -; | | '----- 0 -; | '----- RF……Resume Flag (386+ only) -; '------ VM……Virtual Mode Flag (386+ only) -; -; 注: see PUSHF POPF STI CLI STD CLD -; - - -; 宏 ------------------------------------------------------------------------------------------------------ -; -; 描述符 -; usage: Descriptor Base, Limit, Attr -; Base: dd -; Limit: dd (low 20 bits available) -; Attr: dw (lower 4 bits of higher byte are always 0) -%macro Descriptor 3 - dw %2 & 0FFFFh ; 段界限 1 (2 字节) - dw %1 & 0FFFFh ; 段基址 1 (2 字节) - db (%1 >> 16) & 0FFh ; 段基址 2 (1 字节) - dw ((%2 >> 8) & 0F00h) | (%3 & 0F0FFh) ; 属性 1 + 段界限 2 + 属性 2 (2 字节) - db (%1 >> 24) & 0FFh ; 段基址 3 (1 字节) -%endmacro ; 共 8 字节 -; -; 门 -; usage: Gate Selector, Offset, DCount, Attr -; Selector: dw -; Offset: dd -; DCount: db -; Attr: db -%macro Gate 4 - dw (%2 & 0FFFFh) ; 偏移 1 (2 字节) - dw %1 ; 选择子 (2 字节) - dw (%3 & 1Fh) | ((%4 << 8) & 0FF00h) ; 属性 (2 字节) - dw ((%2 >> 16) & 0FFFFh) ; 偏移 2 (2 字节) -%endmacro ; 共 8 字节 -; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/misc/legacy_bootloader/kalib/_asm_KeGraph32.asm b/misc/legacy_bootloader/kalib/_asm_KeGraph32.asm deleted file mode 100644 index bab9eea..0000000 --- a/misc/legacy_bootloader/kalib/_asm_KeGraph32.asm +++ /dev/null @@ -1,318 +0,0 @@ -;===================================================================32 BITS============================================================= - -global __asm_KePrintHex32 ;VOID __asm_KePrintHex32(ULONG32 Hex) -global __asm_KePrintStr32 ;VOID __asm_KePrintStr32(PCHAR *OffsetStr) -global __asm_KeSetGraphPosition32; ULONG32 __asm_KeSetGraphPosition32(ULONG32 Row,ULONG32 Column) -global __asm_KeClearGraph32;VOID __asm_KeClearGraph32() -global __asm_KeGraphRowOverflow;ULONG32 _asm_KeGraphRowOverflow32(ULONG32 GraphPosition) -global __asm_KeGetCurrentGraphPosition32; ULONG32 _asm_KeGetCurrentGraphPosition32(VOID); - -extern _KeCheckGraphRowForPrint -extern _KeCheckGraphRowForReturn - -SLCT_GRAPH equ 8 -SLCT_FLAT_C equ 16 -SLCT_FLAT_RW equ 24 - -KeGraphPosition_32 dd 0 - -DOSGRAPHROW equ 25 -DOSGRAPHCOLUMN equ 80 - -__asm_KeGetCurrentGraphPosition32: -mov eax, dword [ds:KeGraphPosition_32] -ret - -__asm_KeSetGraphPosition32: -push ebp -mov ebp,esp -push esi -push edi -push ebx -push edx - -mov eax,dword [ss:ebp+8] -mov ebx,dword [ss:ebp+12] -cmp eax,DOSGRAPHROW-1 -ja .fault -cmp ebx,DOSGRAPHCOLUMN-1 -ja .fault - -mov dl,2*DOSGRAPHCOLUMN -mul dl - -mov esi,eax - -xor eax,eax - -mov al,bl -mov dl,2 -mul dl - -add eax,esi - -mov dword [ds:KeGraphPosition_32],eax -jmp .return -.fault: -mov dword [ds:KeGraphPosition_32],0 -xor eax,eax -.return: -pop edx -pop ebx -pop edi -pop esi -mov esp,ebp -pop ebp -ret - -__asm_KeClearGraph32: -push ecx -push esi -mov ecx,2*DOSGRAPHROW*DOSGRAPHCOLUMN-1 -xor esi,esi -.loop: -mov byte [gs:esi],0 -dec ecx -inc esi -cmp ecx,0 -jne .loop -mov dword [KeGraphPosition_32],0 -pop esi -pop ecx -ret - - - -__asm_KePrintHex32: -;Entrance: push HEX -push ebp -mov ebp,esp -push eax - -mov eax,dword [ss:ebp+8] -shr eax,24 -mov ah,0Fh -push ax -call near DISPINTAL32 -pop ax - -mov eax,dword [ss:ebp+8] -shr eax,16 -mov ah,0Fh -push ax -call near DISPINTAL32 -pop ax - -mov eax,dword [ss:ebp+8] -shr eax,8 -mov ah,0Fh -push ax -call near DISPINTAL32 -pop ax - -mov eax,dword [ss:ebp+8] -mov ah,0Fh -push ax -call near DISPINTAL32 -pop ax - -pop eax -mov esp,ebp -pop ebp -ret - -__asm_KePrintStr32: -;Entrance: push offset -;ds:offset = String -push ebp -mov ebp,esp -push esi -push edi -push eax -push ebx -push gs - -mov ax,SLCT_GRAPH -mov gs,ax -mov esi,dword [ss:ebp+8] -mov edi,dword [ds:KeGraphPosition_32] -.loop1: -mov al,byte [ds:esi] -cmp al,0 -je .end -cmp al,0Ah -jne .loop2 -;Check For OverFlow -push eax -push edi -call _KeCheckGraphRowForReturn -add esp,4 -mov edi,eax -pop eax -;let edi point to the next row -;edi/(80*2) - every row:80 chars, each char takes 2 bytes. -push eax -mov eax,edi -mov bl,2*DOSGRAPHCOLUMN -div bl -;only keep the low 8 of eax(al,aka quotion) -and eax, 0FFh -inc eax -;calculate the edi now -mov bl,2*DOSGRAPHCOLUMN -mul bl -mov edi,eax -pop eax -inc esi -jmp .loop1 -.loop2: -;Check For OverFlow -push eax - -push edi -call _KeCheckGraphRowForPrint -add esp,4 - -mov edi,eax -pop eax -;====== -mov ah,0Fh -mov word [gs:edi],ax -add edi,2 -inc esi -jmp .loop1 -.end: -mov dword [ds:KeGraphPosition_32],edi - -pop gs -pop ebx -pop eax -pop edi -pop esi -mov esp,ebp -pop ebp -ret - -DISPINTAL32: -;Entrance: push ax ,AH=ATTR, AL=Char -push ebp -mov ebp,esp -push eax -push gs -push ecx -push edi -push ebx - -mov edi,dword [ds:KeGraphPosition_32] -mov ax,SLCT_GRAPH -mov gs,ax -xor eax,eax -mov ax, word [ss:ebp+8] -mov bx,ax -;keep high 4 bits of al -and al,0F0H -mov cl,4 -shr al,cl -call near CHANGEAL -;Check For OverFlow -push eax - -push edi -call _KeCheckGraphRowForPrint -add esp,4 - -mov edi,eax -pop eax -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -mov word [gs:edi],ax -add edi,2 -mov dword [ds:KeGraphPosition_32],edi -;keep low 4 bits of al -mov ax,bx -and al,0Fh -call near CHANGEAL -mov ah,bh -mov word [gs:edi],ax -add edi,2 -mov dword [ds:KeGraphPosition_32],edi - -pop ebx -pop edi -pop ecx -pop gs -pop eax -pop ebp -ret - -CHANGEAL: -;Entrance:void -cmp al,09h -jna .l2 -add al,37h -jmp .end -.l2: -add al,30h -.end: -ret - -__asm_KeGraphRowOverflow: -push ebp -mov ebp,esp -push esi -push edi -push edx -push ecx -push ebx - -mov eax,[ss:ebp+8] -xor esi,esi -xor edi,edi - -mov esi,2*DOSGRAPHCOLUMN - -mov ebx,DOSGRAPHROW - -.loop1: -mov ecx,2*DOSGRAPHCOLUMN-1 -.loop2: -mov dl,byte [gs:esi] -mov byte [gs:edi],dl -inc edi -inc esi -dec ecx -cmp ecx,0 -jne .loop2 - -dec ebx -cmp ebx,0 -jne .loop1 - -push 0 -push 24 -call __asm_KeSetGraphPosition32 -add esp,8 - -mov ecx,2*DOSGRAPHCOLUMN -.loop3: -mov byte [gs:eax],0 -inc eax -dec ecx -cmp ecx,0 -jne .loop3 - - -push 0 -push 24 -call __asm_KeSetGraphPosition32 -add esp,8 - -pop ebx -pop ecx -pop edx -pop edi -pop esi -mov esp,ebp -pop ebp -ret - - diff --git a/misc/legacy_bootloader/kalib/_asm_KeIO32.asm b/misc/legacy_bootloader/kalib/_asm_KeIO32.asm deleted file mode 100644 index 33a08a6..0000000 --- a/misc/legacy_bootloader/kalib/_asm_KeIO32.asm +++ /dev/null @@ -1,257 +0,0 @@ -global __asm_KeWritePort;VOID _asm_KeWritePort(ULONG16 Port,ULONG8 Value); -global __asm_KeReadPort;ULONG8 _asm_KeReadPort(ULONG16 Port); -global __asm_KeLoadIDT;VOID _asm_KeLoadIDT(VOID) -global __asm_KeWriteGDT; VOID _asm_KeWriteGDT(PGDT_DESCRIPTOR DescBase ,PWrite_GDT_DESCRIPTOR PDescriptor, ULONG32 index); -;IDT DESC -global __asm_KeDivideError -global __asm_KeSingleStepException -global __asm_KeNMI -global __asm_KeBreakpointException -global __asm_KeOverflow -global __asm_KeBoundsCheck -global __asm_KeInvalidOpcode -global __asm_KeCoprNotAvailable -global __asm_KeDoubleFault -global __asm_KeCoprSegmentOverrun -global __asm_KeInvalidTSS -global __asm_KeSegmentNotPresent -global __asm_KeStackException -global __asm_KeGeneralProtection -global __asm_KePageFault -global __asm_KeCoprError -;8259A Interrupts -global __asm_KeIrqInt00 -global __asm_KeIrqInt01 -global __asm_KeIrqInt02 -global __asm_KeIrqInt03 -global __asm_KeIrqInt04 -global __asm_KeIrqInt05 -global __asm_KeIrqInt06 -global __asm_KeIrqInt07 -global __asm_KeIrqInt08 -global __asm_KeIrqInt09 -global __asm_KeIrqInt10 -global __asm_KeIrqInt11 -global __asm_KeIrqInt12 -global __asm_KeIrqInt13 -global __asm_KeIrqInt14 -global __asm_KeIrqInt15 - -global __asm_EIP2EAX - -extern _KeIrqIntHandler -extern _KeIDTPtr -extern _KeExceptionHandler - -SLCT_FLAT_C equ 16 - - - - -__asm_EIP2EAX: - mov eax, [esp] - ret - -__asm_KeReadPort: - mov edx, [esp + 4] - xor eax, eax - in al, dx - nop - nop - ret -;push ebp -;mov ebp,esp -;push edx -;mov edx,[ss:ebp+8] -;xor eax,eax -;in al,dx -;nop -;nop -;nop -;pop edx -;pop ebp -;ret - -__asm_KeWritePort: - mov edx, [esp + 4] - mov al, [esp + 4 + 4] - out dx, al - nop - nop - ret - -;push ebp -;mov ebp,esp -;push edx -;push eax -;mov edx,[ss:ebp+8] -;mov eax,[ss:ebp+12] -;out dx,al -;nop -;nop -;nop -;pop eax -;pop edx -;ret - -__asm_KeLoadIDT: -lidt [_KeIDTPtr] -jmp SLCT_FLAT_C:.force -.force: -sti -ret - -__asm_KeDivideError: -push 0xFFFFFFFF -push 0 -jmp exception - -__asm_KeSingleStepException: -push 0xFFFFFFFF -push 1 -jmp exception - -__asm_KeNMI: -push 0xFFFFFFFF -push 2 -jmp exception - -__asm_KeBreakpointException: -push 0xFFFFFFFF -push 3 -jmp exception - -__asm_KeOverflow: -push 0xFFFFFFFF -push 4 -jmp exception - -__asm_KeBoundsCheck: -push 0xFFFFFFFF -push 5 -jmp exception - -__asm_KeInvalidOpcode: -push 0xFFFFFFFF -push 6 -jmp exception - -__asm_KeCoprNotAvailable: -push 0xFFFFFFFF -push 7 -jmp exception - -__asm_KeDoubleFault: -push 0xFFFFFFFF -push 8 -jmp exception - -__asm_KeCoprSegmentOverrun: -push 0xFFFFFFFF -push 9 -jmp exception - -__asm_KeInvalidTSS: -push 0xFFFFFFFF -push 10 -jmp exception - -__asm_KeSegmentNotPresent: -push 0xFFFFFFFF -push 11 -jmp exception - -__asm_KeStackException: -push 0xFFFFFFFF -push 12 -jmp exception - -__asm_KeGeneralProtection: -push 0xFFFFFFFF -push 13 -jmp exception - -__asm_KePageFault: -push 0xFFFFFFFF -push 14 -jmp exception - -__asm_KeCoprError: -push 0xFFFFFFFF -push 15 -jmp exception - -exception: -call _KeExceptionHandler -add esp,8 -hlt - -__asm_KeIrqInt00: -push 0 -jmp interrupt - -__asm_KeIrqInt01: -push 1 -jmp interrupt - -__asm_KeIrqInt02: -push 2 -jmp interrupt - -__asm_KeIrqInt03: -push 3 -jmp interrupt - -__asm_KeIrqInt04: -push 4 -jmp interrupt - -__asm_KeIrqInt05: -push 5 -jmp interrupt - -__asm_KeIrqInt06: -push 6 -jmp interrupt - -__asm_KeIrqInt07: -push 7 -jmp interrupt - -__asm_KeIrqInt08: -push 8 -jmp interrupt - -__asm_KeIrqInt09: -push 9 -jmp interrupt - -__asm_KeIrqInt10: -push 10 -jmp interrupt - -__asm_KeIrqInt11: -push 11 -jmp interrupt - -__asm_KeIrqInt12: -push 12 -jmp interrupt - -__asm_KeIrqInt13: -push 13 -jmp interrupt - -__asm_KeIrqInt14: -push 14 -jmp interrupt - -__asm_KeIrqInt15: -push 15 -jmp interrupt - -interrupt: -call _KeIrqIntHandler -add esp,4 -hlt - diff --git a/misc/legacy_bootloader/kalib/_asm_KeMemory32.asm b/misc/legacy_bootloader/kalib/_asm_KeMemory32.asm deleted file mode 100644 index 3359303..0000000 --- a/misc/legacy_bootloader/kalib/_asm_KeMemory32.asm +++ /dev/null @@ -1,34 +0,0 @@ -SLCT_GRAPH equ 8 -SLCT_FLAT_C equ 16 -SLCT_FLAT_RW equ 24 -global __asm_KeMemoryCopy;PVOID _asm_KeMemoryCopy(PVOID src,PVOID dst,ULONG32 size) -__asm_KeMemoryCopy: -push ebp -mov ebp,esp -push esi -push edi -push ecx - -mov ax,SLCT_FLAT_RW -mov es,ax -mov esi,dword [ss:ebp+8] -mov edi,dword [ss:ebp+12] -mov ecx,dword [ss:ebp+16] - -.loop: -mov al,byte [es:esi] -mov byte [ds:edi],al -inc esi -inc edi -dec ecx -cmp ecx,0 -je .end -jmp .loop -.end: -mov eax,dword [ss:ebp+8] - -pop ecx -pop edi -pop esi -pop ebp -ret \ No newline at end of file diff --git a/misc/legacy_bootloader/kalib/_asm_KeProcess32.asm b/misc/legacy_bootloader/kalib/_asm_KeProcess32.asm deleted file mode 100644 index 77dbdd5..0000000 --- a/misc/legacy_bootloader/kalib/_asm_KeProcess32.asm +++ /dev/null @@ -1,56 +0,0 @@ -P_STACKBASE equ 0 -GSREG equ P_STACKBASE -FSREG equ GSREG + 4 -ESREG equ FSREG + 4 -DSREG equ ESREG + 4 -EDIREG equ DSREG + 4 -ESIREG equ EDIREG + 4 -EBPREG equ ESIREG + 4 -KERNELESPREG equ EBPREG + 4 -EBXREG equ KERNELESPREG + 4 -EDXREG equ EBXREG + 4 -ECXREG equ EDXREG + 4 -EAXREG equ ECXREG + 4 -RETADR equ EAXREG + 4 -EIPREG equ RETADR + 4 -CSREG equ EIPREG + 4 -EFLAGSREG equ CSREG + 4 -ESPREG equ EFLAGSREG + 4 -SSREG equ ESPREG + 4 -P_STACKTOP equ SSREG + 4 -P_LDT_SEL equ P_STACKTOP -P_LDT equ P_LDT_SEL + 2 -TSS3_S_SP0 equ 4 - -extern _KeTSS -extern _PStartProcess - - -global __asm_KeLoadTSS; -global __asm_Restart; - -__asm_KeLoadTSS: -push ebp -mov ebp,esp -push eax -;mov eax,dword [ss:ebp+8] -mov eax,56 -ltr ax -pop eax -mov esp,ebp -pop ebp -ret - - -__asm_Restart: -mov esp,[_PStartProcess] -lea eax,[esp+P_STACKTOP] -mov dword [_KeTSS+TSS3_S_SP0],eax - -pop gs -pop fs -pop es -pop ds -popad -add esp,4 -iretd diff --git a/misc/legacy_bootloader/kalib/io32.asm b/misc/legacy_bootloader/kalib/io32.asm deleted file mode 100644 index 959d781..0000000 --- a/misc/legacy_bootloader/kalib/io32.asm +++ /dev/null @@ -1,23 +0,0 @@ -global _HkWritePort32 ; void HkWritePort32(uint16 port ,uint16 data) -push ebp -mov ebp,esp -mov edx,[ ebp + 8 ] -mov eax,[ ebp + 12 ] -out dx,ax -nop -nop -mov esp,ebp -pop ebp -ret - -global _HkReadPort32 ; void HkWritePort32(uint16 port ,uint16 data) -push ebp -mov ebp,esp -mov edx,[ ebp + 8] -mov eax,[ ebp + 12] -in ax,dx -nop -nop -mov esp,ebp -pop ebp -ret diff --git a/misc/legacy_bootloader/kernel/kernel.asm b/misc/legacy_bootloader/kernel/kernel.asm deleted file mode 100644 index e3e0ab2..0000000 --- a/misc/legacy_bootloader/kernel/kernel.asm +++ /dev/null @@ -1,36 +0,0 @@ -extern _KeSystemInit -extern _KeGDTPtr -extern _KeSwitchGDT -extern _KeIDTPtr -global _start -;GDT -SLCT_GRAPH equ 8 -SLCT_FLAT_C equ 16 -SLCT_FLAT_RW equ 24 -;Stack -[section .bss] -[BITS 32] -resb 2 * 1024 -KernelStackTop: -[section .text] -[BITS 32] -_start: -mov esp,KernelStackTop - -sgdt [_KeGDTPtr] -call _KeSwitchGDT -lgdt [_KeGDTPtr] -jmp SLCT_FLAT_C:GDT_COMPLETE -GDT_COMPLETE: - -mov ax,SLCT_GRAPH -mov gs,ax -mov ax,SLCT_FLAT_RW -mov ds,ax -mov ss,ax - -push 0 -popfd - - -call _KeSystemInit diff --git a/mk/grub.cfg b/mk/grub.cfg new file mode 100644 index 0000000..73fa1c8 --- /dev/null +++ b/mk/grub.cfg @@ -0,0 +1,3 @@ +menuentry "secX" { + multiboot2 /secX/secxkrnl.elf +} \ No newline at end of file diff --git a/linker.ld b/mk/linker.ld similarity index 100% rename from linker.ld rename to mk/linker.ld diff --git a/test/Rules.mk b/test/Rules.mk new file mode 100644 index 0000000..b9fd3fc --- /dev/null +++ b/test/Rules.mk @@ -0,0 +1,18 @@ +include $(MK)/prologue.mk + +SRC_$(d) := avl_tree_test.c \ + driver.c \ + linked_list_test.c \ + salloc_test.c + +SRC_$(d) := $(addprefix $(d)/, $(SRC_$(d))) + +OBJ_$(d) := $(SRC_$(d):.c=.o) + +$(OBJ_$(d)): %.o: %.c + $(COMP) + +# append all OBJECTS to clean +OBJ := $(OBJ) $(OBJ_$(d)) + +include $(MK)/epilogue.mk \ No newline at end of file diff --git a/test/avl_tree_test.c b/test/avl_tree_test.c index af0dd83..f3fd223 100644 --- a/test/avl_tree_test.c +++ b/test/avl_tree_test.c @@ -69,7 +69,7 @@ static bool pre_order_assert(avl_tree_t *node, int order[], int size) //////// TESTS///////// -static bool insert_simple_l() +static bool insert_simple_l(void) { //1 2 // \ / \ @@ -93,7 +93,7 @@ static bool insert_simple_l() return result && lb_avl_tree_validate(&tree); } -static bool insert_simple_r() +static bool insert_simple_r(void) { // 3 2 // / / \ @@ -117,7 +117,7 @@ static bool insert_simple_r() return result && lb_avl_tree_validate(&tree); } -static bool insert_simple_ll() +static bool insert_simple_ll(void) { //2 3 // \ / \ @@ -140,7 +140,7 @@ static bool insert_simple_ll() return result && lb_avl_tree_validate(&tree); } -static bool insert_simple_rr() +static bool insert_simple_rr(void) { // 4 3 // / / \ @@ -163,7 +163,7 @@ static bool insert_simple_rr() return result && lb_avl_tree_validate(&tree); } -static bool insert_complex_1() +static bool insert_complex_1(void) { // 20+ 20++ 20++ 9 // / \ / \ / \ / \ @@ -191,7 +191,7 @@ static bool insert_complex_1() return result && lb_avl_tree_validate(&tree); } -static bool insert_complex_2() +static bool insert_complex_2(void) { // 20+ 20++ 20++ 9 // / \ / \ / \ / \ @@ -219,7 +219,7 @@ static bool insert_complex_2() return result && lb_avl_tree_validate(&tree); } -static bool insert_complex_3() +static bool insert_complex_3(void) { // __20+__ _20++_ __20++_ ___9___ // / \ / \ / \ / \ @@ -254,7 +254,7 @@ static bool insert_complex_3() return result && lb_avl_tree_validate(&tree); } -static bool insert_complex_4() +static bool insert_complex_4(void) { // __20+__ _20++_ __20++_ ___9___ // / \ / \ / \ / \ @@ -289,7 +289,7 @@ static bool insert_complex_4() return result && lb_avl_tree_validate(&tree); } -static bool insert_duplicate() +static bool insert_duplicate(void) { // __20+__ _20++_ __20++_ ___9___ // / \ / \ / \ / \ @@ -327,7 +327,7 @@ static bool insert_duplicate() } -static bool delete_simple_l() +static bool delete_simple_l(void) { // 2 3 // x \ / \ @@ -355,7 +355,7 @@ static bool delete_simple_l() return result && lb_avl_tree_validate(&tree); } -static bool delete_simple_r() +static bool delete_simple_r(void) { // 3 2 // / x / \ @@ -383,7 +383,7 @@ static bool delete_simple_r() return result && lb_avl_tree_validate(&tree); } -static bool delete_simple_ll() +static bool delete_simple_ll(void) { // 2 3 // x \ / \ @@ -410,7 +410,7 @@ static bool delete_simple_ll() return result && lb_avl_tree_validate(&tree); } -static bool delete_simple_rr() +static bool delete_simple_rr(void) { // 3 2 // / x / \ @@ -437,7 +437,7 @@ static bool delete_simple_rr() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_1() +static bool delete_complex_1(void) { // Test Case #1 // - A single node tree has its only node removed. @@ -464,7 +464,7 @@ static bool delete_complex_1() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_2() +static bool delete_complex_2(void) { // Test Case #2 // - A small tree has its root removed. @@ -507,7 +507,7 @@ static bool delete_complex_2() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_3() +static bool delete_complex_3(void) { // Test Case #3 // - A small tree has a node with 2 children removed @@ -547,7 +547,7 @@ static bool delete_complex_3() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_4() +static bool delete_complex_4(void) { // Test Case #4 // - A small tree has all nodes but the root removed from the bottom up. @@ -596,7 +596,7 @@ static bool delete_complex_4() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_single_rotation() +static bool delete_complex_single_rotation(void) { // Test case single rotation // @@ -651,7 +651,7 @@ static bool delete_complex_single_rotation() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_double_rotation() +static bool delete_complex_double_rotation(void) { // Test case double rotation // @@ -706,7 +706,7 @@ static bool delete_complex_double_rotation() return result && lb_avl_tree_validate(&tree); } -static bool delete_complex_multiple_rotation() +static bool delete_complex_multiple_rotation(void) { // Test case multiple rotation // @@ -761,7 +761,7 @@ static bool delete_complex_multiple_rotation() return result && lb_avl_tree_validate(&tree); } -static bool delete_DNE() +static bool delete_DNE(void) { // Test case DNE // Delete a node that does not exist @@ -808,7 +808,7 @@ static bool delete_DNE() #define AVL_APOCALYPSE_ITER 2 static int_tree_node apocalypse[AVL_APOCALYPSE_NUM]; -static bool test_apocalypse() +static bool test_apocalypse(void) { bool result = true; avl_tree_t tree; @@ -817,10 +817,10 @@ static bool test_apocalypse() // insert test for(int i = 0; i < AVL_APOCALYPSE_NUM; i++) { - apocalypse[i].val = rand(); + apocalypse[i].val = lb_rand(); while(lb_avl_tree_search(&tree, &apocalypse[i].tree_entry) != NULL) { - apocalypse[i].val += rand() % 32765; + apocalypse[i].val += lb_rand() % 32765; } lb_avl_tree_insert(&tree, &apocalypse[i].tree_entry); } @@ -927,7 +927,7 @@ void avl_tree_test(void) // delete non-existing run_case("delete_DNE", delete_DNE()); - srand(2986); + lb_srand(2986); // ultimate apocalypse for(int i = 0; i < AVL_APOCALYPSE_ITER; i++) { diff --git a/test/driver.c b/test/driver.c index 45d92a2..5f2e010 100644 --- a/test/driver.c +++ b/test/driver.c @@ -16,17 +16,17 @@ static case_info ginfo[CASE_NUM]; static void *gat[GAT_SIZE]; static char *test_name; -static void test_info() +static void test_info(void) { ke_printf("[TD-INFO][%s] - ", test_name); } -static void test_warning() +static void test_warning(void) { ke_printf("[TD-WARN][%s] - ", test_name); } -static void test_error() +static void test_error(void) { ke_printf("[TD-ERR][%s] - ", test_name); } @@ -43,7 +43,7 @@ static void gat_push(void *ptr) } } -static bool gat_full() +static bool gat_full(void) { for (int i = 0; i < GAT_SIZE; i++) { @@ -55,7 +55,7 @@ static bool gat_full() return true; } -static void gat_free() +static void gat_free(void) { for (int i = 0; i < GAT_SIZE; i++) { @@ -97,7 +97,7 @@ void KABI test_begin(char *name) } } -void KABI test_end() +void KABI test_end(void) { gat_free(); int32_t total = 0, failed = 0, success = 0; diff --git a/test/linked_list_test.c b/test/linked_list_test.c index 6d3f897..a1684c1 100644 --- a/test/linked_list_test.c +++ b/test/linked_list_test.c @@ -118,7 +118,7 @@ static void push_front_val(linked_list_t *list, int val) } -static bool insert_test_beginning() +static bool insert_test_beginning(void) { linked_list_t list; lb_linked_list_init(&list); @@ -132,7 +132,7 @@ static bool insert_test_beginning() return assert_list(&list, val, 4); } -static bool insert_test_middle() +static bool insert_test_middle(void) { linked_list_t list; lb_linked_list_init(&list); @@ -149,7 +149,7 @@ static bool insert_test_middle() return assert_list(&list, val, 6); } -static bool insert_test_end() +static bool insert_test_end(void) { linked_list_t list; lb_linked_list_init(&list); @@ -163,7 +163,7 @@ static bool insert_test_end() return assert_list(&list, val, 4); } -static bool insert_test_invalid() +static bool insert_test_invalid(void) { linked_list_t list; lb_linked_list_init(&list); @@ -193,7 +193,7 @@ static bool insert_test_invalid() } -static bool remove_test_beginning() +static bool remove_test_beginning(void) { linked_list_t list; lb_linked_list_init(&list); @@ -210,7 +210,7 @@ static bool remove_test_beginning() return assert_list(&list, val, 2); } -static bool remove_test_middle() +static bool remove_test_middle(void) { linked_list_t list; lb_linked_list_init(&list); @@ -231,7 +231,7 @@ static bool remove_test_middle() return assert_list(&list, val, 4); } -static bool remove_test_end() +static bool remove_test_end(void) { linked_list_t list; lb_linked_list_init(&list); @@ -248,7 +248,7 @@ static bool remove_test_end() return assert_list(&list, val, 2); } -static bool remove_test_all() +static bool remove_test_all(void) { bool result = true; linked_list_t list; @@ -293,7 +293,7 @@ static bool remove_test_all() return result; } -static bool remove_test_invalid() +static bool remove_test_invalid(void) { linked_list_t list; lb_linked_list_init(&list); @@ -323,7 +323,7 @@ static bool remove_test_invalid() return assert_list(&list, val, 4); } -static bool size_test() +static bool size_test(void) { bool result = true; linked_list_t list; @@ -343,7 +343,7 @@ static bool size_test() return result; } -static bool push_pop_front_test() +static bool push_pop_front_test(void) { bool result = true; linked_list_t list; @@ -371,7 +371,7 @@ static bool push_pop_front_test() return result; } -static bool push_pop_back_test() +static bool push_pop_back_test(void) { bool result = true; linked_list_t list; @@ -405,7 +405,7 @@ static int32_t equals(void *a, void *b) OBTAIN_STRUCT_ADDR((linked_list_node_t*)a, my_list_node, lnode)->val; } -static bool search_test() +static bool search_test(void) { bool result = true; linked_list_t list; diff --git a/test/salloc_test.c b/test/salloc_test.c index 9370293..885f9f9 100644 --- a/test/salloc_test.c +++ b/test/salloc_test.c @@ -11,7 +11,7 @@ const uint32_t salloc_header_size = sizeof(_salloc_header); static char buffer[1024]; -static bool salloc_init_test() +static bool salloc_init_test(void) { lb_salloc_init(buffer, 1024); uint32_t blk_size[] = {1024}; @@ -19,7 +19,7 @@ static bool salloc_init_test() return lb_salloc_assert(buffer, blk_size, blk_free, 1); } -static bool salloc_basic_alloc() +static bool salloc_basic_alloc(void) { bool result = true; lb_salloc_init(buffer, 1024); @@ -30,7 +30,7 @@ static bool salloc_basic_alloc() return result; } -static bool salloc_full_alloc() +static bool salloc_full_alloc(void) { bool result = true; lb_salloc_init(buffer, 1024); @@ -41,7 +41,7 @@ static bool salloc_full_alloc() return result; } -static bool salloc_overflow_alloc() +static bool salloc_overflow_alloc(void) { bool result = true; lb_salloc_init(buffer, 1024); @@ -52,7 +52,7 @@ static bool salloc_overflow_alloc() return result; } -static bool salloc_multiple_alloc() +static bool salloc_multiple_alloc(void) { bool result = true; lb_salloc_init(buffer, 1024); @@ -68,7 +68,7 @@ static bool salloc_multiple_alloc() return result; } -static bool salloc_alloc_not_enough() +static bool salloc_alloc_not_enough(void) { void* ptr; bool result = true; @@ -82,7 +82,7 @@ static bool salloc_alloc_not_enough() } -static bool salloc_basic_free() +static bool salloc_basic_free(void) { void* ptr; bool result = true; @@ -97,7 +97,7 @@ static bool salloc_basic_free() return result; } -static bool salloc_full_free() +static bool salloc_full_free(void) { void* ptr; bool result = true; @@ -112,7 +112,7 @@ static bool salloc_full_free() return result; } -static bool salloc_multiple_free() +static bool salloc_multiple_free(void) { void* ptr1, *ptr2, *ptr3, *ptr4; bool result = true; @@ -135,7 +135,7 @@ static bool salloc_multiple_free() return result; } -static bool salloc_free_join_tail() +static bool salloc_free_join_tail(void) { void* ptr1, *ptr2, *ptr3, *ptr4; bool result = true; @@ -156,7 +156,7 @@ static bool salloc_free_join_tail() return result; } -static bool salloc_free_join_head() +static bool salloc_free_join_head(void) { void* ptr1, *ptr2, *ptr3, *ptr4; bool result = true; @@ -178,7 +178,7 @@ static bool salloc_free_join_head() return result; } -static bool salloc_free_join_mid() +static bool salloc_free_join_mid(void) { void* ptr1, *ptr2, *ptr3, *ptr4; bool result = true; @@ -200,7 +200,7 @@ static bool salloc_free_join_mid() return result; } -static bool salloc_free_join_consecutive() +static bool salloc_free_join_consecutive(void) { void* ptr1, *ptr2, *ptr3, *ptr4, *ptr5; bool result = true; @@ -234,7 +234,7 @@ static bool salloc_free_join_consecutive() return result; } -static bool salloc_free_all() +static bool salloc_free_all(void) { void* ptr1, *ptr2, *ptr3, *ptr4; bool result = true; @@ -256,7 +256,7 @@ static bool salloc_free_all() } -void KABI salloc_test() +void KABI salloc_test(void) { test_begin("salloc test");