From 7598eb52a16ee2e86ff1dcfb67ba3ea6d871ea77 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:41:43 +0300 Subject: [PATCH 01/17] Corrected indentation from tab to 4 spaces. --- libc/Makefile | 1 + libc/arch/i386/crt0.S | 48 ++++++++--------- libc/arch/i386/crti.S | 12 ++--- libc/arch/i386/crtn.S | 12 ++--- libc/include/stdlib.h | 7 ++- libc/phapi/list.c | 84 +++++++++++++++--------------- libc/stdio/getch.c | 18 +++---- libc/stdio/getchar.c | 8 +-- libc/stdio/gets.c | 30 +++++------ libc/stdio/printf.c | 118 +++++++++++++++++++++--------------------- libc/stdio/putchar.c | 4 +- libc/stdio/puts.c | 2 +- libc/stdlib/abort.c | 12 ++--- libc/stdlib/atoi.c | 13 +++++ libc/stdlib/exit.c | 10 ++-- libc/stdlib/intlen.c | 6 +-- libc/stdlib/itoa.c | 40 +++++++------- libc/string/memcmp.c | 16 +++--- 18 files changed, 230 insertions(+), 211 deletions(-) create mode 100644 libc/stdlib/atoi.c diff --git a/libc/Makefile b/libc/Makefile index 091cc99..e065b14 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -36,6 +36,7 @@ stdio/putchar.o \ stdio/puts.o \ stdlib/abort.o \ stdlib/intlen.o \ +stdlib/atoi.o \ stdlib/itoa.o \ string/memcmp.o \ string/memcpy.o \ diff --git a/libc/arch/i386/crt0.S b/libc/arch/i386/crt0.S index 1c7ae13..65e0914 100644 --- a/libc/arch/i386/crt0.S +++ b/libc/arch/i386/crt0.S @@ -3,35 +3,35 @@ .global _start .type _start, @function _start: - # TODO: Locate argc, argv, envp according to System V ABI (i386 supplement) - # Figure 3-31: Initial Process Stack (3-28, Page 54). + # TODO: Locate argc, argv, envp according to System V ABI (i386 supplement) + # Figure 3-31: Initial Process Stack (3-28, Page 54). - # Set up end of the stack frame linked list. - xorl %ebp, %ebp - pushl %ebp # rip=0 - pushl %ebp # rbp=0 - movl %esp, %ebp + # Set up end of the stack frame linked list. + xorl %ebp, %ebp + pushl %ebp # rip=0 + pushl %ebp # rbp=0 + movl %esp, %ebp - # Initialize the standard library. - push $0 # TODO: argc - push $0 # TODO: argv - push $0 # TODO: envp - call __init_libc # void(int, char**, char**) - addl $12, %esp + # Initialize the standard library. + push $0 # TODO: argc + push $0 # TODO: argv + push $0 # TODO: envp + call __init_libc # void(int, char**, char**) + addl $12, %esp - # Run the global constructors. + # Run the global constructors. #if !defined(__HAS_NO_CRT_INIT) - call _init # void(void) + call _init # void(void) #endif - # Run main - push $0 # TODO: argc - push $0 # TODO: argv - push $0 # TODO: envp - call main # int(int, char**, char**) - addl $12, %esp + # Run main + push $0 # TODO: argc + push $0 # TODO: argv + push $0 # TODO: envp + call main # int(int, char**, char**) + addl $12, %esp - # Terminate the process with main's exit code. - push %eax - call exit + # Terminate the process with main's exit code. + push %eax + call exit .size _start, .-_start diff --git a/libc/arch/i386/crti.S b/libc/arch/i386/crti.S index cebea3e..06112f9 100644 --- a/libc/arch/i386/crti.S +++ b/libc/arch/i386/crti.S @@ -2,14 +2,14 @@ .global _init .type _init, @function _init: - push %ebp - movl %esp, %ebp - /* gcc will nicely put the contents of crtbegin.o's .init section here. */ + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .init section here. */ .section .fini .global _fini .type _fini, @function _fini: - push %ebp - movl %esp, %ebp - /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ diff --git a/libc/arch/i386/crtn.S b/libc/arch/i386/crtn.S index 33957bf..0d58006 100644 --- a/libc/arch/i386/crtn.S +++ b/libc/arch/i386/crtn.S @@ -1,9 +1,9 @@ .section .init - /* gcc will nicely put the contents of crtend.o's .init section here. */ - popl %ebp - ret + /* gcc will nicely put the contents of crtend.o's .init section here. */ + popl %ebp + ret .section .fini - /* gcc will nicely put the contents of crtend.o's .fini section here. */ - popl %ebp - ret + /* gcc will nicely put the contents of crtend.o's .fini section here. */ + popl %ebp + ret diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 572423b..d3fd0c9 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -17,7 +17,7 @@ __attribute__((__noreturn__)) void exit(int); /** - * Converts a integer to a string. + * Converts an integer to a string. */ void itoa(char *buf, unsigned long int n, int base); @@ -26,4 +26,9 @@ void itoa(char *buf, unsigned long int n, int base); */ int intlen(int n, int base); +/** + * Converts a string to an integer. + */ +int atoi(char *str); + #endif diff --git a/libc/phapi/list.c b/libc/phapi/list.c index ee190d8..f28caeb 100644 --- a/libc/phapi/list.c +++ b/libc/phapi/list.c @@ -7,70 +7,70 @@ int8_t std_lessthan_pred(type_t a, type_t b) { - return (a < b) ? 1 : 0; + return (a < b) ? 1 : 0; } list_t create_list(uint32_t max_size, lessthan_pred_t lessthan) { - list_t ret; - ret.array = (void*) kmalloc(max_size * sizeof(type_t)); - memset(ret.array, 0, max_size * sizeof(type_t)); - ret.size = 0; - ret.max_size = max_size; - ret.lessthan = lessthan; - return ret; + list_t ret; + ret.array = (void*) kmalloc(max_size * sizeof(type_t)); + memset(ret.array, 0, max_size * sizeof(type_t)); + ret.size = 0; + ret.max_size = max_size; + ret.lessthan = lessthan; + return ret; } list_t place_list(void *addr, uint32_t max_size, lessthan_pred_t lessthan) { - list_t ret; - ret.array = (type_t*) addr; - memset(ret.array, 0, max_size * sizeof(type_t)); - ret.size = 0; - ret.max_size = max_size; - ret.lessthan = lessthan; - return ret; + list_t ret; + ret.array = (type_t*) addr; + memset(ret.array, 0, max_size * sizeof(type_t)); + ret.size = 0; + ret.max_size = max_size; + ret.lessthan = lessthan; + return ret; } void destroy_list(list_t *array) { - kfree(array->array); + kfree(array->array); } void insert_list(type_t item, list_t *array) { - ASSERT(array->lessthan); - uint32_t iterator = 0; - while (iterator < array->size && array->lessthan(array->array[iterator], item)) { - iterator++; - } - - if (iterator == array->size) { - array->array[array->size++] = item; - } else { - type_t tmp = array->array[iterator]; - array->array[iterator] = item; - while (iterator < array->size) { - iterator++; - type_t tmp2 = array->array[iterator]; - array->array[iterator] = tmp; - tmp = tmp2; - } - array->size++; - } + ASSERT(array->lessthan); + uint32_t iterator = 0; + while (iterator < array->size && array->lessthan(array->array[iterator], item)) { + iterator++; + } + + if (iterator == array->size) { + array->array[array->size++] = item; + } else { + type_t tmp = array->array[iterator]; + array->array[iterator] = item; + while (iterator < array->size) { + iterator++; + type_t tmp2 = array->array[iterator]; + array->array[iterator] = tmp; + tmp = tmp2; + } + array->size++; + } } type_t lookup_list(uint32_t i, list_t *array) { - ASSERT(i < array->size); - return array->array[i]; + ASSERT(i < array->size); + return array->array[i]; } void remove_list(uint32_t i, list_t *array) { - while (i < array->size) { - array->array[i] = array->array[i + 1]; - i++; - } - array->size--; + while (i < array->size) { + array->array[i] = array->array[i + 1]; + i++; + } + array->size--; } diff --git a/libc/stdio/getch.c b/libc/stdio/getch.c index e9c4509..6edf8f6 100644 --- a/libc/stdio/getch.c +++ b/libc/stdio/getch.c @@ -4,13 +4,13 @@ int getch() { - for (;;) { - if (((uint8_t*)stdin)[in_size] != 0) { - in_size++; - break; - } - } - int c = ((uint8_t*)stdin)[in_size - 1]; - - return c; + for (;;) { + if (((uint8_t*)stdin)[in_size] != 0) { + in_size++; + break; + } + } + int c = ((uint8_t*)stdin)[in_size - 1]; + + return c; } diff --git a/libc/stdio/getchar.c b/libc/stdio/getchar.c index c3181a9..3b3bb5a 100644 --- a/libc/stdio/getchar.c +++ b/libc/stdio/getchar.c @@ -3,8 +3,8 @@ int getchar() { - int c = getch(); - putchar(c); - - return c; + int c = getch(); + putchar(c); + + return c; } diff --git a/libc/stdio/gets.c b/libc/stdio/gets.c index 95ae77e..f5a1d6c 100644 --- a/libc/stdio/gets.c +++ b/libc/stdio/gets.c @@ -2,19 +2,19 @@ char *gets(char *str) { - int c = getch(); - int i = 0; - while (c != '\n') { - if (c != '\b') { - str[i++] = c; - putchar(c); - } else if (c == '\b' && i > 0) { - str[--i] = 0; - putchar(c); - } - c = getch(); - } - str[i] = '\0'; - putchar('\n'); - return str; + int c = getch(); + int i = 0; + while (c != '\n') { + if (c != '\b') { + str[i++] = c; + putchar(c); + } else if (c == '\b' && i > 0) { + str[--i] = 0; + putchar(c); + } + c = getch(); + } + str[i] = '\0'; + putchar('\n'); + return str; } diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c index 03a9c93..3bb92d0 100644 --- a/libc/stdio/printf.c +++ b/libc/stdio/printf.c @@ -9,70 +9,70 @@ int printf(const char* restrict format, ...) { - va_list parameters; - va_start(parameters, format); + va_list parameters; + va_start(parameters, format); - int written = 0; - size_t amount; - bool rejected_bad_specifier = false; + int written = 0; + size_t amount; + bool rejected_bad_specifier = false; - while ( *format != '\0' ) { - if ( *format != '%' ) { - print_c: - amount = 1; - while ( format[amount] && format[amount] != '%' ) - amount++; - write(format, amount); - format += amount; - written += amount; - continue; - } + while ( *format != '\0' ) { + if ( *format != '%' ) { + print_c: + amount = 1; + while ( format[amount] && format[amount] != '%' ) + amount++; + write(format, amount); + format += amount; + written += amount; + continue; + } - const char* format_begun_at = format; + const char* format_begun_at = format; - if ( *(++format) == '%' ) - goto print_c; + if ( *(++format) == '%' ) + goto print_c; - if ( rejected_bad_specifier ) { - incomprehensible_conversion: - rejected_bad_specifier = true; - format = format_begun_at; - goto print_c; - } - if ( *format == 'c' ) { - format++; - char c = (char) va_arg(parameters, int /* char promotes to int */); - write(&c, sizeof(c)); - } else if ( *format == 's' ) { - format++; - const char* s = va_arg(parameters, const char*); - call(1, (uint32_t) s, strlen(s), 0, 0, 0); - } else if ( *format == 'd' ) { - format++; - int n = va_arg(parameters, int); - if (n) { - char s[intlen(n, 10)]; - itoa(s, n, 10); - call(1, (uint32_t) s, strlen(s), 0, 0, 0); - } else { - printf("0"); - } - } else if ( *format == 'x') { - format++; - int n = va_arg(parameters, int); - if (n) { - char s[intlen(n, 16)]; - itoa(s, n, 16); - call(1, (uint32_t) s, strlen(s), 0, 0, 0); - } else { - printf("0x0"); - } - } else { - goto incomprehensible_conversion; - } - } + if ( rejected_bad_specifier ) { + incomprehensible_conversion: + rejected_bad_specifier = true; + format = format_begun_at; + goto print_c; + } + if ( *format == 'c' ) { + format++; + char c = (char) va_arg(parameters, int /* char promotes to int */); + write(&c, sizeof(c)); + } else if ( *format == 's' ) { + format++; + const char* s = va_arg(parameters, const char*); + call(1, (uint32_t) s, strlen(s), 0, 0, 0); + } else if ( *format == 'd' ) { + format++; + int n = va_arg(parameters, int); + if (n) { + char s[intlen(n, 10)]; + itoa(s, n, 10); + call(1, (uint32_t) s, strlen(s), 0, 0, 0); + } else { + printf("0"); + } + } else if ( *format == 'x') { + format++; + int n = va_arg(parameters, int); + if (n) { + char s[intlen(n, 16)]; + itoa(s, n, 16); + call(1, (uint32_t) s, strlen(s), 0, 0, 0); + } else { + printf("0x0"); + } + } else { + goto incomprehensible_conversion; + } + } - va_end(parameters); + va_end(parameters); - return written; + return written; } diff --git a/libc/stdio/putchar.c b/libc/stdio/putchar.c index cfc0869..251d440 100644 --- a/libc/stdio/putchar.c +++ b/libc/stdio/putchar.c @@ -3,6 +3,6 @@ #include void putchar(char c) -{ - write_char(c); +{ + write_char(c); } diff --git a/libc/stdio/puts.c b/libc/stdio/puts.c index b4cac29..3c696bf 100644 --- a/libc/stdio/puts.c +++ b/libc/stdio/puts.c @@ -2,5 +2,5 @@ int puts(const char* string) { - return printf("%s\n", string); + return printf("%s\n", string); } diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c index 9f8745c..a4d535c 100644 --- a/libc/stdlib/abort.c +++ b/libc/stdlib/abort.c @@ -6,14 +6,14 @@ __attribute__((__noreturn__)) void abort(void) { #if __STDC_HOSTED__ - // TODO: Properly implement abort(). - exit(1); + // TODO: Properly implement abort(). + exit(1); #elif defined(__is_photon_kernel) - // TODO: Add proper kernel panic. - printf("Kernel Panic: abort()\n"); - while ( 1 ) { } + // TODO: Add proper kernel panic. + printf("Kernel Panic: abort()\n"); + while ( 1 ) { } #else #error "You need to implement abort() in this freestanding environment." #endif - __builtin_unreachable(); + __builtin_unreachable(); } diff --git a/libc/stdlib/atoi.c b/libc/stdlib/atoi.c new file mode 100644 index 0000000..7f7446b --- /dev/null +++ b/libc/stdlib/atoi.c @@ -0,0 +1,13 @@ +#include + +int atoi(char *str) +{ + int res = 0; // Initialize result + + // Iterate through all characters of input string and update result + for (int i = 0; str[i] != '\0'; ++i) + res = res*10 + str[i] - '0'; + + // return result. + return res; +} diff --git a/libc/stdlib/exit.c b/libc/stdlib/exit.c index e167af4..23a14f5 100644 --- a/libc/stdlib/exit.c +++ b/libc/stdlib/exit.c @@ -3,9 +3,9 @@ void exit(int status) { - while ( true ) - { - // TODO: Implement the exit system call. - (void) status; - } + while ( true ) + { + // TODO: Implement the exit system call. + (void) status; + } } diff --git a/libc/stdlib/intlen.c b/libc/stdlib/intlen.c index fa78ac6..7ba004f 100644 --- a/libc/stdlib/intlen.c +++ b/libc/stdlib/intlen.c @@ -2,7 +2,7 @@ int intlen(int n, int base) { - int len; - for(len = 0; n != 0; n /= base, len++) {} - return len; + int len; + for(len = 0; n != 0; n /= base, len++) {} + return len; } diff --git a/libc/stdlib/itoa.c b/libc/stdlib/itoa.c index 3b27475..017c4d0 100644 --- a/libc/stdlib/itoa.c +++ b/libc/stdlib/itoa.c @@ -3,31 +3,31 @@ static void add_hex_prefix(char *buf) { - int len = strlen(buf); - for (int i = len - 1; i >= 0; i--) { - buf[i + 2] = buf[i]; - } - buf[len + 2] = '\0'; - buf[0] = '0'; - buf[1] = 'x'; + int len = strlen(buf); + for (int i = len - 1; i >= 0; i--) { + buf[i + 2] = buf[i]; + } + buf[len + 2] = '\0'; + buf[0] = '0'; + buf[1] = 'x'; } void itoa(char *buf, unsigned long int n, int base) { - unsigned long int tmp; - int i; + unsigned long int tmp; + int i; - tmp = n; - i = 0; + tmp = n; + i = 0; - do { - tmp = n % base; - buf[i++] = (tmp < 10) ? (tmp + '0') : (tmp + 'a' - 10); - } while (n /= base); - buf[i] = '\0'; + do { + tmp = n % base; + buf[i++] = (tmp < 10) ? (tmp + '0') : (tmp + 'a' - 10); + } while (n /= base); + buf[i] = '\0'; - strrev(buf); - if (base == 16) { - add_hex_prefix(buf); - } + strrev(buf); + if (base == 16) { + add_hex_prefix(buf); + } } diff --git a/libc/string/memcmp.c b/libc/string/memcmp.c index d8608f9..9035a88 100644 --- a/libc/string/memcmp.c +++ b/libc/string/memcmp.c @@ -2,12 +2,12 @@ int memcmp(const void* aptr, const void* bptr, size_t size) { - const unsigned char* a = (const unsigned char*) aptr; - const unsigned char* b = (const unsigned char*) bptr; - for ( size_t i = 0; i < size; i++ ) - if ( a[i] < b[i] ) - return -1; - else if ( b[i] < a[i] ) - return 1; - return 0; + const unsigned char* a = (const unsigned char*) aptr; + const unsigned char* b = (const unsigned char*) bptr; + for ( size_t i = 0; i < size; i++ ) + if ( a[i] < b[i] ) + return -1; + else if ( b[i] < a[i] ) + return 1; + return 0; } From cdc7015ee74edb806aeb56d8511f871535883c9e Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:43:01 +0300 Subject: [PATCH 02/17] Deleted paging code and working on a new memory manager. --- kernel/arch/i386/vmm.c | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 kernel/arch/i386/vmm.c diff --git a/kernel/arch/i386/vmm.c b/kernel/arch/i386/vmm.c new file mode 100644 index 0000000..d11a1fc --- /dev/null +++ b/kernel/arch/i386/vmm.c @@ -0,0 +1,9 @@ +void init_vmm() +{ + +} + +void debug_mem_mngr() +{ + +} From 803207eb466cb7feaf86e02406543c2140987eef Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:43:48 +0300 Subject: [PATCH 03/17] Deleted paging code and implemented a frame allocator. --- kernel/arch/i386/pmm.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 kernel/arch/i386/pmm.c diff --git a/kernel/arch/i386/pmm.c b/kernel/arch/i386/pmm.c new file mode 100644 index 0000000..fe2f4f0 --- /dev/null +++ b/kernel/arch/i386/pmm.c @@ -0,0 +1,54 @@ +/* Paging driver + * + * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include +#include +#include +#include + +uint32_t nframes; +uint32_t *frames; +uint32_t placement_addr = (uint32_t) &kernel_end; +int paging_enabled = 0; + +void init_pmm(uint32_t mem_size) +{ + nframes = mem_size / FRAME_SIZE; + frames = kmalloc(sizeof(uint32_t) * nframes); + for (int i = 0; i < nframes; i++) { + free_frame(FRAME_ADDR_FROM_INDEX(i)); + } +} + +uint32_t find_frame() +{ + for (int i = 0; i < nframes; i++) { + if (!frames[i]) { + uint32_t frame_addr = FRAME_ADDR_FROM_INDEX(i); + use_frame(frame_addr); + return frame_addr; + } + } + printk("[ERROR] No free frames!"); + keep_running(); +} + +void use_frame(uint32_t addr) +{ + int frame_index = FRAME_INDEX(addr); + frames[frame_index] = 1; +} + +void free_frame(uint32_t addr) +{ + int frame_index = FRAME_INDEX(addr); + frames[frame_index] = 0; +} From d632de97f8ad3c3a97c2c2433f9ad74a3fa8dc13 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:44:23 +0300 Subject: [PATCH 04/17] Headers of memory manager. --- kernel/arch/i386/include/pmm.h | 36 ++++++++++++++++++++++++++++++++++ kernel/arch/i386/include/vmm.h | 7 +++++++ 2 files changed, 43 insertions(+) create mode 100644 kernel/arch/i386/include/pmm.h create mode 100644 kernel/arch/i386/include/vmm.h diff --git a/kernel/arch/i386/include/pmm.h b/kernel/arch/i386/include/pmm.h new file mode 100644 index 0000000..8782cb1 --- /dev/null +++ b/kernel/arch/i386/include/pmm.h @@ -0,0 +1,36 @@ +/* Paging driver header + * + * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * Contains declarations of functions for pmm driver and pmm structures. + * pmm is one of the memory management schemes by which a computer stores + * and retrieves data from the secondary storage for use in main memory. + * Structures: + * - page: structure used to store details about a block of memory + * - page table: structure used to store 1024 pages + * - page directory: structure used to store 1024 page entries and their + * physical addresses, in addition it stores physical address that will be loaded + * into CR3. + */ + +#ifndef _pmm_h +#define _pmm_h + +#include +#include + +#define FRAME_SIZE 4 +#define FRAME_INDEX(x) (x / (8 * FRAME_SIZE)) +#define PAGE_ALIGN(x) (x & 0xFFFFF000) +#define FRAME_ADDR_FROM_INDEX(x) (x * FRAME_SIZE * 8) + +void init_pmm(uint32_t kend); +uint32_t find_frame(); +void use_frame(uint32_t frame); +void free_frame(uint32_t frame); + +#endif diff --git a/kernel/arch/i386/include/vmm.h b/kernel/arch/i386/include/vmm.h new file mode 100644 index 0000000..c73004c --- /dev/null +++ b/kernel/arch/i386/include/vmm.h @@ -0,0 +1,7 @@ +#ifndef _vmm_h +#define _vmm_h + +void init_vmm(); +void debug_mem_mngr(); + +#endif From 36c4dc148b96275aa718bac161f10ccd07b891ad Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:44:49 +0300 Subject: [PATCH 05/17] Removed useless code. --- kernel/arch/i386/page.asm | 70 ++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/kernel/arch/i386/page.asm b/kernel/arch/i386/page.asm index 8a4131d..4fea1e7 100644 --- a/kernel/arch/i386/page.asm +++ b/kernel/arch/i386/page.asm @@ -1,40 +1,34 @@ -[GLOBAL copy_page_physical] +[global flush_tlb] +flush_tlb: + push ebx + mov cr3, ebx + mov ebx, cr3 + pop ebx + +[global read_cr0] +read_cr0: + mov eax, cr0 + retn -copy_page_physical: - push ebx - pushf - - cli - - mov ebx, [esp+12] - mov ecx, [esp+16] - - mov edx, cr0 - and edx, 0x7fffffff - mov cr0, edx - - mov edx, 1024 - - .loop: - mov eax, [ebx] - mov [ecx], eax - add ebx, 4 - add ecx, 4 - dec edx - jnz .loop - - mov edx, cr0 - or edx, 0x80000000 - mov cr0, edx - - popf - pop ebx - ret - -[GLOBAL flush_tlb] +[global write_cr0] +write_cr0: + push ebp + mov ebp, esp + mov eax, [ebp+8] + mov cr0, eax + pop ebp + retn -flush_tlb: - push ebx - mov cr3, ebx - mov ebx, cr3 - pop ebx +[global read_cr3] +read_cr3: + mov eax, cr3 + retn + +[global write_cr3] +write_cr3: + push ebp + mov ebp, esp + mov eax, [ebp+8] + mov cr3, eax + pop ebp + retn From 1eee2a8dc60aa7515c6abfab2f731662e0adf5b0 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:49:26 +0300 Subject: [PATCH 06/17] Terminal was to slow, so removed and got back to single buffered interface. --- kernel/system/tty.c | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 kernel/system/tty.c diff --git a/kernel/system/tty.c b/kernel/system/tty.c deleted file mode 100644 index 2ec41fb..0000000 --- a/kernel/system/tty.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Terminal Interface - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include -#include -#include -#include -#include - - From ee5b712a26e1562a765b4a2797758866885e2f85 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:50:03 +0300 Subject: [PATCH 07/17] Removed pagging code. (too many bugs) --- kernel/arch/i386/paging.c | 269 -------------------------------------- 1 file changed, 269 deletions(-) delete mode 100644 kernel/arch/i386/paging.c diff --git a/kernel/arch/i386/paging.c b/kernel/arch/i386/paging.c deleted file mode 100644 index 525868a..0000000 --- a/kernel/arch/i386/paging.c +++ /dev/null @@ -1,269 +0,0 @@ -/* Paging driver - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -uint32_t *frames; -uint32_t nframes; - -void set_frame(uint32_t frame_addr) -{ - uint32_t frame = frame_addr / 0x1000; - uint32_t idx = INDEX_FROM_BIT(frame); - uint32_t off = OFFSET_FROM_BIT(frame); - frames[idx] |= (0x1 << off); -} - -void clear_frame(uint32_t frame_addr) -{ - uint32_t frame = frame_addr / 0x1000; - uint32_t idx = INDEX_FROM_BIT(frame); - uint32_t off = OFFSET_FROM_BIT(frame); - frames[idx] &= ~(0x1 << off); -} - -uint32_t test_frame(uint32_t frame_addr) -{ - uint32_t frame = frame_addr / 0x1000; - uint32_t idx = INDEX_FROM_BIT(frame); - uint32_t off = INDEX_FROM_BIT(frame); - return (frames[idx] & (0x1 << off)); -} - -uint32_t first_frame() -{ - uint32_t i, j; - for (i = 0; i < INDEX_FROM_BIT(nframes); i++) { - if (frames[i] != 0xFFFFFFFF) { - for (j = 0; j < 32; j++) { - uint32_t toTest = 0x1 << j; - if (!(frames[i] & toTest)) { - return i * 4 * 8 + j; - } - } - } - } - return -1; -} - -void alloc_frame(page_t *page, int is_kernel, int is_writeable) -{ - if (page->frame != 0) { - return; - } else { - uint32_t idx = first_frame(); - if (idx == (uint32_t)-1) { - panic("No free frames!", __LINE__, __FILE__); - } - set_frame(idx * 0x1000); - page->present = 1; - page->rw = (is_writeable)?1:0; - page->user = (is_kernel)?0:1; - page->frame = idx; - } -} - -void free_frame(page_t *page) -{ - uint32_t frame; - if (!(frame = page->frame)) { - return; - } else { - clear_frame(frame); - page->frame = 0x0; - } -} - -void init_paging(multiboot *mboot_ptr) -{ - placement_address = (size_t)&kernel_end; - kheap = NULL; - - uint32_t mem_in_mb = mboot_ptr->mem_upper / 1024 + 2; - uint32_t mem_in_kb = mem_in_mb * 1024; - - mem_size_mb = mem_in_mb; - mem_size_kb = mem_in_kb; - - nframes = mem_in_kb / 4; - frames = (uint32_t*)kmalloc(INDEX_FROM_BIT(nframes)); - memset(frames, 0, INDEX_FROM_BIT(nframes)); - - kernel_directory = (page_directory_t*)kmalloc_a(sizeof(page_directory_t)); - memset(kernel_directory, 0, sizeof(page_directory_t)); - kernel_directory->physicalAddr = (uint32_t) kernel_directory->tablesPhysical; - - unsigned int i = 0; - for (i = KHEAP_START; i < KHEAP_START + KHEAP_INIT_SIZE; i += 0x1000) { - get_page(i, 1, kernel_directory); - } - - i = 0; - while (i < (size_t)&kernel_end + KHEAP_INIT_SIZE) { - alloc_frame(get_page(i, 1, kernel_directory), 0, 1); - i += 0x1000; - } - - for (i = KHEAP_START; i < KHEAP_START + KHEAP_INIT_SIZE; i += 0x1000) { - alloc_frame(get_page(i, 1, kernel_directory), 0, 1); - } - register_interrupt_handler(14, &page_fault); - current_directory = clone_directory(kernel_directory); - switch_page_directory(kernel_directory); - enable_paging(); - - kheap = create_heap(KHEAP_START, KHEAP_START + KHEAP_INIT_SIZE, 0xCFFFF000, 0, 0); -} - -void switch_page_directory(page_directory_t *dir) -{ - current_directory = dir; - asm volatile("mov %0, %%cr3":: "r"(&dir->tablesPhysical)); -} - -void enable_paging() -{ - uint32_t cr0; - asm volatile("mov %%cr0, %0": "=r"(cr0)); - cr0 |= 0x80000000; - asm volatile("mov %0, %%cr0":: "r"(cr0)); -} - -page_t *get_page(uint32_t address, int make, page_directory_t *dir) -{ - address /= 0x1000; - uint32_t table_idx = address / 1024; - if (dir->tables[table_idx]) { - return &dir->tables[table_idx]->pages[address % 1024]; - } else if (make) { - uint32_t tmp; - dir->tables[table_idx] = (page_table_t*)kmalloc_ap(sizeof(page_table_t), &tmp); - memset(dir->tables[table_idx], 0, 0x1000); - dir->tablesPhysical[table_idx] = tmp | 0x7; - return &dir->tables[table_idx]->pages[address % 1024]; - } else { - return 0; - } -} - -void page_fault(registers_t *regs) -{ - cli(); - print_regs(regs); - - printf("Kernel heap: %x\n", kheap); - - uint32_t fault_address; - asm volatile("mov %%cr2, %0" : "=r" (fault_address)); - - // The error code gives us details of what happened. - int present = !(regs->err_code & 0x1); // Page not present - int rw = regs->err_code & 0x2; // Write operation? - int us = regs->err_code & 0x4; // Processor was in user-mode? - int reserved = regs->err_code & 0x8; // Overwritten CPU-reserved bits of page entry? - int id = regs->err_code & 0x10; // Caused by an instruction fetch? - - printf("Page fault at %x! Id = %x ( ", fault_address, id); - if (present) printf("present "); - if (rw) printf("read-only "); - if (us) printf("user-mode "); - if (reserved) printf("reserved "); - printf(")\n"); - panic("Core dumped.", __LINE__, __FILE__); -} - -page_directory_t *clone_directory(page_directory_t *src) -{ - uint32_t phys; - page_directory_t *dir = (page_directory_t*) kmalloc_ap(sizeof(page_directory_t), &phys); - memset(dir, 0, sizeof(page_directory_t)); - - uint32_t offset = (uint32_t) dir->tablesPhysical - (uint32_t) dir; - dir->physicalAddr = phys + offset; - - int i; - for (i = 0; i < 1024; i++) { - if (!src->tables[i]) - continue; - - if (kernel_directory->tables[i] == src->tables[i]) { - dir->tables[i] = src->tables[i]; - dir->tablesPhysical[i] = src->tablesPhysical[i]; - } else { - uint32_t page_phys; - dir->tables[i] = clone_table((src->tables), &page_phys); - dir->tablesPhysical[i] = page_phys | 0x07; - } - } - return dir; -} - -page_table_t *clone_table(page_table_t *src, uint32_t *physAddr) -{ - page_table_t *table = (page_table_t*) kmalloc_ap(sizeof(page_table_t), physAddr); - memset(table, 0, sizeof(page_table_t)); - - int i; - for (i = 0; i < 1024; i++) { - if (!src->pages[i].frame) - continue; - alloc_frame(&table->pages[i], 0, 0); - if (src->pages[i].present) - table->pages[i].present = 1; - if (src->pages[i].rw) - table->pages[i].rw = 1; - if (src->pages[i].user) - table->pages[i].user = 1; - if (src->pages[i].accessed) - table->pages[i].accessed = 1; - if (src->pages[i].dirty) - table->pages[i].dirty = 1; - - copy_page_physical(src->pages[i].frame * 0x1000, table->pages[i].frame * 0x1000); - } - return table; -} - -void move_stack(void *new_stack, uint32_t size) -{ - for (uint32_t i = (uint32_t) new_stack; i >= (uint32_t) new_stack - size; i -= 0x1000) { - alloc_frame(get_page(i, 1, current_directory), 0, 1); - } - flush_tlb(); - - uint32_t old_stack_pointer; - asm volatile("mov %%esp, %0" : "=r" (old_stack_pointer)); - uint32_t old_base_pointer; - asm volatile("mov %%ebp, %0" : "=r" (old_base_pointer)); - - uint32_t stack_offset = (uint32_t) new_stack - init_esp; - uint32_t new_stack_pointer = old_stack_pointer + stack_offset; - uint32_t new_base_pointer = old_base_pointer + stack_offset; - - memcpy((void*) new_stack_pointer, (void*) old_stack_pointer, init_esp - old_stack_pointer); - - for(uint32_t i = (uint32_t) new_stack; i > (uint32_t) new_stack - size; i -= 4) { - uint32_t tmp = *(uint32_t*) i; - if (( old_stack_pointer < tmp) && (tmp < init_esp)) { - tmp = tmp + stack_offset; - uint32_t *tmp2 = (uint32_t*) i; - *tmp2 = tmp; - } - } - - asm volatile("mov %0, %%esp" : : "r" (new_stack_pointer)); - asm volatile("mov %0, %%ebp" : : "r" (new_base_pointer)); -} From d63ccbddb47d199d694578a0ef90bf57d0e06e51 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:51:35 +0300 Subject: [PATCH 08/17] Removed paging header. --- kernel/arch/i386/include/paging.h | 129 ------------------------------ 1 file changed, 129 deletions(-) delete mode 100644 kernel/arch/i386/include/paging.h diff --git a/kernel/arch/i386/include/paging.h b/kernel/arch/i386/include/paging.h deleted file mode 100644 index 05469f7..0000000 --- a/kernel/arch/i386/include/paging.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Paging driver header - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * Contains declarations of functions for paging driver and paging structures. - * paging is one of the memory management schemes by which a computer stores - * and retrieves data from the secondary storage for use in main memory. - * Structures: - * - page: structure used to store details about a block of memory - * - page table: structure used to store 1024 pages - * - page directory: structure used to store 1024 page entries and their - * physical addresses, in addition it stores physical address that will be loaded - * into CR3. - */ - -#ifndef _paging_h -#define _paging_h - -#include -#include -#include -#include - -typedef struct page -{ - uint32_t present : 1; // Page present in memory - uint32_t rw : 1; // Read-only if clear, read write if set - uint32_t user : 1; // Supervisor level only if clear - uint32_t accessed : 1; // Has the page been accessed since last refresh? - uint32_t dirty : 1; // Has the page been written to since last refresh? - uint32_t unused : 7; // Amalgamation of unused and reserved bits - uint32_t frame : 20; // Frame address (shifted right 12 bits) -} page_t; - -typedef struct page_table -{ - page_t pages[1024]; -} page_table_t; - -typedef struct page_directory -{ - page_table_t *tables[1024]; - uint32_t tablesPhysical[1024]; - uint32_t physicalAddr; -} page_directory_t; - -page_directory_t *kernel_directory; -page_directory_t *current_directory; -uint32_t mem_size_mb; -uint32_t mem_size_kb; - -extern void copy_page_physical(uint32_t src_frame, uint32_t dest_frame); -extern void flush_tlb(); - -/** - * Initialize paging. - */ -void init_paging(); - -/** - * Switch current page directory and load it. - */ -void switch_page_directory(page_directory_t *dir); - -/** - * It does what it does. :))) - */ -void enable_paging(); - -/** - * Get a free page. - */ -page_t *get_page(uint32_t address, int make, page_directory_t *dir); - -/** - * Page fault handler. - */ -void page_fault(registers_t *regs); - -/** - * Set frame bit. - */ -void set_frame(uint32_t frame_addr); - -/** - * Clear frame. - */ -void clear_frame(uint32_t frame_addr); - -/** - * Test the frame. - */ -uint32_t test_frame(uint32_t frame_addr); - -/** - * First free frame. - */ -uint32_t first_frame(); - -/** - * Alloc first free frame to page. - */ -void alloc_frame(page_t *page, int is_kernel, int is_writeable); - -/** - * Free frame from page. - */ -void free_frame(page_t *page); - -/** - * Copy data from a directory and return it as a pointer to a directory allocated on the heap. - */ -page_directory_t *clone_directory(page_directory_t *src); - -/** - * Copy data from a page and return it. - */ -page_table_t *clone_table(page_table_t *src, uint32_t *physAddr); - -/** - * Simply move the stack... - */ -void move_stack(void *new_stack, uint32_t size); - -#endif From 2df7edc09effceae5632bc86110a7745c3265951 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:52:33 +0300 Subject: [PATCH 09/17] Testing the new partial memory manager. --- kernel/init/init.c | 263 +++++++++++++++++++++++---------------------- 1 file changed, 135 insertions(+), 128 deletions(-) diff --git a/kernel/init/init.c b/kernel/init/init.c index 2040def..80c3c82 100644 --- a/kernel/init/init.c +++ b/kernel/init/init.c @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -34,140 +35,146 @@ extern int detect_cpu(void); #define FREQ 100 void init_stdio() { - inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE); - outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE); - - stdin = (uint8_t*) inbuffer; - stdout = (char*) outbuffer; - - for (int i = 0; i <= STDIO_SIZE; i++) { - inbuffer[i] = 0; - outbuffer[i] = 0; - } + inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE); + outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE); + + stdin = (uint8_t*) inbuffer; + stdout = (char*) outbuffer; + + for (int i = 0; i <= STDIO_SIZE; i++) { + inbuffer[i] = 0; + outbuffer[i] = 0; + } } void init(multiboot *mboot_ptr, uint32_t init_stack) { - init_esp = init_stack; - - init_vga(); - init_stdio(); - init_gdt(); - init_idt(); - init_paging(mboot_ptr); - init_timer(FREQ); - install_keyboard(); - - // mask some interrupts - IRQ_set_mask(2); - IRQ_set_mask(3); - IRQ_set_mask(4); - IRQ_set_mask(5); - IRQ_set_mask(6); - IRQ_set_mask(7); - IRQ_set_mask(8); - IRQ_set_mask(9); - IRQ_set_mask(10); - IRQ_set_mask(11); - IRQ_set_mask(12); - IRQ_set_mask(13); - IRQ_set_mask(14); - IRQ_set_mask(15); - - printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); - detect_cpu(); - printk("\n-------------------------------------------------------------------\n"); - - printk("VGA driver was installed!\n"); - printk("Initialize tty. "); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize paging. "); - wstr_color("[OK]\n", COLOR_GREEN); - printk("Memory info:\n"); - printk("\tKernel starts at: %x\n", (size_t)&kernel_start); - printk("\tKernel ends at: %x\n", (size_t)&kernel_end); - printk("\tRAM: %d MB\n", mem_size_mb); - - printk("Initialize stdio (allow using of stdio header). "); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize GDT. "); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize IDT and interrupts. "); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Install timer and clock. "); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Install keyboard support. "); - wstr_color("[OK]\n", COLOR_GREEN); - - /* tasking is useless, because switcher crashes every time - init_tasking(); - - uint32_t cr3, eflags; - asm volatile("movl %%cr3, %%eax; movl %%eax, %0;":"=r"(cr3)::"%eax"); - asm volatile("pushfl; movl (%%esp), %%eax; movl %%eax, %0; popfl;":"=r"(eflags)::"%eax"); - - task_t *clock_task = create_task(clock_task, &update_time, eflags, cr3); - */ - - wstr_color("\nDONE!\n", COLOR_GREEN); - - sti(); - - getch(); + cli(); + init_esp = init_stack; + + init_vga(); + + printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); + detect_cpu(); + printk("\n-------------------------------------------------------------------\n"); + + printk("VGA driver was installed!"); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize GDT. "); + init_gdt(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize IDT and interrupts. "); + init_idt(); + wstr_color("[OK]\n", COLOR_GREEN); + + + // mask some interrupts + IRQ_set_mask(2); + IRQ_set_mask(3); + IRQ_set_mask(4); + IRQ_set_mask(5); + IRQ_set_mask(6); + IRQ_set_mask(7); + IRQ_set_mask(8); + IRQ_set_mask(9); + IRQ_set_mask(10); + IRQ_set_mask(11); + IRQ_set_mask(12); + IRQ_set_mask(13); + IRQ_set_mask(14); + IRQ_set_mask(15); + + printk("Initialize PMM and VMM. "); + init_pmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); + init_vmm(); + wstr_color("[OK]\n", COLOR_GREEN); + debug_mem_mngr(); + keep_running(); + + printk("Memory info:\n"); + printk("\tKernel starts at: %x\n", (size_t)&kernel_start); + printk("\tKernel ends at: %x\n", (size_t)&kernel_end); + //printk("\tRAM: %d MB\n", mem_size_mb); + + printk("Initialize stdio (allow using of stdio header). "); + init_stdio(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Install timer and clock. "); + init_timer(FREQ); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Install keyboard support. "); + install_keyboard(); + wstr_color("[OK]\n", COLOR_GREEN); + + + /* tasking is useless, because switcher crashes every time + init_tasking(); + + uint32_t cr3, eflags; + asm volatile("movl %%cr3, %%eax; movl %%eax, %0;":"=r"(cr3)::"%eax"); + asm volatile("pushfl; movl (%%esp), %%eax; movl %%eax, %0; popfl;":"=r"(eflags)::"%eax"); + + task_t *clock_task = create_task(clock_task, &update_time, eflags, cr3); + */ + + wstr_color("\nDONE!\n", COLOR_GREEN); + + sti(); + + getch(); } void welcome() { - clear_vga(); - - wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); - wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); - wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); - wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); - wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); - wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); - wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); - - wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); - wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | (___) |\n", COLOR_YELLOW); - wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); - - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk(" by Feraru Mihail"); - - getch(); - clear_vga(); + clear_vga(); + + wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); + wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); + wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); + wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); + wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); + wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); + wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); + + wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); + wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | (___) |\n", COLOR_YELLOW); + wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); + + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk(" by Feraru Mihail"); + + getch(); + clear_vga(); } void login() { - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk("Log in please.\n"); - printk("Username: "); - gets(user); - printk("Machine: "); - gets(machine); - printk("Loged in!\n"); + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk("Log in please.\n"); + printk("Username: "); + gets(user); + printk("Machine: "); + gets(machine); + printk("Loged in!\n"); } From 65bde014918b444109c270da6abf212a3487314e Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:53:41 +0300 Subject: [PATCH 10/17] Update makefiles. --- kernel/Makefile | 4 ++-- kernel/arch/i386/make.config | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index e5f6e02..a3c33a1 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -31,15 +31,15 @@ init/icxxabi.o \ init/kernel_class.o \ $(KERNEL_ARCH_OBJS) \ system/cpu.o \ -system/task.o \ drivers/keyboard.o \ drivers/io.o \ drivers/vga.o \ -system/kheap.o \ init/init.o \ init/main.o \ system/system.o \ system/time.o \ +system/task.o \ +system/kheap.o \ CRTI_OBJ:=$(ARCHDIR)/crti.o CRTBEGIN_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtbegin.o) diff --git a/kernel/arch/i386/make.config b/kernel/arch/i386/make.config index 3aed067..a8b44c9 100644 --- a/kernel/arch/i386/make.config +++ b/kernel/arch/i386/make.config @@ -11,6 +11,7 @@ $(ARCHDIR)/idt.o \ $(ARCHDIR)/interrupt.o \ $(ARCHDIR)/handlers.o \ $(ARCHDIR)/page.o \ -$(ARCHDIR)/paging.o \ +$(ARCHDIR)/pmm.o \ +$(ARCHDIR)/vmm.o \ $(ARCHDIR)/pit.o \ $(ARCHDIR)/pic.o \ From 7f86fa4c7bb8b5fc6a3f7ef86cf03ab85f6390f1 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sun, 23 Aug 2015 21:56:35 +0300 Subject: [PATCH 11/17] Corrected indentation from one tab to 4 spaces. --- kernel/arch/i386/boot/boot.asm | 30 +- kernel/arch/i386/crti.S | 12 +- kernel/arch/i386/crtn.S | 12 +- kernel/arch/i386/descriptor_tables.asm | 12 +- kernel/arch/i386/handlers.c | 40 +- kernel/arch/i386/idt.c | 14 +- kernel/arch/i386/include/idt.h | 14 +- kernel/arch/i386/linker.ld | 48 +- kernel/arch/i386/pit.c | 12 +- kernel/drivers/io.c | 162 +++---- kernel/drivers/keyboard.c | 82 ++-- kernel/drivers/vga.c | 158 +++---- kernel/include/icxxabi.h | 30 +- kernel/include/init.h | 2 +- kernel/include/kernel_class.h | 22 +- kernel/include/kheap.h | 97 +--- kernel/include/multiboot.h | 48 +- kernel/include/system.h | 16 +- kernel/include/task.h | 6 +- kernel/include/vga.h | 32 +- kernel/init/icxxabi.cpp | 170 +++---- kernel/init/kernel_class.cpp | 12 +- kernel/init/main.cpp | 45 +- kernel/system/cpu.c | 614 ++++++++++++------------- kernel/system/kheap.c | 343 +------------- kernel/system/system.c | 27 +- 26 files changed, 825 insertions(+), 1235 deletions(-) diff --git a/kernel/arch/i386/boot/boot.asm b/kernel/arch/i386/boot/boot.asm index ee689cb..2cb86ed 100644 --- a/kernel/arch/i386/boot/boot.asm +++ b/kernel/arch/i386/boot/boot.asm @@ -17,15 +17,17 @@ CHECKSUM equ -(MAGIC + FLAGS) section .multiboot align 4 - dd MAGIC - dd FLAGS - dd CHECKSUM + dd MAGIC + dd FLAGS + dd CHECKSUM ; reserve space for kernel stack section .bootstrap_stack -align 4 + align 4 +global stack_bottom stack_bottom: -times 16384 db 0 + times 16384 db 0 + global stack_top stack_top: @@ -33,13 +35,13 @@ stack_top: section .text global _start _start: - mov esp, stack_top ; set stack - push esp ; push stack pointer - push ebx ; push multiboot structure - cli - extern kmain - call kmain ; let's GO!!! - cli ; if kmain ends, disable interrupts and go to infinite loop + mov esp, stack_top ; set stack + push esp ; push stack pointer + push ebx ; push multiboot structure + cli + extern kmain + call kmain ; let's GO!!! + cli ; if kmain ends, disable interrupts and go to infinite loop .hang: - hlt ; if I am here, something went wrong :P - jmp .hang + hlt ; if I am here, something went wrong :P + jmp .hang diff --git a/kernel/arch/i386/crti.S b/kernel/arch/i386/crti.S index cebea3e..06112f9 100644 --- a/kernel/arch/i386/crti.S +++ b/kernel/arch/i386/crti.S @@ -2,14 +2,14 @@ .global _init .type _init, @function _init: - push %ebp - movl %esp, %ebp - /* gcc will nicely put the contents of crtbegin.o's .init section here. */ + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .init section here. */ .section .fini .global _fini .type _fini, @function _fini: - push %ebp - movl %esp, %ebp - /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ diff --git a/kernel/arch/i386/crtn.S b/kernel/arch/i386/crtn.S index 33957bf..0d58006 100644 --- a/kernel/arch/i386/crtn.S +++ b/kernel/arch/i386/crtn.S @@ -1,9 +1,9 @@ .section .init - /* gcc will nicely put the contents of crtend.o's .init section here. */ - popl %ebp - ret + /* gcc will nicely put the contents of crtend.o's .init section here. */ + popl %ebp + ret .section .fini - /* gcc will nicely put the contents of crtend.o's .fini section here. */ - popl %ebp - ret + /* gcc will nicely put the contents of crtend.o's .fini section here. */ + popl %ebp + ret diff --git a/kernel/arch/i386/descriptor_tables.asm b/kernel/arch/i386/descriptor_tables.asm index 7bfff94..afc942b 100644 --- a/kernel/arch/i386/descriptor_tables.asm +++ b/kernel/arch/i386/descriptor_tables.asm @@ -34,12 +34,12 @@ idt_flush: [GLOBAL tss_flush] tss_flush: - mov ax, 0x2B - ltr ax - ret - + mov ax, 0x2B + ltr ax + ret + [GLOBAL read_eip] read_eip: - pop eax - jmp eax + pop eax + jmp eax diff --git a/kernel/arch/i386/handlers.c b/kernel/arch/i386/handlers.c index 256ad77..726fbe9 100644 --- a/kernel/arch/i386/handlers.c +++ b/kernel/arch/i386/handlers.c @@ -41,31 +41,31 @@ void init_irq() void irq_handler(registers_t regs) { - cli(); - // If interrupt involve the slave - if (regs.int_no >= 40) { - // Send reset signal. - outb(0xA0, 0x20); - } + cli(); + // If interrupt involve the slave + if (regs.int_no >= 40) { + // Send reset signal. + outb(0xA0, 0x20); + } - // Reset signal to master. - outb(0x20, 0x20); + // Reset signal to master. + outb(0x20, 0x20); - if (interrupt_handlers[regs.int_no] != 0) { - isr_t handler = interrupt_handlers[regs.int_no]; - handler(®s); - } - sti(); + if (interrupt_handlers[regs.int_no] != 0) { + isr_t handler = interrupt_handlers[regs.int_no]; + handler(®s); + } + sti(); } static void zero_division_handler(__attribute__((unused)) registers_t *regs) { - panic("Division by 0!", __LINE__, __FILE__); + panic("Division by 0!", __LINE__, __FILE__); } void init_isr() { - idt_set_gate( 0, (uint32_t)isr0 , 0x08, 0x8E); + idt_set_gate( 0, (uint32_t)isr0 , 0x08, 0x8E); idt_set_gate( 1, (uint32_t)isr1 , 0x08, 0x8E); idt_set_gate( 2, (uint32_t)isr2 , 0x08, 0x8E); idt_set_gate( 3, (uint32_t)isr3 , 0x08, 0x8E); @@ -106,13 +106,13 @@ void init_isr() // This gets called from our ASM interrupt handler stub. void isr_handler(registers_t regs) { - cli(); - regs.int_no &= 0xFF; - interrupt_handlers[regs.int_no](®s); - sti(); + cli(); + regs.int_no &= 0xFF; + interrupt_handlers[regs.int_no](®s); + sti(); } void register_interrupt_handler(uint8_t n, isr_t handler) { - interrupt_handlers[n] = handler; + interrupt_handlers[n] = handler; } diff --git a/kernel/arch/i386/idt.c b/kernel/arch/i386/idt.c index c216f59..34d5977 100644 --- a/kernel/arch/i386/idt.c +++ b/kernel/arch/i386/idt.c @@ -17,8 +17,8 @@ static void unhandled_interrupt(__attribute__((unused)) registers_t *regs) { - print_regs(regs); - panic("Interrupt unhandled!", __LINE__, __FILE__); + print_regs(regs); + panic("Interrupt unhandled!", __LINE__, __FILE__); } void init_idt() @@ -28,12 +28,12 @@ void init_idt() memset(&idt_entries, 0, sizeof(idt_entry_t)*256); - for (int n = 0; n < 256; n++) { - register_interrupt_handler(n, &unhandled_interrupt); - } + for (int n = 0; n < 256; n++) { + register_interrupt_handler(n, &unhandled_interrupt); + } - init_isr(); - init_irq(); + init_isr(); + init_irq(); idt_flush((uint32_t)&idt_ptr); } diff --git a/kernel/arch/i386/include/idt.h b/kernel/arch/i386/include/idt.h index c0ddca3..8970a16 100644 --- a/kernel/arch/i386/include/idt.h +++ b/kernel/arch/i386/include/idt.h @@ -26,11 +26,11 @@ */ struct idt_entry_struct { - uint16_t base_lo; - uint16_t sel; - uint8_t always0; - uint8_t flags; - uint16_t base_hi; + uint16_t base_lo; + uint16_t sel; + uint8_t always0; + uint8_t flags; + uint16_t base_hi; } __attribute__((packed)); typedef struct idt_entry_struct idt_entry_t; @@ -39,8 +39,8 @@ typedef struct idt_entry_struct idt_entry_t; */ struct idt_ptr_struct { - uint16_t limit; - uint32_t base; + uint16_t limit; + uint32_t base; } __attribute__((packed)); typedef struct idt_ptr_struct idt_ptr_t; diff --git a/kernel/arch/i386/linker.ld b/kernel/arch/i386/linker.ld index cf4a39e..161dfd0 100644 --- a/kernel/arch/i386/linker.ld +++ b/kernel/arch/i386/linker.ld @@ -2,31 +2,31 @@ ENTRY(_start) SECTIONS { - . = 1M; - kernel_start = .; - - .text BLOCK(4K) : ALIGN(4K) - { - *(.multiboot) - *(.text) - } - - .rodata BLOCK(4K) : ALIGN(4K) - { - *(.rodata) - } + . = 0x100000; + kernel_start = .; + + .text BLOCK(4K) : ALIGN(4K) + { + *(.multiboot) + *(.text) + } + + .rodata BLOCK(4K) : ALIGN(4K) + { + *(.rodata) + } - .data BLOCK(4K) : ALIGN(4K) - { - *(.data) - } + .data BLOCK(4K) : ALIGN(4K) + { + *(.data) + } - .bss BLOCK(4K) : ALIGN(4K) - { - *(COMMON) - *(.bss) - *(.bootstrap_stack) - } + .bss BLOCK(4K) : ALIGN(4K) + { + *(COMMON) + *(.bss) + *(.bootstrap_stack) + } - kernel_end = .; + kernel_end = .; } diff --git a/kernel/arch/i386/pit.c b/kernel/arch/i386/pit.c index 21a924d..4af1de9 100644 --- a/kernel/arch/i386/pit.c +++ b/kernel/arch/i386/pit.c @@ -23,11 +23,11 @@ int tick; void timer_callback(__attribute__ ((unused)) registers_t *regs) { - cli(); - tick++; - update_time(); - //preempt(); useless, because it crashes - sti(); + cli(); + tick++; + update_time(); + //preempt(); useless, because it crashes + sti(); } void init_timer(uint32_t frequency) @@ -56,5 +56,5 @@ void init_timer(uint32_t frequency) int get_tick() { - return tick; + return tick; } diff --git a/kernel/drivers/io.c b/kernel/drivers/io.c index 019efcf..27adbe9 100644 --- a/kernel/drivers/io.c +++ b/kernel/drivers/io.c @@ -57,107 +57,107 @@ uint32_t inl(uint32_t ad) void print_regs(registers_t *regs) { - printk("\nds: %d\tedi: %d\tesi: %d\n", regs->ds, regs->edi, regs->esi); - printk("ebp: %d\tesp: %d\tebx: %d\n", regs->ebp, regs->esp, regs->ebx); - printk("edx: %d\tecx: %d\teax: %d\n", regs->edx, regs->ecx, regs->eax); - printk("eip: %d\tcs: %d\teflags: %d\n", regs->eip, regs->cs, regs->eflags); - printk("useresp: %d\tss: %d\n", regs->useresp, regs->ss); - printk("int_no: %d\terr_code: %d\n\n", regs->int_no, regs->err_code); + printk("\nds: %d\tedi: %d\tesi: %d\n", regs->ds, regs->edi, regs->esi); + printk("ebp: %d\tesp: %d\tebx: %d\n", regs->ebp, regs->esp, regs->ebx); + printk("edx: %d\tecx: %d\teax: %d\n", regs->edx, regs->ecx, regs->eax); + printk("eip: %d\tcs: %d\teflags: %d\n", regs->eip, regs->cs, regs->eflags); + printk("useresp: %d\tss: %d\n", regs->useresp, regs->ss); + printk("int_no: %d\terr_code: %d\n\n", regs->int_no, regs->err_code); } int write_char(const char c) { - //((unsigned char*) stdout)[out_crs] = c; - //out_crs++; - vga_putchar(c); - return 0; + //((unsigned char*) stdout)[out_crs] = c; + //out_crs++; + vga_putchar(c); + return 0; } int write(const char *buf, size_t len) { - for ( size_t i = 0; i < len; i++ ) - write_char((int) ((const char*) buf)[i]); - return 0; + for ( size_t i = 0; i < len; i++ ) + write_char((int) ((const char*) buf)[i]); + return 0; } int printk(const char* format, ...) { - va_list parameters; - va_start(parameters, format); + va_list parameters; + va_start(parameters, format); - int written = 0; - size_t amount; - bool rejected_bad_specifier = false; + int written = 0; + size_t amount; + bool rejected_bad_specifier = false; - while ( *format != '\0' ) { - if ( *format != '%' ) { - print_c: - amount = 1; - while ( format[amount] && format[amount] != '%' ) - amount++; - write(format, amount); - format += amount; - written += amount; - continue; - } + while ( *format != '\0' ) { + if ( *format != '%' ) { + print_c: + amount = 1; + while ( format[amount] && format[amount] != '%' ) + amount++; + write(format, amount); + format += amount; + written += amount; + continue; + } - const char* format_begun_at = format; + const char* format_begun_at = format; - if ( *(++format) == '%' ) - goto print_c; + if ( *(++format) == '%' ) + goto print_c; - if ( rejected_bad_specifier ) { - incomprehensible_conversion: - rejected_bad_specifier = true; - format = format_begun_at; - goto print_c; - } - if ( *format == 'c' ) { - format++; - char c = (char) va_arg(parameters, int /* char promotes to int */); - write(&c, sizeof(c)); - } else if ( *format == 's' ) { - format++; - const char* s = va_arg(parameters, const char*); - write(s, strlen(s)); - } else if ( *format == 'd' ) { - format++; - int n = va_arg(parameters, int); - if (n) { - char s[intlen(n, 10)]; - itoa(s, n, 10); - write(s, strlen(s)); - } else { - putchar('0'); - } - } else if ( *format == 'x') { - format++; - int n = va_arg(parameters, int); - if (n) { - char s[intlen(n, 16)]; - itoa(s, n, 16); - write(s, strlen(s)); - } else { - printk("0x0"); - } - } else { - goto incomprehensible_conversion; - } - } + if ( rejected_bad_specifier ) { + incomprehensible_conversion: + rejected_bad_specifier = true; + format = format_begun_at; + goto print_c; + } + if ( *format == 'c' ) { + format++; + char c = (char) va_arg(parameters, int /* char promotes to int */); + write(&c, sizeof(c)); + } else if ( *format == 's' ) { + format++; + const char* s = va_arg(parameters, const char*); + write(s, strlen(s)); + } else if ( *format == 'd' ) { + format++; + int n = va_arg(parameters, int); + if (n) { + char s[intlen(n, 10)]; + itoa(s, n, 10); + write(s, strlen(s)); + } else { + putchar('0'); + } + } else if ( *format == 'x') { + format++; + int n = va_arg(parameters, int); + if (n) { + char s[intlen(n, 16)]; + itoa(s, n, 16); + write(s, strlen(s)); + } else { + printk("0x0"); + } + } else { + goto incomprehensible_conversion; + } + } - va_end(parameters); - return written; + va_end(parameters); + return written; } void call(int32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx, uint32_t esi, uint32_t edi) { - asm volatile (" \ - movl %0, %%eax; \ - movl %1, %%ebx; \ - movl %2, %%ecx; \ - movl %3, %%edx; \ - movl %4, %%esi; \ - movl %5, %%edi; \ - int $0x80; \ - " : : "r" (eax) , "r" (ebx) , "r" (ecx) , "r" (edx) , "r" (esi) , "r" (edi)); + asm volatile (" \ + movl %0, %%eax; \ + movl %1, %%ebx; \ + movl %2, %%ecx; \ + movl %3, %%edx; \ + movl %4, %%esi; \ + movl %5, %%edi; \ + int $0x80; \ + " : : "r" (eax) , "r" (ebx) , "r" (ecx) , "r" (edx) , "r" (esi) , "r" (edi)); } diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c index f40c15c..f0e39cf 100644 --- a/kernel/drivers/keyboard.c +++ b/kernel/drivers/keyboard.c @@ -36,57 +36,57 @@ KHOME, KUP, KPGUP, '-', KLEFT, '5', KRIGHT, '+', KEND, KDOWN, KPGDN, KINS, KDEL, void install_keyboard() { - in_size = 0; - - ascii_s = USasciiNonShift; - ascii_S = USasciiShift; - last = 0; - - keyboard_set_handler(&read_kb_buff); - register_interrupt_handler(IRQ1, &keyboard_interrupt_handler); + in_size = 0; + + ascii_s = USasciiNonShift; + ascii_S = USasciiShift; + last = 0; + + keyboard_set_handler(&read_kb_buff); + register_interrupt_handler(IRQ1, &keyboard_interrupt_handler); } void keyboard_set_handler(void (*callback)(uint8_t *buf, uint16_t size)) { - keyboard_handler = callback; + keyboard_handler = callback; } void keyboard_interrupt_handler(__attribute__ ((unused)) registers_t *regs) { - uint8_t scancode = inb(0x60); - int special = 0; - - if (scancode & 0x80) { - scancode &= 0x7F; - if (scancode == KRLEFT_SHIFT || scancode == KRRIGHT_SHIFT) { - shift = 0; - special = 1; - } - } else { - if (scancode == KRLEFT_SHIFT || scancode == KRRIGHT_SHIFT) { - shift = 1; - special = 1; - } - - if (shift) { - kb_buffer[last++] = ascii_S[scancode]; - } else { - kb_buffer[last++] = ascii_s[scancode]; - } - - if (special != 1) { - cli(); - keyboard_handler(kb_buffer, last); - sti(); - } - - if (last == KEYBOARD_BUFFER_SIZE) { - last = 0; - } - } + uint8_t scancode = inb(0x60); + int special = 0; + + if (scancode & 0x80) { + scancode &= 0x7F; + if (scancode == KRLEFT_SHIFT || scancode == KRRIGHT_SHIFT) { + shift = 0; + special = 1; + } + } else { + if (scancode == KRLEFT_SHIFT || scancode == KRRIGHT_SHIFT) { + shift = 1; + special = 1; + } + + if (shift) { + kb_buffer[last++] = ascii_S[scancode]; + } else { + kb_buffer[last++] = ascii_s[scancode]; + } + + if (special != 1) { + cli(); + keyboard_handler(kb_buffer, last); + sti(); + } + + if (last == KEYBOARD_BUFFER_SIZE) { + last = 0; + } + } } void read_kb_buff(uint8_t *buf, uint16_t size) { - ((uint8_t*) stdin)[in_size] = buf[size - 1]; + ((uint8_t*) stdin)[in_size] = buf[size - 1]; } diff --git a/kernel/drivers/vga.c b/kernel/drivers/vga.c index e35f203..60918a9 100644 --- a/kernel/drivers/vga.c +++ b/kernel/drivers/vga.c @@ -27,50 +27,50 @@ enum vga_color default_fg = COLOR_LIGHT_GREY; uint8_t make_color(enum vga_color fg, enum vga_color bg) { - return fg | bg << 4; + return fg | bg << 4; } uint16_t make_vgaentry(char c, uint8_t color) { - uint16_t c16 = c; - uint16_t color16 = color; - return c16 | color16 << 8; + uint16_t c16 = c; + uint16_t color16 = color; + return c16 | color16 << 8; } #endif void init_vga() { - #ifdef _TEXTMODE - vga_memory = (uint16_t*) 0xB8000; - row = 0; - col = 0; - tabstop = 4; - clear_vga(); - #endif + #ifdef _TEXTMODE + vga_memory = (uint16_t*) 0xB8000; + row = 0; + col = 0; + tabstop = 4; + clear_vga(); + #endif } void clear_vga() { - #ifdef _TEXTMODE - for ( size_t y = 0; y < VGA_HEIGHT; y++ ) - { - for ( size_t x = 0; x < VGA_WIDTH; x++ ) - { - const size_t index = y * VGA_WIDTH + x; - ((uint16_t*) vga_memory)[index] = make_vgaentry(' ', make_color(default_fg, default_bg)); - } - } - row = 0; - col = 0; - vga_move_cursor(row, col); - #endif + #ifdef _TEXTMODE + for ( size_t y = 0; y < VGA_HEIGHT; y++ ) + { + for ( size_t x = 0; x < VGA_WIDTH; x++ ) + { + const size_t index = y * VGA_WIDTH + x; + ((uint16_t*) vga_memory)[index] = make_vgaentry(' ', make_color(default_fg, default_bg)); + } + } + row = 0; + col = 0; + vga_move_cursor(row, col); + #endif } int vga_scroll(size_t *row) { - #ifdef _TEXTMODE - uint16_t blank = make_vgaentry(' ', make_color(default_fg, default_bg)); - + #ifdef _TEXTMODE + uint16_t blank = make_vgaentry(' ', make_color(default_fg, default_bg)); + if (*row >= 25) { int temp = *row - 25 + 1; @@ -87,88 +87,88 @@ int vga_scroll(size_t *row) #ifdef _TEXTMODE void vga_setcolor(enum vga_color fg, enum vga_color bg) { - default_bg = bg; - default_fg = fg; + default_bg = bg; + default_fg = fg; } void vga_putentryat(char c, uint8_t color, size_t x, size_t y) { - const size_t index = y * VGA_WIDTH + x; - ((uint16_t*) vga_memory)[index] = make_vgaentry(c, color); + const size_t index = y * VGA_WIDTH + x; + ((uint16_t*) vga_memory)[index] = make_vgaentry(c, color); } #endif void vga_putchar(char c) -{ - #ifdef _TEXTMODE - switch (c) { - case '\n': - row++; - col = -1; - break; - case '\t': - for (int i = 1; i < tabstop; i++) { - vga_putchar(' '); - } - break; - case '\b': - vga_putentryat(' ', make_color(default_fg, default_bg), --col, row); - --col; - break; - default: - vga_putentryat(c, make_color(default_fg, default_bg), col, row); - break; - } - if (++col >= 80) { - col = 0; - ++row; - } - vga_scroll(&row); - vga_move_cursor(row, col + 1); - #endif +{ + #ifdef _TEXTMODE + switch (c) { + case '\n': + row++; + col = -1; + break; + case '\t': + for (int i = 1; i < tabstop; i++) { + vga_putchar(' '); + } + break; + case '\b': + vga_putentryat(' ', make_color(default_fg, default_bg), --col, row); + --col; + break; + default: + vga_putentryat(c, make_color(default_fg, default_bg), col, row); + break; + } + if (++col >= 80) { + col = 0; + ++row; + } + vga_scroll(&row); + vga_move_cursor(row, col + 1); + #endif } void vga_writestring(const char* data) { - #ifdef _TEXTMODE - size_t datalen = strlen(data); - for ( size_t i = 0; i < datalen; i++ ) - vga_putchar(data[i]); - #endif + #ifdef _TEXTMODE + size_t datalen = strlen(data); + for ( size_t i = 0; i < datalen; i++ ) + vga_putchar(data[i]); + #endif } #ifdef _TEXTMODE void vga_set_tab(int size) { - tabstop = size; + tabstop = size; } void vga_move_cursor(int row, int column) { - uint16_t cursor_pos = row * 80 + column - 1; - outb(0x3D4, 14); - outb(0x3D5, cursor_pos >> 8); - outb(0x3D4, 15); - outb(0x3D5, cursor_pos); + uint16_t cursor_pos = row * 80 + column - 1; + outb(0x3D4, 14); + outb(0x3D5, cursor_pos >> 8); + outb(0x3D4, 15); + outb(0x3D5, cursor_pos); } #endif void vga_putchar_color(char c, enum vga_color fg) { - #ifdef _TEXTMODE - uint8_t temp_color = default_fg; - default_fg = fg; - vga_putchar(c); - default_fg = temp_color; - #endif + #ifdef _TEXTMODE + uint8_t temp_color = default_fg; + default_fg = fg; + vga_putchar(c); + default_fg = temp_color; + #endif } void wstr_color(const char* data, enum vga_color fg) { - #ifdef _TEXTMODE - for ( size_t i = 0, n = strlen(data); i < n; i++ ) - vga_putchar_color((int) ((const unsigned char*) data)[i], fg); - #endif + #ifdef _TEXTMODE + for ( size_t i = 0, n = strlen(data); i < n; i++ ) + vga_putchar_color((int) ((const unsigned char*) data)[i], fg); + #endif } #ifndef _TEXTMODE diff --git a/kernel/include/icxxabi.h b/kernel/include/icxxabi.h index 802088a..c12b6fa 100644 --- a/kernel/include/icxxabi.h +++ b/kernel/include/icxxabi.h @@ -1,30 +1,30 @@ #ifndef _ICXXABI_H - #define _ICXXABI_H + #define _ICXXABI_H - #define ATEXIT_MAX_FUNCS 128 + #define ATEXIT_MAX_FUNCS 128 - #ifdef __cplusplus - extern "C" { - #endif + #ifdef __cplusplus + extern "C" { + #endif typedef unsigned uarch_t; struct atexit_func_entry_t { - /* - * Each member is at least 4 bytes large. Such that each entry is 12bytes. - * 128 * 12 = 1.5KB exact. - **/ - void (*destructor_func)(void *); - void *obj_ptr; - void *dso_handle; + /* + * Each member is at least 4 bytes large. Such that each entry is 12bytes. + * 128 * 12 = 1.5KB exact. + **/ + void (*destructor_func)(void *); + void *obj_ptr; + void *dso_handle; }; int __cxa_atexit(void (*f)(void *), void *objptr, void *dso); void __cxa_finalize(void *f); - #ifdef __cplusplus - }; - #endif + #ifdef __cplusplus + }; + #endif #endif diff --git a/kernel/include/init.h b/kernel/include/init.h index 9089351..f806006 100644 --- a/kernel/include/init.h +++ b/kernel/include/init.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/kernel/include/kernel_class.h b/kernel/include/kernel_class.h index 8f88def..ff97d92 100644 --- a/kernel/include/kernel_class.h +++ b/kernel/include/kernel_class.h @@ -2,17 +2,17 @@ #define _kernel_class_h class KernelClass { - private: - int ID_number; - char version[30]; - char version_name[50]; - public: - KernelClass(); - ~KernelClass(); - void setID(int ID); - void setVersion(const char *version); - int getID(); - char *getVersion(); + private: + int ID_number; + char version[30]; + char version_name[50]; + public: + KernelClass(); + ~KernelClass(); + void setID(int ID); + void setVersion(const char *version); + int getID(); + char *getVersion(); }; #endif diff --git a/kernel/include/kheap.h b/kernel/include/kheap.h index 373173f..5ea4984 100644 --- a/kernel/include/kheap.h +++ b/kernel/include/kheap.h @@ -5,97 +5,22 @@ #include #include #include +#include -#define KHEAP_START 0xC0000000 -#define KHEAP_INIT_SIZE 0x100000 -#define HEAP_INDEX_SIZE 0x20000 -#define HEAP_MAGIC 0x123890AB -#define HEAP_MIN_SIZE 0x70000 +#define HEAP_START 0xD0000000 +#define HEAP_END 0xFFBFF000 -size_t placement_address; - -typedef struct { - uint32_t magic; - uint8_t is_hole; - uint32_t size; +typedef struct header +{ + struct header *prev, *next; + uint32_t allocated : 1; + uint32_t length : 31; } header_t; -typedef struct { - uint32_t magic; - header_t *header; -} footer_t; - -typedef struct { - list_t index; - uint32_t start_address; - uint32_t end_address; - uint32_t max_address; - uint8_t supervisor; - uint8_t readonly; -} heap_t; - -heap_t *kheap; - -/** - * Create a new heap. - */ -heap_t *create_heap(uint32_t start, uint32_t end, uint32_t max, uint8_t supervisor, uint8_t readonly); - -/** - * Allocate a block of memory of 'size'. If page_align == 1, it creates that block starting on a page boundary. - */ -void *alloc(uint32_t size, uint8_t page_align, heap_t *heap_t); - -/** - * Relase a block of memory. - */ -void free(void *p, heap_t *heap); - -/** - * Find the smallest hole that will fit. - */ -int32_t find_hole(uint32_t size, uint8_t page_align, heap_t *heap); - -/** - * Header_t 'less than' checker. - */ -int8_t header_t_lessthan(type_t a, type_t b); - -/** - * Expand the heap. - */ -void expand(uint32_t new_size, heap_t *heap); - -/** - * Contract the heap. - */ -uint32_t contract(uint32_t new_size, heap_t *heap); - -/** - * Alloc a block of memory with specific options. - */ -size_t kmalloc_int(size_t sz, int align, size_t *phys); - -/** - * Alloc a block of memory with page aligned. - */ -size_t kmalloc_a(size_t sz); - -/** - * Alloc a block of memory and returns physical address. - */ -size_t kmalloc_p(size_t sz, size_t *phys); - -/** - * Alloc a block of memory with with page aligned and returns physical address. - */ -size_t kmalloc_ap(size_t sz, size_t *phys); +void init_heap (); -/** - * Alloc a block of memory for kernel. - */ -size_t kmalloc(size_t sz); +void *kmalloc (uint32_t l); -void kfree(void *p); +void kfree (void *p); #endif diff --git a/kernel/include/multiboot.h b/kernel/include/multiboot.h index 2683d73..188ba66 100644 --- a/kernel/include/multiboot.h +++ b/kernel/include/multiboot.h @@ -15,30 +15,30 @@ typedef struct multiboot { - uint32_t flags; - uint32_t mem_lower; - uint32_t mem_upper; - uint32_t boot_device; - uint32_t cmdline; - uint32_t mods_count; - uint32_t mods_addr; - uint32_t num; - uint32_t size; - uint32_t addr; - uint32_t shndx; - uint32_t mmap_length; - uint32_t mmap_addr; - uint32_t drives_length; - uint32_t drives_addr; - uint32_t config_table; - uint32_t boot_loader_name; - uint32_t apm_table; - uint32_t vbe_control_info; - uint32_t vbe_mode_info; - uint32_t vbe_mode; - uint32_t vbe_interface_seg; - uint32_t vbe_interface_off; - uint32_t vbe_interface_len; + uint32_t flags; + uint32_t mem_lower; + uint32_t mem_upper; + uint32_t boot_device; + uint32_t cmdline; + uint32_t mods_count; + uint32_t mods_addr; + uint32_t num; + uint32_t size; + uint32_t addr; + uint32_t shndx; + uint32_t mmap_length; + uint32_t mmap_addr; + uint32_t drives_length; + uint32_t drives_addr; + uint32_t config_table; + uint32_t boot_loader_name; + uint32_t apm_table; + uint32_t vbe_control_info; + uint32_t vbe_mode_info; + uint32_t vbe_mode; + uint32_t vbe_interface_seg; + uint32_t vbe_interface_off; + uint32_t vbe_interface_len; } multiboot; #endif diff --git a/kernel/include/system.h b/kernel/include/system.h index d3d533d..0b80044 100644 --- a/kernel/include/system.h +++ b/kernel/include/system.h @@ -29,16 +29,16 @@ typedef struct registers typedef struct g_regs { - uint32_t edi; - uint32_t esi; - uint32_t edx; - uint32_t ecx; - uint32_t ebx; - uint32_t eax; + uint32_t edi; + uint32_t esi; + uint32_t edx; + uint32_t ecx; + uint32_t ebx; + uint32_t eax; } g_regs_t; // general registers for system calls typedef struct t_regs { - uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3; + uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3; } t_regs_t; // task registers typedef void (*isr_t)(registers_t*); @@ -47,6 +47,8 @@ void register_interrupt_handler(uint8_t n, isr_t handler); typedef void* type_t; extern size_t kernel_end; extern size_t kernel_start; +extern uint32_t stack_top; +extern uint32_t stack_bottom; extern uint32_t init_esp; extern char user[20]; diff --git a/kernel/include/task.h b/kernel/include/task.h index a540c2d..730712b 100644 --- a/kernel/include/task.h +++ b/kernel/include/task.h @@ -4,9 +4,9 @@ #include typedef struct task { - uint32_t pid; - t_regs_t regs; - struct task *next; + uint32_t pid; + t_regs_t regs; + struct task *next; } task_t; task_t *current_task; diff --git a/kernel/include/vga.h b/kernel/include/vga.h index 50b2eb1..319b30c 100644 --- a/kernel/include/vga.h +++ b/kernel/include/vga.h @@ -12,22 +12,22 @@ extern uint16_t *vga_memory; enum vga_color { - COLOR_BLACK = 0, - COLOR_BLUE = 1, - COLOR_GREEN = 2, - COLOR_CYAN = 3, - COLOR_RED = 4, - COLOR_MAGENTA = 5, - COLOR_BROWN = 6, - COLOR_LIGHT_GREY = 7, - COLOR_DARK_GREY = 8, - COLOR_LIGHT_BLUE = 9, - COLOR_LIGHT_GREEN = 10, - COLOR_LIGHT_CYAN = 11, - COLOR_LIGHT_RED = 12, - COLOR_LIGHT_MAGENTA = 13, - COLOR_YELLOW = 14, - COLOR_WHITE = 15, + COLOR_BLACK = 0, + COLOR_BLUE = 1, + COLOR_GREEN = 2, + COLOR_CYAN = 3, + COLOR_RED = 4, + COLOR_MAGENTA = 5, + COLOR_BROWN = 6, + COLOR_LIGHT_GREY = 7, + COLOR_DARK_GREY = 8, + COLOR_LIGHT_BLUE = 9, + COLOR_LIGHT_GREEN = 10, + COLOR_LIGHT_CYAN = 11, + COLOR_LIGHT_RED = 12, + COLOR_LIGHT_MAGENTA = 13, + COLOR_YELLOW = 14, + COLOR_WHITE = 15, }; /** diff --git a/kernel/init/icxxabi.cpp b/kernel/init/icxxabi.cpp index 980b13b..d2e7cb3 100644 --- a/kernel/init/icxxabi.cpp +++ b/kernel/init/icxxabi.cpp @@ -1,8 +1,8 @@ #include - #ifdef __cplusplus - extern "C" { - #endif + #ifdef __cplusplus + extern "C" { + #endif atexit_func_entry_t __atexit_funcs[ATEXIT_MAX_FUNCS]; uarch_t __atexit_func_count = 0; @@ -11,97 +11,97 @@ uarch_t __atexit_func_count = 0; extern "C" void __cxa_pure_virtual() { - // Do nothing... + // Do nothing... } int __cxa_atexit(void (*f)(void *), void *objptr, void *dso) { - if (__atexit_func_count >= ATEXIT_MAX_FUNCS) {return -1;}; - __atexit_funcs[__atexit_func_count].destructor_func = f; - __atexit_funcs[__atexit_func_count].obj_ptr = objptr; - __atexit_funcs[__atexit_func_count].dso_handle = dso; - __atexit_func_count++; - return 0; /*I would prefer if functions returned 1 on success, but the ABI says...*/ + if (__atexit_func_count >= ATEXIT_MAX_FUNCS) {return -1;}; + __atexit_funcs[__atexit_func_count].destructor_func = f; + __atexit_funcs[__atexit_func_count].obj_ptr = objptr; + __atexit_funcs[__atexit_func_count].dso_handle = dso; + __atexit_func_count++; + return 0; /*I would prefer if functions returned 1 on success, but the ABI says...*/ }; void __cxa_finalize(void *f) { - uarch_t i = __atexit_func_count; - if (!f) - { - /* - * According to the Itanium C++ ABI, if __cxa_finalize is called without a - * function ptr, then it means that we should destroy EVERYTHING MUAHAHAHA!! - * - * TODO: - * Note well, however, that deleting a function from here that contains a __dso_handle - * means that one link to a shared object file has been terminated. In other words, - * We should monitor this list (optional, of course), since it tells us how many links to - * an object file exist at runtime in a particular application. This can be used to tell - * when a shared object is no longer in use. It is one of many methods, however. - **/ - - while (i--) - { - if (__atexit_funcs[i].destructor_func) - { - /* ^^^ That if statement is a safeguard... - * To make sure we don't call any entries that have already been called and unset at runtime. - * Those will contain a value of 0, and calling a function with value 0 - * will cause undefined behaviour. Remember that linear address 0, - * in a non-virtual address space (physical) contains the IVT and BDA. - * - * In a virtual environment, the kernel will receive a page fault, and then probably - * map in some trash, or a blank page, or something stupid like that. - * This will result in the processor executing trash, and...we don't want that. - **/ - (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); - }; - }; - return; - }; + uarch_t i = __atexit_func_count; + if (!f) + { + /* + * According to the Itanium C++ ABI, if __cxa_finalize is called without a + * function ptr, then it means that we should destroy EVERYTHING MUAHAHAHA!! + * + * TODO: + * Note well, however, that deleting a function from here that contains a __dso_handle + * means that one link to a shared object file has been terminated. In other words, + * We should monitor this list (optional, of course), since it tells us how many links to + * an object file exist at runtime in a particular application. This can be used to tell + * when a shared object is no longer in use. It is one of many methods, however. + **/ + + while (i--) + { + if (__atexit_funcs[i].destructor_func) + { + /* ^^^ That if statement is a safeguard... + * To make sure we don't call any entries that have already been called and unset at runtime. + * Those will contain a value of 0, and calling a function with value 0 + * will cause undefined behaviour. Remember that linear address 0, + * in a non-virtual address space (physical) contains the IVT and BDA. + * + * In a virtual environment, the kernel will receive a page fault, and then probably + * map in some trash, or a blank page, or something stupid like that. + * This will result in the processor executing trash, and...we don't want that. + **/ + (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); + }; + }; + return; + }; - for ( ; i >= 0; --i) - { - /* - * The ABI states that multiple calls to the __cxa_finalize(destructor_func_ptr) function - * should not destroy objects multiple times. Only one call is needed to eliminate multiple - * entries with the same address. - * - * FIXME: - * This presents the obvious problem: all destructors must be stored in the order they - * were placed in the list. I.e: the last initialized object's destructor must be first - * in the list of destructors to be called. But removing a destructor from the list at runtime - * creates holes in the table with unfilled entries. - * Remember that the insertion algorithm in __cxa_atexit simply inserts the next destructor - * at the end of the table. So, we have holes with our current algorithm - * This function should be modified to move all the destructors above the one currently - * being called and removed one place down in the list, so as to cover up the hole. - * Otherwise, whenever a destructor is called and removed, an entire space in the table is wasted. - **/ - if (__atexit_funcs[i].destructor_func == f) - { - /* - * Note that in the next line, not every destructor function is a class destructor. - * It is perfectly legal to register a non class destructor function as a simple cleanup - * function to be called on program termination, in which case, it would not NEED an - * object This pointer. A smart programmer may even take advantage of this and register - * a C function in the table with the address of some structure containing data about - * what to clean up on exit. - * In the case of a function that takes no arguments, it will simply be ignore within the - * function itself. No worries. - **/ - (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); - __atexit_funcs[i].destructor_func = 0; + for ( ; i >= 0; --i) + { + /* + * The ABI states that multiple calls to the __cxa_finalize(destructor_func_ptr) function + * should not destroy objects multiple times. Only one call is needed to eliminate multiple + * entries with the same address. + * + * FIXME: + * This presents the obvious problem: all destructors must be stored in the order they + * were placed in the list. I.e: the last initialized object's destructor must be first + * in the list of destructors to be called. But removing a destructor from the list at runtime + * creates holes in the table with unfilled entries. + * Remember that the insertion algorithm in __cxa_atexit simply inserts the next destructor + * at the end of the table. So, we have holes with our current algorithm + * This function should be modified to move all the destructors above the one currently + * being called and removed one place down in the list, so as to cover up the hole. + * Otherwise, whenever a destructor is called and removed, an entire space in the table is wasted. + **/ + if (__atexit_funcs[i].destructor_func == f) + { + /* + * Note that in the next line, not every destructor function is a class destructor. + * It is perfectly legal to register a non class destructor function as a simple cleanup + * function to be called on program termination, in which case, it would not NEED an + * object This pointer. A smart programmer may even take advantage of this and register + * a C function in the table with the address of some structure containing data about + * what to clean up on exit. + * In the case of a function that takes no arguments, it will simply be ignore within the + * function itself. No worries. + **/ + (*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr); + __atexit_funcs[i].destructor_func = 0; - /* - * Notice that we didn't decrement __atexit_func_count: this is because this algorithm - * requires patching to deal with the FIXME outlined above. - **/ - }; - }; + /* + * Notice that we didn't decrement __atexit_func_count: this is because this algorithm + * requires patching to deal with the FIXME outlined above. + **/ + }; + }; }; - #ifdef __cplusplus - }; - #endif + #ifdef __cplusplus + }; + #endif diff --git a/kernel/init/kernel_class.cpp b/kernel/init/kernel_class.cpp index 8efb9f1..522aaf1 100644 --- a/kernel/init/kernel_class.cpp +++ b/kernel/init/kernel_class.cpp @@ -13,30 +13,30 @@ extern "C" { void KernelClass::setID(const int ID) { - this->ID_number = ID; + this->ID_number = ID; } void KernelClass::setVersion(const char *version) { - memcpy(this->version, version, strlen(version) + 1); + memcpy(this->version, version, strlen(version) + 1); } int KernelClass::getID() { - return this->ID_number; + return this->ID_number; } char *KernelClass::getVersion() { - return version; + return version; } KernelClass::KernelClass() { - printk("C++ support enabled. Kernel Class created.\n"); + printk("C++ support enabled. Kernel Class created.\n"); } KernelClass::~KernelClass() { - printk("Kernel Class destroyed. Kernel go down."); + printk("Kernel Class destroyed. Kernel go down."); } diff --git a/kernel/init/main.cpp b/kernel/init/main.cpp index 6baeb96..cddf6d5 100644 --- a/kernel/init/main.cpp +++ b/kernel/init/main.cpp @@ -27,33 +27,34 @@ extern "C" { #include #include #include -#include +#include +#include #include #include #include void kmain(multiboot *mboot_ptr, uint32_t init_stack) { - init(mboot_ptr, init_stack); - welcome(); - login(); - - /* C++ Test */ - printk("\n"); - - KernelClass my_kernel; - my_kernel.setID(16072015); - my_kernel.setVersion("v0.0.1cpp"); - int ID = my_kernel.getID(); - char version[30]; - memcpy(version, my_kernel.getVersion(), strlen(my_kernel.getVersion()) + 1); - - printk("KERNEL ID: %d\n", ID); - printk("KERNEL VERSION: %s\n", version); - - printk("\n"); - - prompt(); - panic("Shell exited!", __LINE__, __FILE__); + init(mboot_ptr, init_stack); + welcome(); + login(); + + /* C++ Test */ + printk("\n"); + + KernelClass my_kernel; + my_kernel.setID(16072015); + my_kernel.setVersion("v0.0.1cpp"); + int ID = my_kernel.getID(); + char version[30]; + memcpy(version, my_kernel.getVersion(), strlen(my_kernel.getVersion()) + 1); + + printk("KERNEL ID: %d\n", ID); + printk("KERNEL VERSION: %s\n", version); + + printk("\n"); + + prompt(); + panic("Shell exited!", __LINE__, __FILE__); } #ifdef __cplusplus diff --git a/kernel/system/cpu.c b/kernel/system/cpu.c index dd1710b..86dfc2f 100644 --- a/kernel/system/cpu.c +++ b/kernel/system/cpu.c @@ -36,331 +36,331 @@ void printregs(int eax, int ebx, int ecx, int edx); /* Simply call this function detect_cpu(); */ int detect_cpu(void) { /* or main() if your trying to port this as an independant application */ - unsigned long ebx, unused; - cpuid(0, unused, ebx, unused, unused); - switch(ebx) { - case 0x756e6547: /* Intel Magic Code */ - do_intel(); - break; - case 0x68747541: /* AMD Magic Code */ - do_amd(); - break; - default: - printk("Unknown x86 CPU Detected\n"); - break; - } - return 0; + unsigned long ebx, unused; + cpuid(0, unused, ebx, unused, unused); + switch(ebx) { + case 0x756e6547: /* Intel Magic Code */ + do_intel(); + break; + case 0x68747541: /* AMD Magic Code */ + do_amd(); + break; + default: + printk("Unknown x86 CPU Detected\n"); + break; + } + return 0; } /* Intel Specific brand list */ char *Intel[] = { - "Brand ID Not Supported.", - "Intel(R) Celeron(R) processor", - "Intel(R) Pentium(R) III processor", - "Intel(R) Pentium(R) III Xeon(R) processor", - "Intel(R) Pentium(R) III processor", - "Reserved", - "Mobile Intel(R) Pentium(R) III processor-M", - "Mobile Intel(R) Celeron(R) processor", - "Intel(R) Pentium(R) 4 processor", - "Intel(R) Pentium(R) 4 processor", - "Intel(R) Celeron(R) processor", - "Intel(R) Xeon(R) Processor", - "Intel(R) Xeon(R) processor MP", - "Reserved", - "Mobile Intel(R) Pentium(R) 4 processor-M", - "Mobile Intel(R) Pentium(R) Celeron(R) processor", - "Reserved", - "Mobile Genuine Intel(R) processor", - "Intel(R) Celeron(R) M processor", - "Mobile Intel(R) Celeron(R) processor", - "Intel(R) Celeron(R) processor", - "Mobile Geniune Intel(R) processor", - "Intel(R) Pentium(R) M processor", - "Mobile Intel(R) Celeron(R) processor" + "Brand ID Not Supported.", + "Intel(R) Celeron(R) processor", + "Intel(R) Pentium(R) III processor", + "Intel(R) Pentium(R) III Xeon(R) processor", + "Intel(R) Pentium(R) III processor", + "Reserved", + "Mobile Intel(R) Pentium(R) III processor-M", + "Mobile Intel(R) Celeron(R) processor", + "Intel(R) Pentium(R) 4 processor", + "Intel(R) Pentium(R) 4 processor", + "Intel(R) Celeron(R) processor", + "Intel(R) Xeon(R) Processor", + "Intel(R) Xeon(R) processor MP", + "Reserved", + "Mobile Intel(R) Pentium(R) 4 processor-M", + "Mobile Intel(R) Pentium(R) Celeron(R) processor", + "Reserved", + "Mobile Genuine Intel(R) processor", + "Intel(R) Celeron(R) M processor", + "Mobile Intel(R) Celeron(R) processor", + "Intel(R) Celeron(R) processor", + "Mobile Geniune Intel(R) processor", + "Intel(R) Pentium(R) M processor", + "Mobile Intel(R) Celeron(R) processor" }; /* This table is for those brand strings that have two values depending on the processor signature. It should have the same number of entries as the above table. */ char *Intel_Other[] = { - "Reserved", - "Reserved", - "Reserved", - "Intel(R) Celeron(R) processor", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Intel(R) Xeon(R) processor MP", - "Reserved", - "Reserved", - "Intel(R) Xeon(R) processor", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved" + "Reserved", + "Reserved", + "Reserved", + "Intel(R) Celeron(R) processor", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Intel(R) Xeon(R) processor MP", + "Reserved", + "Reserved", + "Intel(R) Xeon(R) processor", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved" }; /* Intel-specific information */ int do_intel(void) { - printk("Intel Specific Features:\n"); - unsigned long eax, ebx, ecx, edx, max_eax, signature, unused; - int model, family, type, brand, stepping, reserved; - int extended_family = -1; - cpuid(1, eax, ebx, unused, unused); - model = (eax >> 4) & 0xf; - family = (eax >> 8) & 0xf; - type = (eax >> 12) & 0x3; - brand = ebx & 0xff; - stepping = eax & 0xf; - reserved = eax >> 14; - signature = eax; - printk("Type %d - ", type); - switch(type) { - case 0: - printk("Original OEM"); - break; - case 1: - printk("Overdrive"); - break; - case 2: - printk("Dual-capable"); - break; - case 3: - printk("Reserved"); - break; - } - printk("\n"); - printk("Family %d - ", family); - switch(family) { - case 3: - printk("i386"); - break; - case 4: - printk("i486"); - break; - case 5: - printk("Pentium"); - break; - case 6: - printk("Pentium Pro"); - break; - case 15: - printk("Pentium 4"); - } - printk("\n"); - if(family == 15) { - extended_family = (eax >> 20) & 0xff; - printk("Extended family %d\n", extended_family); - } - printk("Model %d - ", model); - switch(family) { - case 3: - break; - case 4: - switch(model) { - case 0: - case 1: - printk("DX"); - break; - case 2: - printk("SX"); - break; - case 3: - printk("487/DX2"); - break; - case 4: - printk("SL"); - break; - case 5: - printk("SX2"); - break; - case 7: - printk("Write-back enhanced DX2"); - break; - case 8: - printk("DX4"); - break; - } - break; - case 5: - switch(model) { - case 1: - printk("60/66"); - break; - case 2: - printk("75-200"); - break; - case 3: - printk("for 486 system"); - break; - case 4: - printk("MMX"); - break; - } - break; - case 6: - switch(model) { - case 1: - printk("Pentium Pro"); - break; - case 3: - printk("Pentium II Model 3"); - break; - case 5: - printk("Pentium II Model 5/Xeon/Celeron"); - break; - case 6: - printk("Celeron"); - break; - case 7: - printk("Pentium III/Pentium III Xeon - external L2 cache"); - break; - case 8: - printk("Pentium III/Pentium III Xeon - internal L2 cache"); - break; - } - break; - case 15: - break; - } - printk("\n"); - cpuid(0x80000000, max_eax, unused, unused, unused); - /* Quok said: If the max extended eax value is high enough to support the processor brand string - (values 0x80000002 to 0x80000004), then we'll use that information to return the brand information. - Otherwise, we'll refer back to the brand tables above for backwards compatibility with older processors. - According to the Sept. 2006 Intel Arch Software Developer's Guide, if extended eax values are supported, - then all 3 values for the processor brand string are supported, but we'll test just to make sure and be safe. */ - if(max_eax >= 0x80000004) { - printk("Brand: "); - if(max_eax >= 0x80000002) { - cpuid(0x80000002, eax, ebx, ecx, edx); - printregs(eax, ebx, ecx, edx); - } - if(max_eax >= 0x80000003) { - cpuid(0x80000003, eax, ebx, ecx, edx); - printregs(eax, ebx, ecx, edx); - } - if(max_eax >= 0x80000004) { - cpuid(0x80000004, eax, ebx, ecx, edx); - printregs(eax, ebx, ecx, edx); - } - printk("\n"); - } else if(brand > 0) { - printk("Brand %d - ", brand); - if(brand < 0x18) { - if(signature == 0x000006B1 || signature == 0x00000F13) { - printk("%s\n", Intel_Other[brand]); - } else { - printk("%s\n", Intel[brand]); - } - } else { - printk("Reserved\n"); - } - } - printk("Stepping: %d Reserved: %d\n", stepping, reserved); - return 0; + printk("Intel Specific Features:\n"); + unsigned long eax, ebx, ecx, edx, max_eax, signature, unused; + int model, family, type, brand, stepping, reserved; + int extended_family = -1; + cpuid(1, eax, ebx, unused, unused); + model = (eax >> 4) & 0xf; + family = (eax >> 8) & 0xf; + type = (eax >> 12) & 0x3; + brand = ebx & 0xff; + stepping = eax & 0xf; + reserved = eax >> 14; + signature = eax; + printk("Type %d - ", type); + switch(type) { + case 0: + printk("Original OEM"); + break; + case 1: + printk("Overdrive"); + break; + case 2: + printk("Dual-capable"); + break; + case 3: + printk("Reserved"); + break; + } + printk("\n"); + printk("Family %d - ", family); + switch(family) { + case 3: + printk("i386"); + break; + case 4: + printk("i486"); + break; + case 5: + printk("Pentium"); + break; + case 6: + printk("Pentium Pro"); + break; + case 15: + printk("Pentium 4"); + } + printk("\n"); + if(family == 15) { + extended_family = (eax >> 20) & 0xff; + printk("Extended family %d\n", extended_family); + } + printk("Model %d - ", model); + switch(family) { + case 3: + break; + case 4: + switch(model) { + case 0: + case 1: + printk("DX"); + break; + case 2: + printk("SX"); + break; + case 3: + printk("487/DX2"); + break; + case 4: + printk("SL"); + break; + case 5: + printk("SX2"); + break; + case 7: + printk("Write-back enhanced DX2"); + break; + case 8: + printk("DX4"); + break; + } + break; + case 5: + switch(model) { + case 1: + printk("60/66"); + break; + case 2: + printk("75-200"); + break; + case 3: + printk("for 486 system"); + break; + case 4: + printk("MMX"); + break; + } + break; + case 6: + switch(model) { + case 1: + printk("Pentium Pro"); + break; + case 3: + printk("Pentium II Model 3"); + break; + case 5: + printk("Pentium II Model 5/Xeon/Celeron"); + break; + case 6: + printk("Celeron"); + break; + case 7: + printk("Pentium III/Pentium III Xeon - external L2 cache"); + break; + case 8: + printk("Pentium III/Pentium III Xeon - internal L2 cache"); + break; + } + break; + case 15: + break; + } + printk("\n"); + cpuid(0x80000000, max_eax, unused, unused, unused); + /* Quok said: If the max extended eax value is high enough to support the processor brand string + (values 0x80000002 to 0x80000004), then we'll use that information to return the brand information. + Otherwise, we'll refer back to the brand tables above for backwards compatibility with older processors. + According to the Sept. 2006 Intel Arch Software Developer's Guide, if extended eax values are supported, + then all 3 values for the processor brand string are supported, but we'll test just to make sure and be safe. */ + if(max_eax >= 0x80000004) { + printk("Brand: "); + if(max_eax >= 0x80000002) { + cpuid(0x80000002, eax, ebx, ecx, edx); + printregs(eax, ebx, ecx, edx); + } + if(max_eax >= 0x80000003) { + cpuid(0x80000003, eax, ebx, ecx, edx); + printregs(eax, ebx, ecx, edx); + } + if(max_eax >= 0x80000004) { + cpuid(0x80000004, eax, ebx, ecx, edx); + printregs(eax, ebx, ecx, edx); + } + printk("\n"); + } else if(brand > 0) { + printk("Brand %d - ", brand); + if(brand < 0x18) { + if(signature == 0x000006B1 || signature == 0x00000F13) { + printk("%s\n", Intel_Other[brand]); + } else { + printk("%s\n", Intel[brand]); + } + } else { + printk("Reserved\n"); + } + } + printk("Stepping: %d Reserved: %d\n", stepping, reserved); + return 0; } /* Print Registers */ void printregs(int eax, int ebx, int ecx, int edx) { - int j; - char string[17]; - string[16] = '\0'; - for(j = 0; j < 4; j++) { - string[j] = eax >> (8 * j); - string[j + 4] = ebx >> (8 * j); - string[j + 8] = ecx >> (8 * j); - string[j + 12] = edx >> (8 * j); - } - printk("%s", string); + int j; + char string[17]; + string[16] = '\0'; + for(j = 0; j < 4; j++) { + string[j] = eax >> (8 * j); + string[j + 4] = ebx >> (8 * j); + string[j + 8] = ecx >> (8 * j); + string[j + 12] = edx >> (8 * j); + } + printk("%s", string); } /* AMD-specific information */ int do_amd(void) { - printk("AMD Specific Features:\n"); - unsigned long extended, eax, ebx, ecx, edx, unused; - int family, model, stepping, reserved; - cpuid(1, eax, unused, unused, unused); - model = (eax >> 4) & 0xf; - family = (eax >> 8) & 0xf; - stepping = eax & 0xf; - reserved = eax >> 12; - printk("Family: %d Model: %d [", family, model); - switch(family) { - case 4: - printk("486 Model %d", model); - break; - case 5: - switch(model) { - case 0: - case 1: - case 2: - case 3: - case 6: - case 7: - printk("K6 Model %d", model); - break; - case 8: - printk("K6-2 Model 8"); - break; - case 9: - printk("K6-III Model 9"); - break; - default: - printk("K5/K6 Model %d", model); - break; - } - break; - case 6: - switch(model) { - case 1: - case 2: - case 4: - printk("Athlon Model %d", model); - break; - case 3: - printk("Duron Model 3"); - break; - case 6: - printk("Athlon MP/Mobile Athlon Model 6"); - break; - case 7: - printk("Mobile Duron Model 7"); - break; - default: - printk("Duron/Athlon Model %d", model); - break; - } - break; - } - printk("]\n"); - cpuid(0x80000000, extended, unused, unused, unused); - if(extended == 0) { - return 0; - } - if(extended >= 0x80000002) { - unsigned int j; - printk("Detected Processor Name: "); - for(j = 0x80000002; j <= 0x80000004; j++) { - cpuid(j, eax, ebx, ecx, edx); - printregs(eax, ebx, ecx, edx); - } - printk("\n"); - } - if(extended >= 0x80000007) { - cpuid(0x80000007, unused, unused, unused, edx); - if(edx & 1) { - printk("Temperature Sensing Diode Detected!\n"); - } - } - printk("Stepping: %d Reserved: %d\n", stepping, reserved); - return 0; + printk("AMD Specific Features:\n"); + unsigned long extended, eax, ebx, ecx, edx, unused; + int family, model, stepping, reserved; + cpuid(1, eax, unused, unused, unused); + model = (eax >> 4) & 0xf; + family = (eax >> 8) & 0xf; + stepping = eax & 0xf; + reserved = eax >> 12; + printk("Family: %d Model: %d [", family, model); + switch(family) { + case 4: + printk("486 Model %d", model); + break; + case 5: + switch(model) { + case 0: + case 1: + case 2: + case 3: + case 6: + case 7: + printk("K6 Model %d", model); + break; + case 8: + printk("K6-2 Model 8"); + break; + case 9: + printk("K6-III Model 9"); + break; + default: + printk("K5/K6 Model %d", model); + break; + } + break; + case 6: + switch(model) { + case 1: + case 2: + case 4: + printk("Athlon Model %d", model); + break; + case 3: + printk("Duron Model 3"); + break; + case 6: + printk("Athlon MP/Mobile Athlon Model 6"); + break; + case 7: + printk("Mobile Duron Model 7"); + break; + default: + printk("Duron/Athlon Model %d", model); + break; + } + break; + } + printk("]\n"); + cpuid(0x80000000, extended, unused, unused, unused); + if(extended == 0) { + return 0; + } + if(extended >= 0x80000002) { + unsigned int j; + printk("Detected Processor Name: "); + for(j = 0x80000002; j <= 0x80000004; j++) { + cpuid(j, eax, ebx, ecx, edx); + printregs(eax, ebx, ecx, edx); + } + printk("\n"); + } + if(extended >= 0x80000007) { + cpuid(0x80000007, unused, unused, unused, edx); + if(edx & 1) { + printk("Temperature Sensing Diode Detected!\n"); + } + } + printk("Stepping: %d Reserved: %d\n", stepping, reserved); + return 0; } diff --git a/kernel/system/kheap.c b/kernel/system/kheap.c index 33837ef..6d6b0a6 100644 --- a/kernel/system/kheap.c +++ b/kernel/system/kheap.c @@ -8,352 +8,23 @@ */ #include -#include +#include +#include #include #include #include #include -int32_t find_hole(uint32_t size, uint8_t page_align, heap_t *heap) +void init_heap () { - uint32_t iterator = 0; - while (iterator < heap->index.size) { - header_t *header = (header_t*) lookup_list(iterator, &heap->index); - if (page_align > 0) { - uint32_t location = (uint32_t) header; - int32_t offset = 0; - if (((location + sizeof(header_t)) & 0xFFFFF000) != 0) { - offset = 0x1000 - (location + sizeof(header_t) % 0x1000); - } - int32_t hole_size = (int32_t) header->size - offset; - if (hole_size >= (int32_t) size) { - break; - } - } else if (header->size >= size) { - break; - } - iterator++; - } - if (iterator == heap->index.size) { - return -1; - } else { - return iterator; - } } -int8_t header_t_lessthan(type_t a, type_t b) +void *kmalloc (uint32_t p) { - return (((header_t*)a)->size < ((header_t*)b)->size)?1:0; + return 0xdeadbeef; } -heap_t *create_heap(uint32_t start, uint32_t end, uint32_t max, uint8_t supervisor, uint8_t readonly) +void kfree (void *p) { - heap_t *heap = (heap_t*) kmalloc(sizeof(heap_t)); - ASSERT((start % 0x1000 == 0)); - ASSERT((end % 0x1000 == 0)); - - heap->index = place_list((type_t*) start, HEAP_INDEX_SIZE, &header_t_lessthan); - - start += sizeof(type_t) * HEAP_INDEX_SIZE; - - if ((start & 0xFFFFF000) != 0) { - start &= 0xFFFFF000; - start += 0x1000; - } - - heap->start_address = start; - heap->end_address = end; - heap->max_address = max; - heap->supervisor = supervisor; - heap->readonly = readonly; - - header_t *hole = (header_t*) start; - hole->size = end - start; - hole->magic = HEAP_MAGIC; - hole->is_hole = 1; - insert_list((type_t) hole, &heap->index); - - return heap; -} - -void *alloc(uint32_t size, uint8_t page_align, heap_t *heap) -{ - uint32_t new_size = size + sizeof(header_t) + sizeof(footer_t); - int32_t iterator = find_hole(new_size, page_align, heap); - - if (iterator == (int32_t) -1) { - uint32_t old_length = heap->end_address - heap->start_address; - uint32_t old_end_address = heap->end_address; - - expand(old_length+new_size, heap); - uint32_t new_length = heap->end_address-heap->start_address; - - iterator = 0; - - int32_t idx = -1; - uint32_t value = 0x0; - while (iterator < (int32_t) heap->index.size) - { - uint32_t tmp = (uint32_t)lookup_list(iterator, &heap->index); - if (tmp > value) - { - value = tmp; - idx = iterator; - } - iterator++; - } - - if (idx == -1) - { - header_t *header = (header_t *)old_end_address; - header->magic = HEAP_MAGIC; - header->size = new_length - old_length; - header->is_hole = 1; - footer_t *footer = (footer_t *) (old_end_address + header->size - sizeof(footer_t)); - footer->magic = HEAP_MAGIC; - footer->header = header; - insert_list((void*)header, &heap->index); - } - else - { - header_t *header = lookup_list(idx, &heap->index); - header->size += new_length - old_length; - footer_t *footer = (footer_t *) ( (uint32_t)header + header->size - sizeof(footer_t) ); - footer->header = header; - footer->magic = HEAP_MAGIC; - } - - return alloc(size, page_align, heap); - } - - header_t *orig_hole_header = (header_t *)lookup_list(iterator, &heap->index); - uint32_t orig_hole_pos = (uint32_t) orig_hole_header; - uint32_t orig_hole_size = orig_hole_header->size; - - if (orig_hole_size - new_size < sizeof(header_t) + sizeof(footer_t)) { - size += orig_hole_size - new_size; - new_size = orig_hole_size; - } - - if (page_align && (orig_hole_pos & 0xFFFFF000)) { - uint32_t new_location = orig_hole_pos + 0x1000 - (orig_hole_pos & 0xFFF) - sizeof(header_t); - header_t *hole_header = (header_t*) orig_hole_pos; - hole_header->size = 0x1000; - hole_header->magic = HEAP_MAGIC; - hole_header->is_hole = 1; - footer_t *hole_footer = (footer_t*) ((uint32_t) new_location - sizeof(footer_t)); - hole_footer->magic = HEAP_MAGIC; - hole_footer->header = hole_header; - orig_hole_pos = new_location; - orig_hole_size = orig_hole_size - hole_header->size; - } else { - remove_list(iterator, &heap->index); - } - - header_t *block_header = (header_t*) orig_hole_pos; - block_header->magic = HEAP_MAGIC; - block_header->is_hole = 0; - block_header->size = new_size; - - footer_t *block_footer = (footer_t*) (orig_hole_pos + sizeof(header_t) + size); - block_footer->header = block_header; - - if (orig_hole_size - new_size > 0) { - header_t *hole_header = (header_t*) (orig_hole_pos + sizeof(header_t) + size + sizeof(footer_t)); - hole_header->magic = HEAP_MAGIC; - hole_header->is_hole = 1; - hole_header->size = orig_hole_size - new_size; - footer_t *hole_footer = (footer_t*) ((uint32_t) hole_header + orig_hole_size - new_size - sizeof(footer_t)); - - if ((uint32_t) hole_footer < heap->end_address) { - hole_footer->magic = HEAP_MAGIC; - hole_footer->header = hole_header; - } - insert_list((void*)hole_header, &heap->index); - } - return (void*) ((uint32_t) block_header + sizeof(header_t)); -} - -void free(void *p, heap_t *heap) -{ - // Exit gracefully for null pointers. - if (p == 0) - return; - - // Get the header and footer associated with this pointer. - header_t *header = (header_t*) ( (uint32_t)p - sizeof(header_t) ); - footer_t *footer = (footer_t*) ( (uint32_t)header + header->size - sizeof(footer_t) ); - - // Sanity checks. - ASSERT(header->magic == HEAP_MAGIC); - ASSERT(footer->magic == HEAP_MAGIC); - - // Make us a hole. - header->is_hole = 1; - - // Do we want to add this header into the 'free holes' index? - char do_add = 1; - - // Unify left - // If the thing immediately to the left of us is a footer... - footer_t *test_footer = (footer_t*) ( (uint32_t)header - sizeof(footer_t) ); - if (test_footer->magic == HEAP_MAGIC && - test_footer->header->is_hole == 1) - { - uint32_t cache_size = header->size; // Cache our current size. - header = test_footer->header; // Rewrite our header with the new one. - footer->header = header; // Rewrite our footer to point to the new header. - header->size += cache_size; // Change the size. - do_add = 0; // Since this header is already in the index, we don't want to add it again. - } - - // Unify right - // If the thing immediately to the right of us is a header... - header_t *test_header = (header_t*) ( (uint32_t)footer + sizeof(footer_t) ); - if (test_header->magic == HEAP_MAGIC && - test_header->is_hole) - { - header->size += test_header->size; // Increase our size. - test_footer = (footer_t*) ( (uint32_t)test_header + // Rewrite it's footer to point to our header. - test_header->size - sizeof(footer_t) ); - footer = test_footer; - // Find and remove this header from the index. - uint32_t iterator = 0; - while ( (iterator < heap->index.size) && - (lookup_list(iterator, &heap->index) != (void*)test_header) ) - iterator++; - - // Make sure we actually found the item. - ASSERT(iterator < heap->index.size); - // Remove it. - remove_list(iterator, &heap->index); - } - - // If the footer location is the end address, we can contract. - if ( (uint32_t)footer+sizeof(footer_t) == heap->end_address) - { - uint32_t old_length = heap->end_address-heap->start_address; - uint32_t new_length = contract( (uint32_t)header - heap->start_address, heap); - // Check how big we will be after resizing. - if (header->size - (old_length-new_length) > 0) - { - // We will still exist, so resize us. - header->size -= old_length-new_length; - footer = (footer_t*) ( (uint32_t)header + header->size - sizeof(footer_t) ); - footer->magic = HEAP_MAGIC; - footer->header = header; - } - else - { - // We will no longer exist :(. Remove us from the index. - uint32_t iterator = 0; - while ( (iterator < heap->index.size) && - (lookup_list(iterator, &heap->index) != (void*)test_header) ) - iterator++; - // If we didn't find ourselves, we have nothing to remove. - if (iterator < heap->index.size) - remove_list(iterator, &heap->index); - } - } - - // If required, add us to the index. - if (do_add == 1) - insert_list((void*)header, &heap->index); - -} - -void expand(uint32_t new_size, heap_t *heap) -{ - ASSERT(new_size > heap->end_address - heap->start_address); - - if ((new_size & 0xFFFFF000) != 0) { - new_size &= 0xFFFFF000; - new_size += 0x1000; - } - - ASSERT(heap->start_address + new_size <= heap->max_address); - - uint32_t old_size = heap->end_address-heap->start_address; - uint32_t i = old_size; - while (i < new_size) { - alloc_frame( get_page(heap->start_address+i, 1, kernel_directory), - (heap->supervisor)?1:0, (heap->readonly)?0:1); - i += 0x1000; - } - heap->end_address = heap->start_address+new_size; -} - -uint32_t contract(uint32_t new_size, heap_t *heap) -{ - ASSERT(new_size < heap->end_address - heap->start_address); - - if (new_size & 0x1000) { - new_size &= 0x1000; - new_size += 0x1000; - } - - if (new_size < HEAP_MIN_SIZE) { - new_size = HEAP_MIN_SIZE; - } - uint32_t old_size = heap->end_address - heap->start_address; - uint32_t i = old_size - 0x1000; - - while (new_size < i) { - free_frame(get_page(heap->start_address + i, 0, kernel_directory)); - i -= 0x1000; - } - heap->end_address = heap->start_address + new_size; - - return new_size; -} - -size_t kmalloc_int(size_t sz, int align, size_t *phys) -{ - if (kheap == NULL) { - if (align == 1 && (placement_address & 0xFFFFF000)) { - placement_address &= 0xFFFFF000; - placement_address += 0x1000; - } - if (phys) { - *phys = placement_address; - } - size_t tmp = placement_address; - placement_address += sz; - return tmp; - } else { - void *addr = alloc(sz, (uint8_t) align, kheap); - if (phys != NULL) { - page_t *page = get_page((uint32_t) addr, 0, kernel_directory); - *phys = page->frame * 0x1000 + ((uint32_t) addr & 0xFFF); - } - return (uint32_t) addr; - } -} - -size_t kmalloc_a(size_t sz) -{ - return kmalloc_int(sz, 1, 0); -} - -size_t kmalloc_p(size_t sz, size_t *phys) -{ - return kmalloc_int(sz, 0, phys); -} - -size_t kmalloc_ap(size_t sz, size_t *phys) -{ - return kmalloc_int(sz, 1, phys); -} - -size_t kmalloc(size_t sz) -{ - return kmalloc_int(sz, 0, 0); -} - -void kfree(void *p) -{ - if (p != NULL) { - free(p, kheap); - p = NULL; - } + p = 0xdeadbeef; } diff --git a/kernel/system/system.c b/kernel/system/system.c index 25e5d98..6558a8c 100644 --- a/kernel/system/system.c +++ b/kernel/system/system.c @@ -13,11 +13,11 @@ #include #include #include -#include +#include +#include #include #include -extern uint32_t stack_top; uint32_t init_esp; char user[20]; @@ -39,10 +39,11 @@ static void testing_shell(char *str) printk("Char: %d\nInt: %d\nFloat: %d\nSize_t: %d\n", sizeof(char), sizeof(int), sizeof(float), sizeof(size_t)); printk("Kernel:\n"); printk("Start: %x\nEnd: %x\n", (size_t)&kernel_start, (size_t)&kernel_end); - printk("RAM: %d MB\n", mem_size_mb); + //printk("RAM: %d MB\n", mem_size_mb); } else if (!strcmp(str, "page-fault")) { printk("Test fault...\n"); uint32_t *ptr = (uint32_t*)0xA123142300; + *ptr = 432; printk("%d\n", *ptr); } else if (!strcmp(str, "address")) { printk("This is a test of memory manager. Warning! You are in kernel mode!\n"); @@ -52,13 +53,6 @@ static void testing_shell(char *str) printk("stack_top: %x\n", stack_top); printk("&stack_top: %x\n", &stack_top); getch(); - printk("placement_address: %x\n", placement_address); - printk("&placement_address: %x\n", &placement_address); - getch(); - printk("kheap: %x\n", kheap); - printk("&kheap: %x\n", &kheap); - printk("*kheap: %x\n", *kheap); - getch(); int *num = (int*) kmalloc(sizeof(int)); *num = 0x123ABC; @@ -78,15 +72,6 @@ static void testing_shell(char *str) printk("&stack_top: %x\n", &stack_top); getch(); - printk("placement_address: %x\n", placement_address); - printk("&placement_address: %x\n", &placement_address); - getch(); - - printk("kheap: %x\n", kheap); - printk("&kheap: %x\n", &kheap); - printk("*kheap: %x\n", *kheap); - getch(); - kfree(num); } else if (!strcmp(str, "alloc")) { printk("SIZE OF INT: %d\n", sizeof(int)); @@ -182,6 +167,10 @@ void shell(char *str) { } else if (!strcmp(str, "reboot")) { reboot(); + + } else if (!strcmp(str, "huge-alloc")) { + int *i = (void *) kmalloc(sizeof(int)); + kfree(i); } else if (!strcmp(str, "usermode")) { printk("CPU will jump to usermode, this will stop shell, because it is running only in kernel mode.\n"); init_usermode(); From 3ded58a352240eebf200698ede53ed28664001f7 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Mon, 7 Sep 2015 22:39:20 +0300 Subject: [PATCH 12/17] Rewrite paging. --- : | 179 +++++++ all | 5 + kernel/Makefile | 2 +- kernel/arch/i386/handlers.c | 10 + kernel/arch/i386/include/pmm.h | 8 +- kernel/arch/i386/include/vmm.h | 32 +- kernel/arch/i386/pmm.c | 10 +- kernel/arch/i386/vmm.c | 156 +++++- kernel/drivers/vga.c | 2 +- kernel/include/kheap.h | 2 +- kernel/init/init.c | 24 +- kernel/init/main.cpp | 3 +- kernel/system/kheap.c | 29 +- kernel/system/system.c | 18 +- kernel/system/task.c | 4 +- libc/phapi/list.c | 2 +- serial.log | 0 tags | 914 +++++++++++++++++++++++++++++++++ 18 files changed, 1357 insertions(+), 43 deletions(-) create mode 100644 : create mode 100755 all create mode 100644 serial.log create mode 100644 tags diff --git a/: b/: new file mode 100644 index 0000000..5fa1a8a --- /dev/null +++ b/: @@ -0,0 +1,179 @@ +/* Initialization interface + * + * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern int detect_cpu(void); + +#define FREQ 100 + +void init_stdio() { + inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE, 0, 0); + outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE, 0, 0); + + stdin = (uint8_t*) inbuffer; + stdout = (char*) outbuffer; + + for (int i = 0; i <= STDIO_SIZE; i++) { + inbuffer[i] = 0; + outbuffer[i] = 0; + } +} + +void init(multiboot *mboot_ptr, uint32_t init_stack) { + cli(); + init_esp = init_stack; + + init_vga(); + + printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); + detect_cpu(); + printk("\n-------------------------------------------------------------------\n"); + + printk("VGA driver was installed!"); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize GDT. "); + init_gdt(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize IDT and interrupts. "); + init_idt(); + wstr_color("[OK]\n", COLOR_GREEN); + + + // mask some interrupts + IRQ_set_mask(2); + IRQ_set_mask(3); + IRQ_set_mask(4); + IRQ_set_mask(5); + IRQ_set_mask(6); + IRQ_set_mask(7); + IRQ_set_mask(8); + IRQ_set_mask(9); + IRQ_set_mask(10); + IRQ_set_mask(11); + IRQ_set_mask(12); + IRQ_set_mask(13); + IRQ_set_mask(14); + IRQ_set_mask(15); + + printk("Install timer and clock. "); + init_timer(FREQ); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Install keyboard support. "); + install_keyboard(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize PMM and VMM. "); + init_pmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); + init_vmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); + wstr_color("[OK]\n", COLOR_GREEN); + debug_mem_mngr(); + keep_running(); + + printk("Memory info:\n"); + printk("\tKernel starts at: %x\n", (size_t)&kernel_start); + printk("\tKernel ends at: %x\n", (size_t)&kernel_end); + //printk("\tRAM: %d MB\n", mem_size_mb); + + printk("Initialize stdio (allow using of stdio header). "); + init_stdio(); + wstr_color("[OK]\n", COLOR_GREEN); + + /* tasking is useless, because switcher crashes every time + init_tasking(); + + uint32_t cr3, eflags; + asm volatile("movl %%cr3, %%eax; movl %%eax, %0;":"=r"(cr3)::"%eax"); + asm volatile("pushfl; movl (%%esp), %%eax; movl %%eax, %0; popfl;":"=r"(eflags)::"%eax"); + + task_t *clock_task = create_task(clock_task, &update_time, eflags, cr3); + */ + + wstr_color("\nDONE!\n", COLOR_GREEN); + + sti(); + + getch(); +} + +void welcome() { + clear_vga(); + + wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); + wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); + wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); + wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); + wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); + wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); + wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); + + wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); + wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | (___) |\n", COLOR_YELLOW); + wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); + + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk(" by Feraru Mihail"); + + getch(); + clear_vga(); +} + +void login() { + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk("Log in please.\n"); + printk("Username: "); + gets(user); + printk("Machine: "); + gets(machine); + printk("Loged in!\n"); +} diff --git a/all b/all new file mode 100755 index 0000000..91c5282 --- /dev/null +++ b/all @@ -0,0 +1,5 @@ +#!/bin/sh +set -e +. ./iso.sh + +qemu-system-$(./target-triplet-to-arch.sh $HOST) -cdrom photon.iso diff --git a/kernel/Makefile b/kernel/Makefile index a3c33a1..17cb1f2 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,7 +1,7 @@ HOST?=$(shell ../default-host.sh) HOSTARCH:=$(shell ../target-triplet-to-arch.sh $(HOST)) -CFLAGS?=-O2 -g +CFLAGS?=-O0 -g CPPFLAGS?= LDFLAGS?= LIBS?= -L../libc diff --git a/kernel/arch/i386/handlers.c b/kernel/arch/i386/handlers.c index 726fbe9..7e55bee 100644 --- a/kernel/arch/i386/handlers.c +++ b/kernel/arch/i386/handlers.c @@ -8,6 +8,12 @@ isr_t interrupt_handlers[256]; +void std_handler(registers_t *regs) +{ + print_regs(regs); + panic("Unsupported error occured.\n", __LINE__, __FILE__); +} + void init_irq() { outb(0x20, 0x11); @@ -99,6 +105,10 @@ void init_isr() idt_set_gate(31, (uint32_t)isr31, 0x08, 0x8E); idt_set_gate(128, (uint32_t)isr128, 0x08, 0x8E); + for (int i = 0; i < 256; i++) { + register_interrupt_handler(i, &std_handler); + } + register_interrupt_handler(0, &zero_division_handler); register_interrupt_handler(128, &syscall_handler); } diff --git a/kernel/arch/i386/include/pmm.h b/kernel/arch/i386/include/pmm.h index 8782cb1..5ff8904 100644 --- a/kernel/arch/i386/include/pmm.h +++ b/kernel/arch/i386/include/pmm.h @@ -23,12 +23,12 @@ #include #include -#define FRAME_SIZE 4 -#define FRAME_INDEX(x) (x / (8 * FRAME_SIZE)) +#define FRAME_SIZE 0x20 +#define FRAME_INDEX(x) (x / FRAME_SIZE) #define PAGE_ALIGN(x) (x & 0xFFFFF000) -#define FRAME_ADDR_FROM_INDEX(x) (x * FRAME_SIZE * 8) +#define FRAME_ADDR_FROM_INDEX(x) (x * FRAME_SIZE) -void init_pmm(uint32_t kend); +void init_pmm(uint32_t mem_size); uint32_t find_frame(); void use_frame(uint32_t frame); void free_frame(uint32_t frame); diff --git a/kernel/arch/i386/include/vmm.h b/kernel/arch/i386/include/vmm.h index c73004c..4757e54 100644 --- a/kernel/arch/i386/include/vmm.h +++ b/kernel/arch/i386/include/vmm.h @@ -1,7 +1,37 @@ #ifndef _vmm_h #define _vmm_h -void init_vmm(); +#include +#include +#include + +typedef struct page { + uint32_t present : 1; + uint32_t rw : 1; + uint32_t us : 1; + uint32_t accessed : 1; + uint32_t dirty : 1; + uint32_t unused : 7; + uint32_t frame : 20; +} page_t; + +typedef struct page_table { + page_t pages[1024]; +} page_table_t __attribute__((aligned(4096))); + +typedef struct page_directory { + page_table_t *tables[1024]; + uint32_t phys_tables[1024]; +} page_directory_t __attribute__((aligned(4096))); + +void init_vmm(uint32_t mem_size); +void switch_page_directory(page_directory_t *dir); +void enable_paging(); +void map(uint32_t va, uint32_t pa, uint32_t rw, uint32_t us); +void unmap(uint32_t va); +void create_page(page_t *page, uint32_t frame, uint32_t rw, uint32_t us); +page_t *get_page(uint32_t address, page_directory_t *dir); void debug_mem_mngr(); +void page_fault_handler(registers_t *regs); #endif diff --git a/kernel/arch/i386/pmm.c b/kernel/arch/i386/pmm.c index fe2f4f0..b6d01a0 100644 --- a/kernel/arch/i386/pmm.c +++ b/kernel/arch/i386/pmm.c @@ -13,6 +13,7 @@ #include #include #include +#include uint32_t nframes; uint32_t *frames; @@ -21,16 +22,17 @@ int paging_enabled = 0; void init_pmm(uint32_t mem_size) { - nframes = mem_size / FRAME_SIZE; - frames = kmalloc(sizeof(uint32_t) * nframes); - for (int i = 0; i < nframes; i++) { + nframes = (mem_size * 1024) / FRAME_SIZE; + frames = kmalloc(sizeof(uint32_t) * nframes, 0, 0); + for (uint32_t i = 0; i < nframes; i++) { free_frame(FRAME_ADDR_FROM_INDEX(i)); } + printk("Number of frames: %d and memory size: %d\n", nframes, mem_size / 1024); } uint32_t find_frame() { - for (int i = 0; i < nframes; i++) { + for (uint32_t i = 0; i < nframes; i++) { if (!frames[i]) { uint32_t frame_addr = FRAME_ADDR_FROM_INDEX(i); use_frame(frame_addr); diff --git a/kernel/arch/i386/vmm.c b/kernel/arch/i386/vmm.c index d11a1fc..b7a318c 100644 --- a/kernel/arch/i386/vmm.c +++ b/kernel/arch/i386/vmm.c @@ -1,9 +1,163 @@ -void init_vmm() +#include +#include +#include +#include +#include +#include +#include +#include + +extern void write_cr3(); +extern void write_cr0(); +extern uint32_t read_cr3(); +extern uint32_t read_cr0(); +extern uint32_t *frames; +extern uint32_t nframes; +extern int paging_enabled; + +page_directory_t *kernel_directory; +page_directory_t *current_directory; + +void init_vmm(uint32_t mem_size) +{ + // Register interrupt handler + register_interrupt_handler(14, &page_fault_handler); + + // Alloc space for kernel directory + kernel_directory = kmalloc(sizeof(page_directory_t), 1, 0); + + // Empty it + memset(kernel_directory, 0, sizeof(page_directory_t)); + + // Set current directory to kernel diretory + current_directory = kernel_directory; + + // Map the memory + uint32_t mem_addr = 0x0; + uint32_t frame_addr = 0x0; + while (mem_addr < (size_t) &kernel_end + 0x10000) { + frame_addr = find_frame(); + map(mem_addr, frame_addr, 1, 1); + mem_addr += 32; + } + // Switch current directory + switch_page_directory(kernel_directory); + + // Enable paging + enable_paging(); +} + +void switch_page_directory(page_directory_t *dir) +{ + current_directory = dir; + write_cr3((uint32_t) &(dir->phys_tables)); +} + +void enable_paging() +{ + uint32_t cr0 = read_cr0(); + cr0 |= 0x80000000; + write_cr0(cr0); + paging_enabled = 1; +} + +void map(uint32_t va, uint32_t pa, uint32_t rw, uint32_t us) +{ + page_t *page = get_page(va, current_directory); + create_page(page, pa, rw, us); +} + +void unmap(uint32_t va) { + page_t *page = get_page(va, current_directory); + free_frame(page->frame); + memset(page, 0, sizeof(page_t)); + asm volatile ("invlpg (%0)" : : "a" (va)); +} + +void create_page(page_t *page, uint32_t frame, uint32_t rw, uint32_t us) +{ + page->present = 1; + page->rw = rw; + page->us = us; + page->frame = frame; +} + +page_t *get_page(uint32_t address, page_directory_t *dir) +{ + int page_index = address / 0x1000; + int table_index = page_index / 1024; + if (dir->tables[table_index] != 0) { + return &(dir->tables[table_index]->pages[page_index]); + } else { + uint32_t phys_table_addr; + dir->tables[table_index] = kmalloc(sizeof(page_table_t), + 1, &phys_table_addr); + memset((void*) dir->tables[table_index], 0, sizeof(page_table_t)); + dir->phys_tables[table_index] = phys_table_addr | 0x7; + return &(dir->tables[table_index]->pages[page_index]); + } + return NULL; } + void debug_mem_mngr() { + printk("[DEBUG] Testing memory manager...\n"); + printk("page %d page_table %d page_directory %d\n", sizeof(page_t), sizeof(page_table_t), sizeof(page_directory_t)); + printk("Frame allocator test:\n"); + uint32_t addr_a = find_frame(); + uint32_t addr_b = find_frame(); + + int index_a = FRAME_INDEX(addr_a); + int index_b = FRAME_INDEX(addr_b); + + printk("Frame A: %x, index: %d, used: %d\n", addr_a, index_a, frames[index_a]); + printk("Frame B: %x, index: %d, used: %d\n", addr_b, index_b, frames[index_b]); + + free_frame(addr_a); + printk("After free, value of frame A: %d\n", frames[index_a]); + + uint32_t addr_c = find_frame(); + uint32_t addr_d = find_frame(); + + int index_c = FRAME_INDEX(addr_c); + int index_d = FRAME_INDEX(addr_d); + + printk("Frame C: %x, index: %d, used: %d\n", addr_c, index_c, frames[index_c]); + printk("Frame D: %x, index: %d, used: %d\n", addr_d, index_d, frames[index_d]); + + if (index_c != index_a || addr_c != addr_a) { + panic("[ERROR] Page frame allocator crash.\n", __LINE__, __FILE__); + } else { + printk("[INFO] Page frame allocator works fine.\n"); + } + + free_frame(addr_a); + free_frame(addr_b); + free_frame(addr_c); + free_frame(addr_d); + + printk("[INFO] Testing page directory.\n"); + if (current_directory->tables[0]->pages[0].frame != 0x0) { + panic("[ERROR] Map function error.", __LINE__, __FILE__); + } else { + printk("[INFO] All is good.\n"); + page_t *page3 = &(current_directory->tables[0]->pages[2]); + printk("Page 3: frame: %x present: %x rw: %x us: %x\n", page3->frame, page3->present, page3->rw, page3->us); + } + + void *error = kmalloc(sizeof(int), 0, 0); + printk("%d", (uint32_t*) error); +} + +void page_fault_handler(registers_t *regs) +{ + uint32_t cr2; + asm volatile ("mov %%cr2, %0": "=r" (cr2)); + printk("Page fault at %x, faulting address %x\n", regs->eip, cr2); + printk("Error code %x\n", regs->err_code); + panic("Core dumb.\n", __LINE__, __FILE__); } diff --git a/kernel/drivers/vga.c b/kernel/drivers/vga.c index 60918a9..9d7291b 100644 --- a/kernel/drivers/vga.c +++ b/kernel/drivers/vga.c @@ -79,7 +79,7 @@ int vga_scroll(size_t *row) memsetw ((uint16_t*) vga_memory + (25 - temp) * 80, blank, 80); *row = 24; } - vga_move_cursor(row, col); + vga_move_cursor(*row, col); return 0; #endif } diff --git a/kernel/include/kheap.h b/kernel/include/kheap.h index 5ea4984..2f45067 100644 --- a/kernel/include/kheap.h +++ b/kernel/include/kheap.h @@ -19,7 +19,7 @@ typedef struct header void init_heap (); -void *kmalloc (uint32_t l); +void *kmalloc (size_t size, int align, uint32_t *phys); void kfree (void *p); diff --git a/kernel/init/init.c b/kernel/init/init.c index 80c3c82..ae1222b 100644 --- a/kernel/init/init.c +++ b/kernel/init/init.c @@ -35,8 +35,8 @@ extern int detect_cpu(void); #define FREQ 100 void init_stdio() { - inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE); - outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE); + inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE, 0, 0); + outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE, 0, 0); stdin = (uint8_t*) inbuffer; stdout = (char*) outbuffer; @@ -85,12 +85,19 @@ void init(multiboot *mboot_ptr, uint32_t init_stack) { IRQ_set_mask(14); IRQ_set_mask(15); + printk("Install timer and clock. "); + init_timer(FREQ); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Install keyboard support. "); + install_keyboard(); + wstr_color("[OK]\n", COLOR_GREEN); + printk("Initialize PMM and VMM. "); init_pmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); - init_vmm(); + init_vmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); wstr_color("[OK]\n", COLOR_GREEN); debug_mem_mngr(); - keep_running(); printk("Memory info:\n"); printk("\tKernel starts at: %x\n", (size_t)&kernel_start); @@ -101,15 +108,6 @@ void init(multiboot *mboot_ptr, uint32_t init_stack) { init_stdio(); wstr_color("[OK]\n", COLOR_GREEN); - printk("Install timer and clock. "); - init_timer(FREQ); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Install keyboard support. "); - install_keyboard(); - wstr_color("[OK]\n", COLOR_GREEN); - - /* tasking is useless, because switcher crashes every time init_tasking(); diff --git a/kernel/init/main.cpp b/kernel/init/main.cpp index cddf6d5..bbe7ba7 100644 --- a/kernel/init/main.cpp +++ b/kernel/init/main.cpp @@ -54,7 +54,8 @@ void kmain(multiboot *mboot_ptr, uint32_t init_stack) { printk("\n"); prompt(); - panic("Shell exited!", __LINE__, __FILE__); + cli(); + keep_running(); } #ifdef __cplusplus diff --git a/kernel/system/kheap.c b/kernel/system/kheap.c index 6d6b0a6..aeece51 100644 --- a/kernel/system/kheap.c +++ b/kernel/system/kheap.c @@ -14,17 +14,38 @@ #include #include #include +#include +#include + +extern int paging_enabled; +extern uint32_t placement_addr; void init_heap () { } -void *kmalloc (uint32_t p) +void *kmalloc(size_t size, int align, uint32_t *phys) { - return 0xdeadbeef; + if (paging_enabled) { + panic("kmalloc isn't ready to work with paging.\n", __LINE__, __FILE__); + } else { + if (align && (placement_addr & 0xFFFFF000)) { + placement_addr &= 0xFFFFF000; + placement_addr += 0x1000; + } + + if (phys) { + *phys = placement_addr; + } + uint32_t ret_addr = placement_addr; + placement_addr += size; + void *ret_p = (void*) ret_addr; + return ret_p; + } + return NULL; } -void kfree (void *p) +void kfree(void *p) { - p = 0xdeadbeef; + printk("%d", (uint32_t) p); } diff --git a/kernel/system/system.c b/kernel/system/system.c index 6558a8c..b41e1cd 100644 --- a/kernel/system/system.c +++ b/kernel/system/system.c @@ -54,7 +54,7 @@ static void testing_shell(char *str) printk("&stack_top: %x\n", &stack_top); getch(); - int *num = (int*) kmalloc(sizeof(int)); + int *num = (int*) kmalloc(sizeof(int), 0, 0); *num = 0x123ABC; printk("num: %x\n", num); printk("&num: %x\n", &num); @@ -75,18 +75,18 @@ static void testing_shell(char *str) kfree(num); } else if (!strcmp(str, "alloc")) { printk("SIZE OF INT: %d\n", sizeof(int)); - int *a = (int *)kmalloc(sizeof(int)); + int *a = (int *)kmalloc(sizeof(int), 0, 0); *a = 6; printk("a: %x\n", a); printk("a: %x\n", *a); - int *b = (int *)kmalloc(sizeof(int)); + int *b = (int *)kmalloc(sizeof(int), 0, 0); *b = 5; printk("b: %x\n", b); printk("b: %x\n", *b); kfree(b); - int *c = (int *)kmalloc(sizeof(int)); + int *c = (int *)kmalloc(sizeof(int), 0, 0); *c = 8; printk("c: %x\n", c); printk("c: %x\n", *c); @@ -95,14 +95,14 @@ static void testing_shell(char *str) kfree(b); kfree(c); //------------------------------------------------------- - char *stmp = (char *)kmalloc(sizeof(char) * 11); + char *stmp = (char *)kmalloc(sizeof(char) * 11, 0, 0); memcpy(stmp, "This is.\0", 9); printk(stmp); printk("\n&stmp[0]: %x &stmp[9]: %x\n", stmp, stmp + sizeof(char) * 11); kfree(stmp); - char *tmp = (char *)kmalloc(sizeof(char) * 10); + char *tmp = (char *)kmalloc(sizeof(char) * 10, 0, 0); memcpy(tmp, "THIS WAS.\0", 10); printk(tmp); printk("\n&tmp[0]: %x &tmp[9]: %x\n", tmp, tmp + sizeof(char) * 11); @@ -158,7 +158,7 @@ void shell(char *str) { seconds = 0; } else if (!strcmp(str, "write")) { - char *to_write = (char*) kmalloc(sizeof(char) * 30); + char *to_write = (char*) kmalloc(sizeof(char) * 30, 0, 0); size_t len = strlen("\nLet's write this...\n"); memcpy(to_write, "Let's write this...\n\0", len + 1); @@ -169,11 +169,11 @@ void shell(char *str) { reboot(); } else if (!strcmp(str, "huge-alloc")) { - int *i = (void *) kmalloc(sizeof(int)); + int *i = (void *) kmalloc(sizeof(int), 0, 0); kfree(i); } else if (!strcmp(str, "usermode")) { printk("CPU will jump to usermode, this will stop shell, because it is running only in kernel mode.\n"); - init_usermode(); + //init_usermode(); char s[] = "Welcome in usermode!\n"; call(1, (uint32_t) s, (uint32_t) strlen(s), 0, 0, 0); } else if (!strcmp(str, "sys-info")) { diff --git a/kernel/system/task.c b/kernel/system/task.c index 5523696..fa3ceee 100644 --- a/kernel/system/task.c +++ b/kernel/system/task.c @@ -80,7 +80,7 @@ void init_tasking() task_t *create_task(task_t *new_task, void (*main)(), int32_t flags, uint32_t pagedir) { - new_task = (task_t*) kmalloc(sizeof(task_t)); + new_task = (task_t*) kmalloc(sizeof(task_t), 0, 0); new_task->pid = pid; new_task->regs.eax = 0; new_task->regs.ebx = 0; @@ -91,7 +91,7 @@ task_t *create_task(task_t *new_task, void (*main)(), int32_t flags, uint32_t pa new_task->regs.eflags = flags; new_task->regs.eip = (uint32_t) main; new_task->regs.cr3 = (uint32_t) pagedir; - new_task->regs.esp = (uint32_t) kmalloc(2000); + new_task->regs.esp = (uint32_t) kmalloc(2000, 0, 0); new_task->next = 0; if (pid != (uint32_t) 1) { diff --git a/libc/phapi/list.c b/libc/phapi/list.c index f28caeb..da1e49a 100644 --- a/libc/phapi/list.c +++ b/libc/phapi/list.c @@ -13,7 +13,7 @@ int8_t std_lessthan_pred(type_t a, type_t b) list_t create_list(uint32_t max_size, lessthan_pred_t lessthan) { list_t ret; - ret.array = (void*) kmalloc(max_size * sizeof(type_t)); + ret.array = (void*) kmalloc(max_size * sizeof(type_t), 0, 0); memset(ret.array, 0, max_size * sizeof(type_t)); ret.size = 0; ret.max_size = max_size; diff --git a/serial.log b/serial.log new file mode 100644 index 0000000..e69de29 diff --git a/tags b/tags new file mode 100644 index 0000000..5ef02fc --- /dev/null +++ b/tags @@ -0,0 +1,914 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.9~svn20110310 // +ALL_OUR_OBJS kernel/Makefile /^ALL_OUR_OBJS:=\\$/;" m +ARCHDIR kernel/Makefile /^ARCHDIR:=arch\/$(HOSTARCH)$/;" m +ARCHDIR libc/Makefile /^ARCHDIR:=arch\/$(HOSTARCH)$/;" m +ASSERT libc/include/stdlib.h 12;" d +ASSERT sysroot/usr/include/stdlib.h 12;" d +ATEXIT_MAX_FUNCS kernel/include/icxxabi.h 4;" d +ATEXIT_MAX_FUNCS sysroot/usr/include/icxxabi.h 4;" d +Author kernel/include/system.h 12;" d +Author sysroot/usr/include/system.h 12;" d +BACKSPACE kernel/include/keyboard.h 20;" d +BACKSPACE sysroot/usr/include/keyboard.h 20;" d +BINARIES libc/Makefile /^BINARIES=libg.a libk.a $(ARCHDIR)\/crt0.o $(ARCHDIR)\/crti.o $(ARCHDIR)\/crtn.o # add libc.a when user space is ready$/;" m +BOOTDIR kernel/Makefile /^BOOTDIR?=$(EXEC_PREFIX)\/boot$/;" m +CFLAGS kernel/Makefile /^CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS)$/;" m +CFLAGS kernel/Makefile /^CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra$/;" m +CFLAGS kernel/Makefile /^CFLAGS?=-O2 -g$/;" m +CFLAGS libc/Makefile /^CFLAGS:=$(CFLAGS) $(ARCH_CFLAGS)$/;" m +CFLAGS libc/Makefile /^CFLAGS:=$(CFLAGS) -Wall -Wextra$/;" m +CFLAGS libc/Makefile /^CFLAGS?=-O2 -g$/;" m +CHECKSUM kernel/arch/i386/boot/boot.asm /^CHECKSUM equ -(MAGIC + FLAGS) $/;" d +COLOR_BLACK kernel/include/vga.h /^ COLOR_BLACK = 0,$/;" e enum:vga_color +COLOR_BLACK sysroot/usr/include/vga.h /^ COLOR_BLACK = 0,$/;" e enum:vga_color +COLOR_BLUE kernel/include/vga.h /^ COLOR_BLUE = 1,$/;" e enum:vga_color +COLOR_BLUE sysroot/usr/include/vga.h /^ COLOR_BLUE = 1,$/;" e enum:vga_color +COLOR_BROWN kernel/include/vga.h /^ COLOR_BROWN = 6,$/;" e enum:vga_color +COLOR_BROWN sysroot/usr/include/vga.h /^ COLOR_BROWN = 6,$/;" e enum:vga_color +COLOR_CYAN kernel/include/vga.h /^ COLOR_CYAN = 3,$/;" e enum:vga_color +COLOR_CYAN sysroot/usr/include/vga.h /^ COLOR_CYAN = 3,$/;" e enum:vga_color +COLOR_DARK_GREY kernel/include/vga.h /^ COLOR_DARK_GREY = 8,$/;" e enum:vga_color +COLOR_DARK_GREY sysroot/usr/include/vga.h /^ COLOR_DARK_GREY = 8,$/;" e enum:vga_color +COLOR_GREEN kernel/include/vga.h /^ COLOR_GREEN = 2,$/;" e enum:vga_color +COLOR_GREEN sysroot/usr/include/vga.h /^ COLOR_GREEN = 2,$/;" e enum:vga_color +COLOR_LIGHT_BLUE kernel/include/vga.h /^ COLOR_LIGHT_BLUE = 9,$/;" e enum:vga_color +COLOR_LIGHT_BLUE sysroot/usr/include/vga.h /^ COLOR_LIGHT_BLUE = 9,$/;" e enum:vga_color +COLOR_LIGHT_CYAN kernel/include/vga.h /^ COLOR_LIGHT_CYAN = 11,$/;" e enum:vga_color +COLOR_LIGHT_CYAN sysroot/usr/include/vga.h /^ COLOR_LIGHT_CYAN = 11,$/;" e enum:vga_color +COLOR_LIGHT_GREEN kernel/include/vga.h /^ COLOR_LIGHT_GREEN = 10,$/;" e enum:vga_color +COLOR_LIGHT_GREEN sysroot/usr/include/vga.h /^ COLOR_LIGHT_GREEN = 10,$/;" e enum:vga_color +COLOR_LIGHT_GREY kernel/include/vga.h /^ COLOR_LIGHT_GREY = 7,$/;" e enum:vga_color +COLOR_LIGHT_GREY sysroot/usr/include/vga.h /^ COLOR_LIGHT_GREY = 7,$/;" e enum:vga_color +COLOR_LIGHT_MAGENTA kernel/include/vga.h /^ COLOR_LIGHT_MAGENTA = 13,$/;" e enum:vga_color +COLOR_LIGHT_MAGENTA sysroot/usr/include/vga.h /^ COLOR_LIGHT_MAGENTA = 13,$/;" e enum:vga_color +COLOR_LIGHT_RED kernel/include/vga.h /^ COLOR_LIGHT_RED = 12,$/;" e enum:vga_color +COLOR_LIGHT_RED sysroot/usr/include/vga.h /^ COLOR_LIGHT_RED = 12,$/;" e enum:vga_color +COLOR_MAGENTA kernel/include/vga.h /^ COLOR_MAGENTA = 5,$/;" e enum:vga_color +COLOR_MAGENTA sysroot/usr/include/vga.h /^ COLOR_MAGENTA = 5,$/;" e enum:vga_color +COLOR_RED kernel/include/vga.h /^ COLOR_RED = 4,$/;" e enum:vga_color +COLOR_RED sysroot/usr/include/vga.h /^ COLOR_RED = 4,$/;" e enum:vga_color +COLOR_WHITE kernel/include/vga.h /^ COLOR_WHITE = 15,$/;" e enum:vga_color +COLOR_WHITE sysroot/usr/include/vga.h /^ COLOR_WHITE = 15,$/;" e enum:vga_color +COLOR_YELLOW kernel/include/vga.h /^ COLOR_YELLOW = 14,$/;" e enum:vga_color +COLOR_YELLOW sysroot/usr/include/vga.h /^ COLOR_YELLOW = 14,$/;" e enum:vga_color +CPFLAGS kernel/Makefile /^CPFLAGS:=$(CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)$/;" m +CPFLAGS libc/Makefile /^CPFLAGS:=$(CPPFLAGS) $(ARCH_CPPFLAGS)$/;" m +CPPFLAGS kernel/Makefile /^CPPFLAGS:=$(CPPFLAGS) -D__is_photon_kernel -D_TEXTMODE -Iinclude -Iarch\/i386\/include -I..\/libc\/include$/;" m +CPPFLAGS kernel/Makefile /^CPPFLAGS?= $/;" m +CPPFLAGS libc/Makefile /^CPPFLAGS:=$(CPPFLAGS) -D__is_photon_libc -Iinclude$/;" m +CPPFLAGS libc/Makefile /^CPPFLAGS?=$/;" m +CRTBEGIN_OBJ kernel/Makefile /^CRTBEGIN_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtbegin.o)$/;" m +CRTEND_OBJ kernel/Makefile /^CRTEND_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtend.o)$/;" m +CRTI_OBJ kernel/Makefile /^CRTI_OBJ:=$(ARCHDIR)\/crti.o$/;" m +CRTN_OBJ kernel/Makefile /^CRTN_OBJ:=$(ARCHDIR)\/crtn.o$/;" m +DESTDIR kernel/Makefile /^DESTDIR?=$/;" m +DESTDIR libc/Makefile /^DESTDIR?=$/;" m +ENTER kernel/include/keyboard.h 22;" d +ENTER sysroot/usr/include/keyboard.h 22;" d +ESC kernel/include/keyboard.h 19;" d +ESC sysroot/usr/include/keyboard.h 19;" d +EXEC_PREFIX kernel/Makefile /^EXEC_PREFIX?=$(PREFIX)$/;" m +EXEC_PREFIX libc/Makefile /^EXEC_PREFIX?=$(PREFIX)$/;" m +FLAGS kernel/arch/i386/boot/boot.asm /^FLAGS equ MBALIGN | MEMINFO $/;" d +FRAME_ADDR_FROM_INDEX kernel/arch/i386/include/pmm.h 29;" d +FRAME_ADDR_FROM_INDEX sysroot/usr/include/pmm.h 29;" d +FRAME_INDEX kernel/arch/i386/include/pmm.h 27;" d +FRAME_INDEX sysroot/usr/include/pmm.h 27;" d +FRAME_SIZE kernel/arch/i386/include/pmm.h 26;" d +FRAME_SIZE sysroot/usr/include/pmm.h 26;" d +FREEOBJS libc/Makefile /^FREEOBJS:=\\$/;" m +FREQ kernel/include/init.h 22;" d +FREQ kernel/init/init.c 35;" d file: +FREQ sysroot/usr/include/init.h 22;" d +HEAP_END kernel/include/kheap.h 11;" d +HEAP_END sysroot/usr/include/kheap.h 11;" d +HEAP_START kernel/include/kheap.h 10;" d +HEAP_START sysroot/usr/include/kheap.h 10;" d +HOST kernel/Makefile /^HOST?=$(shell ..\/default-host.sh)$/;" m +HOST libc/Makefile /^HOST?=$(shell ..\/default-host.sh)$/;" m +HOSTARCH kernel/Makefile /^HOSTARCH:=$(shell ..\/target-triplet-to-arch.sh $(HOST))$/;" m +HOSTARCH libc/Makefile /^HOSTARCH:=$(shell ..\/target-triplet-to-arch.sh $(HOST))$/;" m +HOSTEDOBJS libc/Makefile /^HOSTEDOBJS:=\\$/;" m +ID_number kernel/include/kernel_class.h /^ int ID_number;$/;" m class:KernelClass +ID_number sysroot/usr/include/kernel_class.h /^ int ID_number;$/;" m class:KernelClass +INCLUDEDIR kernel/Makefile /^INCLUDEDIR?=$(PREFIX)\/include$/;" m +INCLUDEDIR libc/Makefile /^INCLUDEDIR?=$(PREFIX)\/include$/;" m +INDEX_FROM_BIT kernel/include/system.h 19;" d +INDEX_FROM_BIT sysroot/usr/include/system.h 19;" d +IRQ kernel/arch/i386/interrupt.asm /^IRQ 0, 32$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 1, 33$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 2, 34$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 3, 35$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 4, 36$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 5, 37$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 6, 38$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 7, 39$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 8, 40$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 9, 41$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 10, 42$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 11, 43$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 12, 44$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 13, 45$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 14, 46$/;" l +IRQ kernel/arch/i386/interrupt.asm /^IRQ 15, 47$/;" l +IRQ0 kernel/arch/i386/include/handlers.h 70;" d +IRQ0 sysroot/usr/include/handlers.h 70;" d +IRQ1 kernel/arch/i386/include/handlers.h 71;" d +IRQ1 sysroot/usr/include/handlers.h 71;" d +IRQ10 kernel/arch/i386/include/handlers.h 80;" d +IRQ10 sysroot/usr/include/handlers.h 80;" d +IRQ11 kernel/arch/i386/include/handlers.h 81;" d +IRQ11 sysroot/usr/include/handlers.h 81;" d +IRQ12 kernel/arch/i386/include/handlers.h 82;" d +IRQ12 sysroot/usr/include/handlers.h 82;" d +IRQ13 kernel/arch/i386/include/handlers.h 83;" d +IRQ13 sysroot/usr/include/handlers.h 83;" d +IRQ14 kernel/arch/i386/include/handlers.h 84;" d +IRQ14 sysroot/usr/include/handlers.h 84;" d +IRQ15 kernel/arch/i386/include/handlers.h 85;" d +IRQ15 sysroot/usr/include/handlers.h 85;" d +IRQ2 kernel/arch/i386/include/handlers.h 72;" d +IRQ2 sysroot/usr/include/handlers.h 72;" d +IRQ3 kernel/arch/i386/include/handlers.h 73;" d +IRQ3 sysroot/usr/include/handlers.h 73;" d +IRQ4 kernel/arch/i386/include/handlers.h 74;" d +IRQ4 sysroot/usr/include/handlers.h 74;" d +IRQ5 kernel/arch/i386/include/handlers.h 75;" d +IRQ5 sysroot/usr/include/handlers.h 75;" d +IRQ6 kernel/arch/i386/include/handlers.h 76;" d +IRQ6 sysroot/usr/include/handlers.h 76;" d +IRQ7 kernel/arch/i386/include/handlers.h 77;" d +IRQ7 sysroot/usr/include/handlers.h 77;" d +IRQ8 kernel/arch/i386/include/handlers.h 78;" d +IRQ8 sysroot/usr/include/handlers.h 78;" d +IRQ9 kernel/arch/i386/include/handlers.h 79;" d +IRQ9 sysroot/usr/include/handlers.h 79;" d +IRQ_clear_mask kernel/arch/i386/pic.c /^void IRQ_clear_mask(unsigned char IRQline) {$/;" f +IRQ_set_mask kernel/arch/i386/pic.c /^void IRQ_set_mask(unsigned char IRQline) {$/;" f +ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 10$/;" l +ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 11$/;" l +ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 12$/;" l +ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 13$/;" l +ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 14$/;" l +ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 8$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 0$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 1$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 128$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 15$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 16$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 17$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 18$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 19$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 2$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 20$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 21$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 22$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 23$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 24$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 25$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 26$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 27$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 28$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 29$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 3$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 30$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 31$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 4$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 5$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 6$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 7$/;" l +ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 9$/;" l +Intel kernel/system/cpu.c /^char *Intel[] = {$/;" v +Intel_Other kernel/system/cpu.c /^char *Intel_Other[] = {$/;" v +KDEL kernel/include/keyboard.h 43;" d +KDEL sysroot/usr/include/keyboard.h 43;" d +KDOWN kernel/include/keyboard.h 50;" d +KDOWN sysroot/usr/include/keyboard.h 50;" d +KEND kernel/include/keyboard.h 45;" d +KEND sysroot/usr/include/keyboard.h 45;" d +KESC kernel/include/keyboard.h 27;" d +KESC sysroot/usr/include/keyboard.h 27;" d +KEYBOARD_BUFFER_SIZE kernel/include/keyboard.h 11;" d +KEYBOARD_BUFFER_SIZE sysroot/usr/include/keyboard.h 11;" d +KF1 kernel/include/keyboard.h 28;" d +KF1 sysroot/usr/include/keyboard.h 28;" d +KF10 kernel/include/keyboard.h 37;" d +KF10 sysroot/usr/include/keyboard.h 37;" d +KF11 kernel/include/keyboard.h 38;" d +KF11 sysroot/usr/include/keyboard.h 38;" d +KF12 kernel/include/keyboard.h 39;" d +KF12 sysroot/usr/include/keyboard.h 39;" d +KF2 kernel/include/keyboard.h 29;" d +KF2 sysroot/usr/include/keyboard.h 29;" d +KF3 kernel/include/keyboard.h 30;" d +KF3 sysroot/usr/include/keyboard.h 30;" d +KF4 kernel/include/keyboard.h 31;" d +KF4 sysroot/usr/include/keyboard.h 31;" d +KF5 kernel/include/keyboard.h 32;" d +KF5 sysroot/usr/include/keyboard.h 32;" d +KF6 kernel/include/keyboard.h 33;" d +KF6 sysroot/usr/include/keyboard.h 33;" d +KF7 kernel/include/keyboard.h 34;" d +KF7 sysroot/usr/include/keyboard.h 34;" d +KF8 kernel/include/keyboard.h 35;" d +KF8 sysroot/usr/include/keyboard.h 35;" d +KF9 kernel/include/keyboard.h 36;" d +KF9 sysroot/usr/include/keyboard.h 36;" d +KHOME kernel/include/keyboard.h 44;" d +KHOME sysroot/usr/include/keyboard.h 44;" d +KINS kernel/include/keyboard.h 42;" d +KINS sysroot/usr/include/keyboard.h 42;" d +KLEFT kernel/include/keyboard.h 48;" d +KLEFT sysroot/usr/include/keyboard.h 48;" d +KLWIN kernel/include/keyboard.h 65;" d +KLWIN sysroot/usr/include/keyboard.h 65;" d +KMENU kernel/include/keyboard.h 67;" d +KMENU sysroot/usr/include/keyboard.h 67;" d +KMETA_ALT kernel/include/keyboard.h 54;" d +KMETA_ALT sysroot/usr/include/keyboard.h 54;" d +KMETA_ANY kernel/include/keyboard.h 57;" d +KMETA_ANY sysroot/usr/include/keyboard.h 57;" d +KMETA_CAPS kernel/include/keyboard.h 58;" d +KMETA_CAPS sysroot/usr/include/keyboard.h 58;" d +KMETA_CTRL kernel/include/keyboard.h 55;" d +KMETA_CTRL sysroot/usr/include/keyboard.h 55;" d +KMETA_NUM kernel/include/keyboard.h 59;" d +KMETA_NUM sysroot/usr/include/keyboard.h 59;" d +KMETA_SCRL kernel/include/keyboard.h 60;" d +KMETA_SCRL sysroot/usr/include/keyboard.h 60;" d +KMETA_SHIFT kernel/include/keyboard.h 56;" d +KMETA_SHIFT sysroot/usr/include/keyboard.h 56;" d +KPAUSE kernel/include/keyboard.h 64;" d +KPAUSE sysroot/usr/include/keyboard.h 64;" d +KPGDN kernel/include/keyboard.h 47;" d +KPGDN sysroot/usr/include/keyboard.h 47;" d +KPGUP kernel/include/keyboard.h 46;" d +KPGUP sysroot/usr/include/keyboard.h 46;" d +KPRNT kernel/include/keyboard.h 63;" d +KPRNT sysroot/usr/include/keyboard.h 63;" d +KRCAPS_LOCK kernel/include/keyboard.h 74;" d +KRCAPS_LOCK sysroot/usr/include/keyboard.h 74;" d +KRDEL kernel/include/keyboard.h 77;" d +KRDEL sysroot/usr/include/keyboard.h 77;" d +KRIGHT kernel/include/keyboard.h 51;" d +KRIGHT sysroot/usr/include/keyboard.h 51;" d +KRLEFT_ALT kernel/include/keyboard.h 70;" d +KRLEFT_ALT sysroot/usr/include/keyboard.h 70;" d +KRLEFT_CTRL kernel/include/keyboard.h 68;" d +KRLEFT_CTRL sysroot/usr/include/keyboard.h 68;" d +KRLEFT_SHIFT kernel/include/keyboard.h 72;" d +KRLEFT_SHIFT sysroot/usr/include/keyboard.h 72;" d +KRNUM_LOCK kernel/include/keyboard.h 76;" d +KRNUM_LOCK sysroot/usr/include/keyboard.h 76;" d +KRRIGHT_ALT kernel/include/keyboard.h 71;" d +KRRIGHT_ALT sysroot/usr/include/keyboard.h 71;" d +KRRIGHT_CTRL kernel/include/keyboard.h 69;" d +KRRIGHT_CTRL sysroot/usr/include/keyboard.h 69;" d +KRRIGHT_SHIFT kernel/include/keyboard.h 73;" d +KRRIGHT_SHIFT sysroot/usr/include/keyboard.h 73;" d +KRSCROLL_LOCK kernel/include/keyboard.h 75;" d +KRSCROLL_LOCK sysroot/usr/include/keyboard.h 75;" d +KRWIN kernel/include/keyboard.h 66;" d +KRWIN sysroot/usr/include/keyboard.h 66;" d +KUP kernel/include/keyboard.h 49;" d +KUP sysroot/usr/include/keyboard.h 49;" d +KernelClass kernel/include/kernel_class.h /^class KernelClass {$/;" c +KernelClass kernel/init/kernel_class.cpp /^KernelClass::KernelClass()$/;" f class:KernelClass +KernelClass sysroot/usr/include/kernel_class.h /^class KernelClass {$/;" c +LDFLAGS kernel/Makefile /^LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS)$/;" m +LDFLAGS kernel/Makefile /^LDFLAGS:=$(LDFLAGS)$/;" m +LDFLAGS kernel/Makefile /^LDFLAGS?=$/;" m +LDFLAGS libc/Makefile /^LDFLAGS?=$/;" m +LIBDIR libc/Makefile /^LIBDIR?=$(EXEC_PREFIX)\/lib$/;" m +LIBK_CFLAGS libc/Makefile /^LIBK_CFLAGS:=$(CFLAGS) -ffreestanding$/;" m +LIBK_CFLAGS libc/Makefile /^LIBK_CFLAGS:=$(LIBK_CFLAGS) $(KERNEL_ARCH_CFLAGS)$/;" m +LIBK_CPFLAGS libc/Makefile /^LIBK_CPFLAGS:=$(LIBK_CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)$/;" m +LIBK_CPPFLAGS libc/Makefile /^LIBK_CPPFLAGS:=$(CPPFLAGS) -D__is_photon_kernel$/;" m +LIBK_OBJS libc/Makefile /^LIBK_OBJS:=$(FREEOBJS:.o=.libk.o)$/;" m +LIBS kernel/Makefile /^LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS)$/;" m +LIBS kernel/Makefile /^LIBS:=$(LIBS) -nostdlib -lk -lgcc$/;" m +LIBS kernel/Makefile /^LIBS?= -L..\/libc$/;" m +LIBS libc/Makefile /^LIBS?=$/;" m +MAGIC kernel/arch/i386/boot/boot.asm /^MAGIC equ 0x1BADB002 $/;" d +MBALIGN kernel/arch/i386/boot/boot.asm /^MBALIGN equ 1<<0 $/;" d +MEMINFO kernel/arch/i386/boot/boot.asm /^MEMINFO equ 1<<1 $/;" d +MULTIBOOT_FLAG_AOUT kernel/include/multiboot.h 8;" d +MULTIBOOT_FLAG_AOUT sysroot/usr/include/multiboot.h 8;" d +MULTIBOOT_FLAG_APM kernel/include/multiboot.h 13;" d +MULTIBOOT_FLAG_APM sysroot/usr/include/multiboot.h 13;" d +MULTIBOOT_FLAG_CMDLINE kernel/include/multiboot.h 6;" d +MULTIBOOT_FLAG_CMDLINE sysroot/usr/include/multiboot.h 6;" d +MULTIBOOT_FLAG_CONFIG kernel/include/multiboot.h 11;" d +MULTIBOOT_FLAG_CONFIG sysroot/usr/include/multiboot.h 11;" d +MULTIBOOT_FLAG_DEVICE kernel/include/multiboot.h 5;" d +MULTIBOOT_FLAG_DEVICE sysroot/usr/include/multiboot.h 5;" d +MULTIBOOT_FLAG_ELF kernel/include/multiboot.h 9;" d +MULTIBOOT_FLAG_ELF sysroot/usr/include/multiboot.h 9;" d +MULTIBOOT_FLAG_LOADER kernel/include/multiboot.h 12;" d +MULTIBOOT_FLAG_LOADER sysroot/usr/include/multiboot.h 12;" d +MULTIBOOT_FLAG_MEM kernel/include/multiboot.h 4;" d +MULTIBOOT_FLAG_MEM sysroot/usr/include/multiboot.h 4;" d +MULTIBOOT_FLAG_MMAP kernel/include/multiboot.h 10;" d +MULTIBOOT_FLAG_MMAP sysroot/usr/include/multiboot.h 10;" d +MULTIBOOT_FLAG_MODS kernel/include/multiboot.h 7;" d +MULTIBOOT_FLAG_MODS sysroot/usr/include/multiboot.h 7;" d +MULTIBOOT_FLAG_VBE kernel/include/multiboot.h 14;" d +MULTIBOOT_FLAG_VBE sysroot/usr/include/multiboot.h 14;" d +NEWLINE kernel/include/keyboard.h 24;" d +NEWLINE sysroot/usr/include/keyboard.h 24;" d +OBJS kernel/Makefile /^OBJS:=\\$/;" m +OBJS libc/Makefile /^OBJS:=\\$/;" m +OBJ_LINK_LIST kernel/Makefile /^OBJ_LINK_LIST:=\\$/;" m +OFFSET_FROM_BIT kernel/include/system.h 20;" d +OFFSET_FROM_BIT sysroot/usr/include/system.h 20;" d +OS_Name kernel/include/system.h 9;" d +OS_Name sysroot/usr/include/system.h 9;" d +PAGE_ALIGN kernel/arch/i386/include/pmm.h 28;" d +PAGE_ALIGN sysroot/usr/include/pmm.h 28;" d +PIC1 kernel/arch/i386/include/pic.h 4;" d +PIC1 sysroot/usr/include/pic.h 4;" d +PIC1_COMMAND kernel/arch/i386/include/pic.h 6;" d +PIC1_COMMAND sysroot/usr/include/pic.h 6;" d +PIC1_DATA kernel/arch/i386/include/pic.h 7;" d +PIC1_DATA sysroot/usr/include/pic.h 7;" d +PIC2 kernel/arch/i386/include/pic.h 5;" d +PIC2 sysroot/usr/include/pic.h 5;" d +PIC2_COMMAND kernel/arch/i386/include/pic.h 8;" d +PIC2_COMMAND sysroot/usr/include/pic.h 8;" d +PIC2_DATA kernel/arch/i386/include/pic.h 9;" d +PIC2_DATA sysroot/usr/include/pic.h 9;" d +PREFIX kernel/Makefile /^PREFIX?=\/usr\/local$/;" m +PREFIX libc/Makefile /^PREFIX?=\/usr\/local$/;" m +RETURN kernel/include/keyboard.h 23;" d +RETURN sysroot/usr/include/keyboard.h 23;" d +Relase_Date kernel/include/system.h 11;" d +Relase_Date sysroot/usr/include/system.h 11;" d +STDIO_SIZE libc/include/stdio.h 10;" d +STDIO_SIZE sysroot/usr/include/stdio.h 10;" d +TAB kernel/include/keyboard.h 21;" d +TAB sysroot/usr/include/keyboard.h 21;" d +USasciiNonShift kernel/drivers/keyboard.c /^static char USasciiNonShift[] = {$/;" v file: +USasciiShift kernel/drivers/keyboard.c /^static char USasciiShift[] = {$/;" v file: +VGA_HEIGHT kernel/include/vga.h /^static const size_t VGA_HEIGHT = 25;$/;" v +VGA_HEIGHT sysroot/usr/include/vga.h /^static const size_t VGA_HEIGHT = 25;$/;" v +VGA_WIDTH kernel/include/vga.h /^static const size_t VGA_WIDTH = 80;$/;" v +VGA_WIDTH sysroot/usr/include/vga.h /^static const size_t VGA_WIDTH = 80;$/;" v +Version kernel/include/system.h 10;" d +Version sysroot/usr/include/system.h 10;" d +_ICXXABI_H kernel/include/icxxabi.h 2;" d +_ICXXABI_H sysroot/usr/include/icxxabi.h 2;" d +_SYS_CDEFS_H libc/include/sys/cdefs.h 2;" d +_SYS_CDEFS_H sysroot/usr/include/sys/cdefs.h 2;" d +__MULTIBOOT_H kernel/include/multiboot.h 2;" d +__MULTIBOOT_H sysroot/usr/include/multiboot.h 2;" d +__atexit_func_count kernel/init/icxxabi.cpp /^uarch_t __atexit_func_count = 0;$/;" v +__atexit_funcs kernel/init/icxxabi.cpp /^atexit_func_entry_t __atexit_funcs[ATEXIT_MAX_FUNCS];$/;" v +__cxa_atexit kernel/init/icxxabi.cpp /^int __cxa_atexit(void (*f)(void *), void *objptr, void *dso)$/;" f +__cxa_finalize kernel/init/icxxabi.cpp /^void __cxa_finalize(void *f)$/;" f +__cxa_pure_virtual kernel/init/icxxabi.cpp /^extern "C" void __cxa_pure_virtual()$/;" f +__myos_libc libc/include/sys/cdefs.h 4;" d +__myos_libc sysroot/usr/include/sys/cdefs.h 4;" d +_clock_h kernel/arch/i386/include/pit.h 15;" d +_clock_h sysroot/usr/include/pit.h 15;" d +_fini kernel/arch/i386/crti.S /^_fini:$/;" l +_fini libc/arch/i386/crti.S /^_fini:$/;" l +_gdt_h kernel/arch/i386/include/gdt.h 18;" d +_gdt_h sysroot/usr/include/gdt.h 18;" d +_handlers_h kernel/arch/i386/include/handlers.h 17;" d +_handlers_h sysroot/usr/include/handlers.h 17;" d +_idt_h kernel/arch/i386/include/idt.h 15;" d +_idt_h sysroot/usr/include/idt.h 15;" d +_init kernel/arch/i386/crti.S /^_init:$/;" l +_init libc/arch/i386/crti.S /^_init:$/;" l +_init_h kernel/include/init.h 2;" d +_init_h sysroot/usr/include/init.h 2;" d +_io_h kernel/include/io.h 2;" d +_io_h sysroot/usr/include/io.h 2;" d +_kernel_class_h kernel/include/kernel_class.h 2;" d +_kernel_class_h sysroot/usr/include/kernel_class.h 2;" d +_keyboard_h kernel/include/keyboard.h 2;" d +_keyboard_h sysroot/usr/include/keyboard.h 2;" d +_kheap_h kernel/include/kheap.h 2;" d +_kheap_h sysroot/usr/include/kheap.h 2;" d +_list_h libc/include/list.h 2;" d +_list_h sysroot/usr/include/list.h 2;" d +_phapi_h libc/include/phapi.h 2;" d +_phapi_h sysroot/usr/include/phapi.h 2;" d +_pic_h kernel/arch/i386/include/pic.h 2;" d +_pic_h sysroot/usr/include/pic.h 2;" d +_pmm_h kernel/arch/i386/include/pmm.h 21;" d +_pmm_h sysroot/usr/include/pmm.h 21;" d +_start kernel/arch/i386/boot/boot.asm /^_start:$/;" l +_start libc/arch/i386/crt0.S /^_start:$/;" l +_stdio_h libc/include/stdio.h 2;" d +_stdio_h sysroot/usr/include/stdio.h 2;" d +_stdlib_h libc/include/stdlib.h 2;" d +_stdlib_h sysroot/usr/include/stdlib.h 2;" d +_string_h libc/include/string.h 2;" d +_string_h sysroot/usr/include/string.h 2;" d +_system_h kernel/include/system.h 2;" d +_system_h sysroot/usr/include/system.h 2;" d +_task_h kernel/include/task.h 2;" d +_task_h sysroot/usr/include/task.h 2;" d +_time_h kernel/include/time.h 2;" d +_time_h sysroot/usr/include/time.h 2;" d +_vga_h kernel/include/vga.h 2;" d +_vga_h sysroot/usr/include/vga.h 2;" d +_vmm_h kernel/arch/i386/include/vmm.h 2;" d +_vmm_h sysroot/usr/include/vmm.h 2;" d +abort libc/stdlib/abort.c /^void abort(void)$/;" f +access kernel/arch/i386/include/gdt.h /^ uint8_t access;$/;" m struct:gdt_entry_struct +access sysroot/usr/include/gdt.h /^ uint8_t access;$/;" m struct:gdt_entry_struct +add_hex_prefix libc/stdlib/itoa.c /^static void add_hex_prefix(char *buf)$/;" f file: +addr kernel/include/multiboot.h /^ uint32_t addr;$/;" m struct:multiboot +addr sysroot/usr/include/multiboot.h /^ uint32_t addr;$/;" m struct:multiboot +allocated kernel/include/kheap.h /^ uint32_t allocated : 1;$/;" m struct:header +allocated sysroot/usr/include/kheap.h /^ uint32_t allocated : 1;$/;" m struct:header +always0 kernel/arch/i386/include/idt.h /^ uint8_t always0; $/;" m struct:idt_entry_struct +always0 sysroot/usr/include/idt.h /^ uint8_t always0; $/;" m struct:idt_entry_struct +apm_table kernel/include/multiboot.h /^ uint32_t apm_table;$/;" m struct:multiboot +apm_table sysroot/usr/include/multiboot.h /^ uint32_t apm_table;$/;" m struct:multiboot +array libc/include/list.h /^ type_t *array;$/;" m struct:__anon1 +array sysroot/usr/include/list.h /^ type_t *array;$/;" m struct:__anon2 +ascii_S kernel/include/keyboard.h /^char *ascii_S;$/;" v +ascii_S sysroot/usr/include/keyboard.h /^char *ascii_S;$/;" v +ascii_s kernel/include/keyboard.h /^char *ascii_s;$/;" v +ascii_s sysroot/usr/include/keyboard.h /^char *ascii_s;$/;" v +atexit_func_entry_t kernel/include/icxxabi.h /^struct atexit_func_entry_t$/;" s +atexit_func_entry_t sysroot/usr/include/icxxabi.h /^struct atexit_func_entry_t$/;" s +atoi libc/stdlib/atoi.c /^int atoi(char *str)$/;" f +base kernel/arch/i386/include/gdt.h /^ uint32_t base;$/;" m struct:gdt_ptr_struct +base kernel/arch/i386/include/idt.h /^ uint32_t base; $/;" m struct:idt_ptr_struct +base sysroot/usr/include/gdt.h /^ uint32_t base;$/;" m struct:gdt_ptr_struct +base sysroot/usr/include/idt.h /^ uint32_t base; $/;" m struct:idt_ptr_struct +base_hi kernel/arch/i386/include/idt.h /^ uint16_t base_hi; $/;" m struct:idt_entry_struct +base_hi sysroot/usr/include/idt.h /^ uint16_t base_hi; $/;" m struct:idt_entry_struct +base_high kernel/arch/i386/include/gdt.h /^ uint8_t base_high;$/;" m struct:gdt_entry_struct +base_high sysroot/usr/include/gdt.h /^ uint8_t base_high;$/;" m struct:gdt_entry_struct +base_lo kernel/arch/i386/include/idt.h /^ uint16_t base_lo;$/;" m struct:idt_entry_struct +base_lo sysroot/usr/include/idt.h /^ uint16_t base_lo;$/;" m struct:idt_entry_struct +base_low kernel/arch/i386/include/gdt.h /^ uint16_t base_low;$/;" m struct:gdt_entry_struct +base_low sysroot/usr/include/gdt.h /^ uint16_t base_low;$/;" m struct:gdt_entry_struct +base_mid kernel/arch/i386/include/gdt.h /^ uint8_t base_mid;$/;" m struct:gdt_entry_struct +base_mid sysroot/usr/include/gdt.h /^ uint8_t base_mid;$/;" m struct:gdt_entry_struct +boot_device kernel/include/multiboot.h /^ uint32_t boot_device;$/;" m struct:multiboot +boot_device sysroot/usr/include/multiboot.h /^ uint32_t boot_device;$/;" m struct:multiboot +boot_loader_name kernel/include/multiboot.h /^ uint32_t boot_loader_name;$/;" m struct:multiboot +boot_loader_name sysroot/usr/include/multiboot.h /^ uint32_t boot_loader_name;$/;" m struct:multiboot +call kernel/drivers/io.c /^void call(int32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx, uint32_t esi, uint32_t edi)$/;" f +clear_vga kernel/drivers/vga.c /^void clear_vga()$/;" f +cli kernel/include/system.h 15;" d +cli sysroot/usr/include/system.h 15;" d +cmdline kernel/include/multiboot.h /^ uint32_t cmdline;$/;" m struct:multiboot +cmdline sysroot/usr/include/multiboot.h /^ uint32_t cmdline;$/;" m struct:multiboot +col kernel/drivers/vga.c /^size_t col;$/;" v +config_table kernel/include/multiboot.h /^ uint32_t config_table;$/;" m struct:multiboot +config_table sysroot/usr/include/multiboot.h /^ uint32_t config_table;$/;" m struct:multiboot +cpuid kernel/system/cpu.c 35;" d file: +cr3 kernel/arch/i386/include/gdt.h /^ uint32_t cr3;$/;" m struct:tss_entry_struct +cr3 kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +cr3 sysroot/usr/include/gdt.h /^ uint32_t cr3;$/;" m struct:tss_entry_struct +cr3 sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +create_list libc/phapi/list.c /^list_t create_list(uint32_t max_size, lessthan_pred_t lessthan)$/;" f +create_task kernel/system/task.c /^task_t *create_task(task_t *new_task, void (*main)(), int32_t flags, uint32_t pagedir)$/;" f +cs kernel/arch/i386/include/gdt.h /^ uint32_t cs; \/\/ The value to load into CS when we change to kernel mode.$/;" m struct:tss_entry_struct +cs kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +cs sysroot/usr/include/gdt.h /^ uint32_t cs; \/\/ The value to load into CS when we change to kernel mode.$/;" m struct:tss_entry_struct +cs sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +current_task kernel/include/task.h /^task_t *current_task;$/;" v +current_task sysroot/usr/include/task.h /^task_t *current_task;$/;" v +debug_mem_mngr kernel/arch/i386/vmm.c /^void debug_mem_mngr()$/;" f +default_bg kernel/drivers/vga.c /^enum vga_color default_bg = COLOR_BLACK;$/;" v typeref:enum:vga_color +default_fg kernel/drivers/vga.c /^enum vga_color default_fg = COLOR_LIGHT_GREY;$/;" v typeref:enum:vga_color +destroy_list libc/phapi/list.c /^void destroy_list(list_t *array)$/;" f +destructor_func kernel/include/icxxabi.h /^ void (*destructor_func)(void *);$/;" m struct:atexit_func_entry_t +destructor_func sysroot/usr/include/icxxabi.h /^ void (*destructor_func)(void *);$/;" m struct:atexit_func_entry_t +detect_cpu kernel/system/cpu.c /^int detect_cpu(void) { \/* or main() if your trying to port this as an independant application *\/$/;" f +do_amd kernel/system/cpu.c /^int do_amd(void) {$/;" f +do_intel kernel/system/cpu.c /^int do_intel(void) {$/;" f +drives_addr kernel/include/multiboot.h /^ uint32_t drives_addr;$/;" m struct:multiboot +drives_addr sysroot/usr/include/multiboot.h /^ uint32_t drives_addr;$/;" m struct:multiboot +drives_length kernel/include/multiboot.h /^ uint32_t drives_length;$/;" m struct:multiboot +drives_length sysroot/usr/include/multiboot.h /^ uint32_t drives_length;$/;" m struct:multiboot +ds kernel/arch/i386/include/gdt.h /^ uint32_t ds; \/\/ The value to load into DS when we change to kernel mode.$/;" m struct:tss_entry_struct +ds kernel/include/system.h /^ uint32_t ds; \/\/ Data segment selector$/;" m struct:registers +ds sysroot/usr/include/gdt.h /^ uint32_t ds; \/\/ The value to load into DS when we change to kernel mode.$/;" m struct:tss_entry_struct +ds sysroot/usr/include/system.h /^ uint32_t ds; \/\/ Data segment selector$/;" m struct:registers +dso_handle kernel/include/icxxabi.h /^ void *dso_handle;$/;" m struct:atexit_func_entry_t +dso_handle sysroot/usr/include/icxxabi.h /^ void *dso_handle;$/;" m struct:atexit_func_entry_t +eax kernel/arch/i386/include/gdt.h /^ uint32_t eax;$/;" m struct:tss_entry_struct +eax kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +eax kernel/include/system.h /^ uint32_t eax;$/;" m struct:g_regs +eax kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +eax sysroot/usr/include/gdt.h /^ uint32_t eax;$/;" m struct:tss_entry_struct +eax sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +eax sysroot/usr/include/system.h /^ uint32_t eax;$/;" m struct:g_regs +eax sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +ebp kernel/arch/i386/include/gdt.h /^ uint32_t ebp;$/;" m struct:tss_entry_struct +ebp kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +ebp kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +ebp sysroot/usr/include/gdt.h /^ uint32_t ebp;$/;" m struct:tss_entry_struct +ebp sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +ebp sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +ebx kernel/arch/i386/include/gdt.h /^ uint32_t ebx;$/;" m struct:tss_entry_struct +ebx kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +ebx kernel/include/system.h /^ uint32_t ebx;$/;" m struct:g_regs +ebx kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +ebx sysroot/usr/include/gdt.h /^ uint32_t ebx;$/;" m struct:tss_entry_struct +ebx sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +ebx sysroot/usr/include/system.h /^ uint32_t ebx;$/;" m struct:g_regs +ebx sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +ecx kernel/arch/i386/include/gdt.h /^ uint32_t ecx;$/;" m struct:tss_entry_struct +ecx kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +ecx kernel/include/system.h /^ uint32_t ecx;$/;" m struct:g_regs +ecx kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +ecx sysroot/usr/include/gdt.h /^ uint32_t ecx;$/;" m struct:tss_entry_struct +ecx sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +ecx sysroot/usr/include/system.h /^ uint32_t ecx;$/;" m struct:g_regs +ecx sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +edi kernel/arch/i386/include/gdt.h /^ uint32_t edi;$/;" m struct:tss_entry_struct +edi kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +edi kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +edi kernel/include/system.h /^ uint32_t edi;$/;" m struct:g_regs +edi sysroot/usr/include/gdt.h /^ uint32_t edi;$/;" m struct:tss_entry_struct +edi sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +edi sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +edi sysroot/usr/include/system.h /^ uint32_t edi;$/;" m struct:g_regs +edx kernel/arch/i386/include/gdt.h /^ uint32_t edx;$/;" m struct:tss_entry_struct +edx kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +edx kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +edx kernel/include/system.h /^ uint32_t edx;$/;" m struct:g_regs +edx sysroot/usr/include/gdt.h /^ uint32_t edx;$/;" m struct:tss_entry_struct +edx sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +edx sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +edx sysroot/usr/include/system.h /^ uint32_t edx;$/;" m struct:g_regs +eflags kernel/arch/i386/include/gdt.h /^ uint32_t eflags;$/;" m struct:tss_entry_struct +eflags kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +eflags kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +eflags sysroot/usr/include/gdt.h /^ uint32_t eflags;$/;" m struct:tss_entry_struct +eflags sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +eflags sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +eip kernel/arch/i386/include/gdt.h /^ uint32_t eip;$/;" m struct:tss_entry_struct +eip kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +eip kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +eip sysroot/usr/include/gdt.h /^ uint32_t eip;$/;" m struct:tss_entry_struct +eip sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +eip sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +err_code kernel/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers +err_code sysroot/usr/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers +es kernel/arch/i386/include/gdt.h /^ uint32_t es; \/\/ The value to load into ES when we change to kernel mode.$/;" m struct:tss_entry_struct +es sysroot/usr/include/gdt.h /^ uint32_t es; \/\/ The value to load into ES when we change to kernel mode.$/;" m struct:tss_entry_struct +esi kernel/arch/i386/include/gdt.h /^ uint32_t esi;$/;" m struct:tss_entry_struct +esi kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +esi kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +esi kernel/include/system.h /^ uint32_t esi;$/;" m struct:g_regs +esi sysroot/usr/include/gdt.h /^ uint32_t esi;$/;" m struct:tss_entry_struct +esi sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +esi sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +esi sysroot/usr/include/system.h /^ uint32_t esi;$/;" m struct:g_regs +esp kernel/arch/i386/include/gdt.h /^ uint32_t esp;$/;" m struct:tss_entry_struct +esp kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +esp kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +esp sysroot/usr/include/gdt.h /^ uint32_t esp;$/;" m struct:tss_entry_struct +esp sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs +esp sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers +esp0 kernel/arch/i386/include/gdt.h /^ uint32_t esp0; \/\/ The stack pointer to load when we change to kernel mode.$/;" m struct:tss_entry_struct +esp0 sysroot/usr/include/gdt.h /^ uint32_t esp0; \/\/ The stack pointer to load when we change to kernel mode.$/;" m struct:tss_entry_struct +esp1 kernel/arch/i386/include/gdt.h /^ uint32_t esp1; \/\/ Unused...$/;" m struct:tss_entry_struct +esp1 sysroot/usr/include/gdt.h /^ uint32_t esp1; \/\/ Unused...$/;" m struct:tss_entry_struct +esp2 kernel/arch/i386/include/gdt.h /^ uint32_t esp2;$/;" m struct:tss_entry_struct +esp2 sysroot/usr/include/gdt.h /^ uint32_t esp2;$/;" m struct:tss_entry_struct +exit libc/stdlib/exit.c /^void exit(int status)$/;" f +extern kernel/arch/i386/interrupt.asm /^extern irq_handler$/;" l +extern kernel/arch/i386/interrupt.asm /^extern isr_handler$/;" l +find_frame kernel/arch/i386/pmm.c /^uint32_t find_frame()$/;" f +flags kernel/arch/i386/include/idt.h /^ uint8_t flags; $/;" m struct:idt_entry_struct +flags kernel/include/multiboot.h /^ uint32_t flags;$/;" m struct:multiboot +flags sysroot/usr/include/idt.h /^ uint8_t flags; $/;" m struct:idt_entry_struct +flags sysroot/usr/include/multiboot.h /^ uint32_t flags;$/;" m struct:multiboot +flush_tlb kernel/arch/i386/page.asm /^flush_tlb:$/;" l +frames kernel/arch/i386/pmm.c /^uint32_t *frames;$/;" v +free_frame kernel/arch/i386/pmm.c /^void free_frame(uint32_t addr)$/;" f +fs kernel/arch/i386/include/gdt.h /^ uint32_t fs; \/\/ The value to load into FS when we change to kernel mode.$/;" m struct:tss_entry_struct +fs sysroot/usr/include/gdt.h /^ uint32_t fs; \/\/ The value to load into FS when we change to kernel mode.$/;" m struct:tss_entry_struct +g_regs kernel/include/system.h /^typedef struct g_regs$/;" s +g_regs sysroot/usr/include/system.h /^typedef struct g_regs$/;" s +g_regs_t kernel/include/system.h /^} g_regs_t; \/\/ general registers for system calls$/;" t typeref:struct:g_regs +g_regs_t sysroot/usr/include/system.h /^} g_regs_t; \/\/ general registers for system calls$/;" t typeref:struct:g_regs +gdt_entries kernel/arch/i386/include/gdt.h /^gdt_entry_t gdt_entries[5];$/;" v +gdt_entries sysroot/usr/include/gdt.h /^gdt_entry_t gdt_entries[5];$/;" v +gdt_entry_struct kernel/arch/i386/include/gdt.h /^struct gdt_entry_struct$/;" s +gdt_entry_struct sysroot/usr/include/gdt.h /^struct gdt_entry_struct$/;" s +gdt_entry_t kernel/arch/i386/include/gdt.h /^typedef struct gdt_entry_struct gdt_entry_t;$/;" t typeref:struct:gdt_entry_struct +gdt_entry_t sysroot/usr/include/gdt.h /^typedef struct gdt_entry_struct gdt_entry_t;$/;" t typeref:struct:gdt_entry_struct +gdt_flush kernel/arch/i386/descriptor_tables.asm /^gdt_flush:$/;" l +gdt_ptr kernel/arch/i386/include/gdt.h /^gdt_ptr_t gdt_ptr;$/;" v +gdt_ptr sysroot/usr/include/gdt.h /^gdt_ptr_t gdt_ptr;$/;" v +gdt_ptr_struct kernel/arch/i386/include/gdt.h /^struct gdt_ptr_struct$/;" s +gdt_ptr_struct sysroot/usr/include/gdt.h /^struct gdt_ptr_struct$/;" s +gdt_ptr_t kernel/arch/i386/include/gdt.h /^typedef struct gdt_ptr_struct gdt_ptr_t;$/;" t typeref:struct:gdt_ptr_struct +gdt_ptr_t sysroot/usr/include/gdt.h /^typedef struct gdt_ptr_struct gdt_ptr_t;$/;" t typeref:struct:gdt_ptr_struct +gdt_set_gate kernel/arch/i386/gdt.c /^void gdt_set_gate(int32_t num, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran)$/;" f +getID kernel/init/kernel_class.cpp /^int KernelClass::getID()$/;" f class:KernelClass +getVersion kernel/init/kernel_class.cpp /^char *KernelClass::getVersion()$/;" f class:KernelClass +get_tick kernel/arch/i386/pit.c /^int get_tick()$/;" f +getch libc/stdio/getch.c /^int getch()$/;" f +getchar libc/stdio/getchar.c /^int getchar()$/;" f +gets libc/stdio/gets.c /^char *gets(char *str)$/;" f +global kernel/arch/i386/boot/boot.asm /^global _start$/;" l +global kernel/arch/i386/boot/boot.asm /^global stack_bottom$/;" l +global kernel/arch/i386/boot/boot.asm /^global stack_top$/;" l +granularity kernel/arch/i386/include/gdt.h /^ uint8_t granularity;$/;" m struct:gdt_entry_struct +granularity sysroot/usr/include/gdt.h /^ uint8_t granularity;$/;" m struct:gdt_entry_struct +gs kernel/arch/i386/include/gdt.h /^ uint32_t gs; \/\/ The value to load into GS when we change to kernel mode.$/;" m struct:tss_entry_struct +gs sysroot/usr/include/gdt.h /^ uint32_t gs; \/\/ The value to load into GS when we change to kernel mode.$/;" m struct:tss_entry_struct +header kernel/include/kheap.h /^typedef struct header$/;" s +header sysroot/usr/include/kheap.h /^typedef struct header$/;" s +header_t kernel/include/kheap.h /^} header_t;$/;" t typeref:struct:header +header_t sysroot/usr/include/kheap.h /^} header_t;$/;" t typeref:struct:header +hlt kernel/include/system.h 16;" d +hlt sysroot/usr/include/system.h 16;" d +hours kernel/include/time.h /^int hours;$/;" v +hours sysroot/usr/include/time.h /^int hours;$/;" v +idt_entries kernel/arch/i386/include/idt.h /^idt_entry_t idt_entries[256];$/;" v +idt_entries sysroot/usr/include/idt.h /^idt_entry_t idt_entries[256];$/;" v +idt_entry_struct kernel/arch/i386/include/idt.h /^struct idt_entry_struct$/;" s +idt_entry_struct sysroot/usr/include/idt.h /^struct idt_entry_struct$/;" s +idt_entry_t kernel/arch/i386/include/idt.h /^typedef struct idt_entry_struct idt_entry_t;$/;" t typeref:struct:idt_entry_struct +idt_entry_t sysroot/usr/include/idt.h /^typedef struct idt_entry_struct idt_entry_t;$/;" t typeref:struct:idt_entry_struct +idt_flush kernel/arch/i386/descriptor_tables.asm /^idt_flush:$/;" l +idt_ptr kernel/arch/i386/include/idt.h /^idt_ptr_t idt_ptr; $/;" v +idt_ptr sysroot/usr/include/idt.h /^idt_ptr_t idt_ptr; $/;" v +idt_ptr_struct kernel/arch/i386/include/idt.h /^struct idt_ptr_struct$/;" s +idt_ptr_struct sysroot/usr/include/idt.h /^struct idt_ptr_struct$/;" s +idt_ptr_t kernel/arch/i386/include/idt.h /^typedef struct idt_ptr_struct idt_ptr_t;$/;" t typeref:struct:idt_ptr_struct +idt_ptr_t sysroot/usr/include/idt.h /^typedef struct idt_ptr_struct idt_ptr_t;$/;" t typeref:struct:idt_ptr_struct +idt_set_gate kernel/arch/i386/idt.c /^void idt_set_gate(uint8_t num, uint32_t base, uint16_t sel, uint8_t flags)$/;" f +in_size libc/include/stdio.h /^volatile int in_size;$/;" v +in_size sysroot/usr/include/stdio.h /^volatile int in_size;$/;" v +inb kernel/drivers/io.c /^uint8_t inb(uint32_t ad)$/;" f +inbuffer kernel/include/init.h /^uint8_t *inbuffer;$/;" v +inbuffer sysroot/usr/include/init.h /^uint8_t *inbuffer;$/;" v +init kernel/init/init.c /^void init(multiboot *mboot_ptr, uint32_t init_stack) {$/;" f +init_esp kernel/system/system.c /^uint32_t init_esp;$/;" v +init_gdt kernel/arch/i386/gdt.c /^void init_gdt()$/;" f +init_heap kernel/system/kheap.c /^void init_heap ()$/;" f +init_idt kernel/arch/i386/idt.c /^void init_idt()$/;" f +init_irq kernel/arch/i386/handlers.c /^void init_irq()$/;" f +init_isr kernel/arch/i386/handlers.c /^void init_isr()$/;" f +init_pmm kernel/arch/i386/pmm.c /^void init_pmm(uint32_t mem_size)$/;" f +init_stdio kernel/init/init.c /^void init_stdio() {$/;" f +init_tasking kernel/system/task.c /^void init_tasking()$/;" f +init_time kernel/system/time.c /^void init_time()$/;" f +init_timer kernel/arch/i386/pit.c /^void init_timer(uint32_t frequency)$/;" f +init_usermode kernel/system/task.c /^void init_usermode() {$/;" f +init_vga kernel/drivers/vga.c /^void init_vga()$/;" f +init_vmm kernel/arch/i386/vmm.c /^void init_vmm()$/;" f +inl kernel/drivers/io.c /^uint32_t inl(uint32_t ad)$/;" f +insert_list libc/phapi/list.c /^void insert_list(type_t item, list_t *array)$/;" f +install_keyboard kernel/drivers/keyboard.c /^void install_keyboard()$/;" f +int_no kernel/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers +int_no sysroot/usr/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers +interrupt_handlers kernel/arch/i386/handlers.c /^isr_t interrupt_handlers[256];$/;" v +intlen libc/stdlib/intlen.c /^int intlen(int n, int base)$/;" f +inw kernel/drivers/io.c /^uint16_t inw(uint32_t ad)$/;" f +iomap_base kernel/arch/i386/include/gdt.h /^ uint16_t iomap_base;$/;" m struct:tss_entry_struct +iomap_base sysroot/usr/include/gdt.h /^ uint16_t iomap_base;$/;" m struct:tss_entry_struct +irq_common_stub kernel/arch/i386/interrupt.asm /^irq_common_stub:$/;" l +irq_handler kernel/arch/i386/handlers.c /^void irq_handler(registers_t regs)$/;" f +isr_common_stub kernel/arch/i386/interrupt.asm /^isr_common_stub:$/;" l +isr_handler kernel/arch/i386/handlers.c /^void isr_handler(registers_t regs)$/;" f +isr_t kernel/include/system.h /^typedef void (*isr_t)(registers_t*);$/;" t +isr_t sysroot/usr/include/system.h /^typedef void (*isr_t)(registers_t*);$/;" t +itoa libc/stdlib/itoa.c /^void itoa(char *buf, unsigned long int n, int base)$/;" f +kb_buffer kernel/include/keyboard.h /^uint8_t kb_buffer[KEYBOARD_BUFFER_SIZE];$/;" v +kb_buffer sysroot/usr/include/keyboard.h /^uint8_t kb_buffer[KEYBOARD_BUFFER_SIZE];$/;" v +keep_running kernel/include/system.h 17;" d +keep_running sysroot/usr/include/system.h 17;" d +keyboard_handler kernel/include/keyboard.h /^void (*keyboard_handler)(uint8_t *buf, uint16_t size); $/;" v +keyboard_handler sysroot/usr/include/keyboard.h /^void (*keyboard_handler)(uint8_t *buf, uint16_t size); $/;" v +keyboard_interrupt_handler kernel/drivers/keyboard.c /^void keyboard_interrupt_handler(__attribute__ ((unused)) registers_t *regs)$/;" f +keyboard_set_handler kernel/drivers/keyboard.c /^void keyboard_set_handler(void (*callback)(uint8_t *buf, uint16_t size))$/;" f +kfree kernel/system/kheap.c /^void kfree (void *p)$/;" f +kmain kernel/init/main.cpp /^void kmain(multiboot *mboot_ptr, uint32_t init_stack) {$/;" f +kmalloc kernel/system/kheap.c /^void *kmalloc (uint32_t p)$/;" f +last kernel/include/keyboard.h /^int last;$/;" v +last sysroot/usr/include/keyboard.h /^int last;$/;" v +ldt kernel/arch/i386/include/gdt.h /^ uint32_t ldt; \/\/ Unused...$/;" m struct:tss_entry_struct +ldt sysroot/usr/include/gdt.h /^ uint32_t ldt; \/\/ Unused...$/;" m struct:tss_entry_struct +length kernel/include/kheap.h /^ uint32_t length : 31;$/;" m struct:header +length sysroot/usr/include/kheap.h /^ uint32_t length : 31;$/;" m struct:header +lessthan libc/include/list.h /^ lessthan_pred_t lessthan;$/;" m struct:__anon1 +lessthan sysroot/usr/include/list.h /^ lessthan_pred_t lessthan;$/;" m struct:__anon2 +lessthan_pred_t libc/include/list.h /^typedef int8_t (*lessthan_pred_t)(type_t, type_t);$/;" t +lessthan_pred_t sysroot/usr/include/list.h /^typedef int8_t (*lessthan_pred_t)(type_t, type_t);$/;" t +lim kernel/arch/i386/include/gdt.h /^ uint16_t lim;$/;" m struct:gdt_ptr_struct +lim sysroot/usr/include/gdt.h /^ uint16_t lim;$/;" m struct:gdt_ptr_struct +lim_low kernel/arch/i386/include/gdt.h /^ uint16_t lim_low;$/;" m struct:gdt_entry_struct +lim_low sysroot/usr/include/gdt.h /^ uint16_t lim_low;$/;" m struct:gdt_entry_struct +limit kernel/arch/i386/include/idt.h /^ uint16_t limit;$/;" m struct:idt_ptr_struct +limit sysroot/usr/include/idt.h /^ uint16_t limit;$/;" m struct:idt_ptr_struct +list_t libc/include/list.h /^} list_t;$/;" t typeref:struct:__anon1 +list_t sysroot/usr/include/list.h /^} list_t;$/;" t typeref:struct:__anon2 +login kernel/init/init.c /^void login() {$/;" f +lookup_list libc/phapi/list.c /^type_t lookup_list(uint32_t i, list_t *array)$/;" f +machine kernel/system/system.c /^char machine[30];$/;" v +make_color kernel/drivers/vga.c /^uint8_t make_color(enum vga_color fg, enum vga_color bg)$/;" f +make_vgaentry kernel/drivers/vga.c /^uint16_t make_vgaentry(char c, uint8_t color)$/;" f +max_size libc/include/list.h /^ uint32_t max_size;$/;" m struct:__anon1 +max_size sysroot/usr/include/list.h /^ uint32_t max_size;$/;" m struct:__anon2 +mem_lower kernel/include/multiboot.h /^ uint32_t mem_lower;$/;" m struct:multiboot +mem_lower sysroot/usr/include/multiboot.h /^ uint32_t mem_lower;$/;" m struct:multiboot +mem_upper kernel/include/multiboot.h /^ uint32_t mem_upper;$/;" m struct:multiboot +mem_upper sysroot/usr/include/multiboot.h /^ uint32_t mem_upper;$/;" m struct:multiboot +memcmp libc/string/memcmp.c /^int memcmp(const void* aptr, const void* bptr, size_t size)$/;" f +memcpy libc/string/memcpy.c /^void* memcpy(void* dstptr, const void* srcptr, size_t size)$/;" f +memmove libc/string/memmove.c /^void* memmove(void* dstptr, const void* srcptr, size_t size)$/;" f +memset libc/string/memset.c /^void* memset(void* bufptr, int value, size_t size)$/;" f +memsetw libc/string/memsetw.c /^void *memsetw(void *s, int c, size_t n)$/;" f +minutes kernel/include/time.h /^int minutes;$/;" v +minutes sysroot/usr/include/time.h /^int minutes;$/;" v +mmap_addr kernel/include/multiboot.h /^ uint32_t mmap_addr;$/;" m struct:multiboot +mmap_addr sysroot/usr/include/multiboot.h /^ uint32_t mmap_addr;$/;" m struct:multiboot +mmap_length kernel/include/multiboot.h /^ uint32_t mmap_length;$/;" m struct:multiboot +mmap_length sysroot/usr/include/multiboot.h /^ uint32_t mmap_length;$/;" m struct:multiboot +mods_addr kernel/include/multiboot.h /^ uint32_t mods_addr;$/;" m struct:multiboot +mods_addr sysroot/usr/include/multiboot.h /^ uint32_t mods_addr;$/;" m struct:multiboot +mods_count kernel/include/multiboot.h /^ uint32_t mods_count;$/;" m struct:multiboot +mods_count sysroot/usr/include/multiboot.h /^ uint32_t mods_count;$/;" m struct:multiboot +mseconds kernel/include/time.h /^int mseconds;$/;" v +mseconds sysroot/usr/include/time.h /^int mseconds;$/;" v +multiboot kernel/include/multiboot.h /^typedef struct multiboot$/;" s +multiboot kernel/include/multiboot.h /^} multiboot;$/;" t typeref:struct:multiboot +multiboot sysroot/usr/include/multiboot.h /^typedef struct multiboot$/;" s +multiboot sysroot/usr/include/multiboot.h /^} multiboot;$/;" t typeref:struct:multiboot +next kernel/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header:: +next kernel/include/task.h /^ struct task *next;$/;" m struct:task typeref:struct:task::task +next sysroot/usr/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header:: +next sysroot/usr/include/task.h /^ struct task *next;$/;" m struct:task typeref:struct:task::task +nframes kernel/arch/i386/pmm.c /^uint32_t nframes;$/;" v +num kernel/include/multiboot.h /^ uint32_t num;$/;" m struct:multiboot +num sysroot/usr/include/multiboot.h /^ uint32_t num;$/;" m struct:multiboot +num_syscalls kernel/system/task.c /^int num_syscalls = 1;$/;" v +obj_ptr kernel/include/icxxabi.h /^ void *obj_ptr;$/;" m struct:atexit_func_entry_t +obj_ptr sysroot/usr/include/icxxabi.h /^ void *obj_ptr;$/;" m struct:atexit_func_entry_t +out_crs libc/include/stdio.h /^int out_crs;$/;" v +out_crs sysroot/usr/include/stdio.h /^int out_crs;$/;" v +outb kernel/drivers/io.c /^void outb(uint32_t ad, uint8_t v)$/;" f +outbuffer kernel/include/init.h /^char *outbuffer;$/;" v +outbuffer sysroot/usr/include/init.h /^char *outbuffer;$/;" v +outl kernel/drivers/io.c /^void outl(uint32_t ad, uint32_t v)$/;" f +outw kernel/drivers/io.c /^void outw(uint32_t ad, uint16_t v)$/;" f +paging_enabled kernel/arch/i386/pmm.c /^int paging_enabled = 0;$/;" v +panic kernel/system/system.c /^void panic(const char *msg, int line, char *file)$/;" f +pid kernel/include/task.h /^ uint32_t pid;$/;" m struct:task +pid kernel/include/task.h /^uint32_t pid;$/;" v +pid sysroot/usr/include/task.h /^ uint32_t pid;$/;" m struct:task +pid sysroot/usr/include/task.h /^uint32_t pid;$/;" v +place_list libc/phapi/list.c /^list_t place_list(void *addr, uint32_t max_size, lessthan_pred_t lessthan)$/;" f +placement_addr kernel/arch/i386/pmm.c /^uint32_t placement_addr = (uint32_t) &kernel_end;$/;" v +preempt kernel/system/task.c /^void preempt()$/;" f +prev kernel/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header::header +prev sysroot/usr/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header::header +prev_tss kernel/arch/i386/include/gdt.h /^ uint32_t prev_tss; \/\/ The previous TSS - if we used hardware task switching this would form a linked list.$/;" m struct:tss_entry_struct +prev_tss sysroot/usr/include/gdt.h /^ uint32_t prev_tss; \/\/ The previous TSS - if we used hardware task switching this would form a linked list.$/;" m struct:tss_entry_struct +print_regs kernel/drivers/io.c /^void print_regs(registers_t *regs)$/;" f +print_time kernel/system/time.c /^void print_time()$/;" f +printf libc/stdio/printf.c /^int printf(const char* restrict format, ...)$/;" f +printk kernel/drivers/io.c /^int printk(const char* format, ...)$/;" f +printregs kernel/system/cpu.c /^void printregs(int eax, int ebx, int ecx, int edx) {$/;" f +prompt kernel/system/system.c /^void prompt() {$/;" f +putchar libc/stdio/putchar.c /^void putchar(char c)$/;" f +puts libc/stdio/puts.c /^int puts(const char* string)$/;" f +read_cr0 kernel/arch/i386/page.asm /^read_cr0:$/;" l +read_cr3 kernel/arch/i386/page.asm /^read_cr3:$/;" l +read_eip kernel/arch/i386/descriptor_tables.asm /^read_eip:$/;" l +read_kb_buff kernel/drivers/keyboard.c /^void read_kb_buff(uint8_t *buf, uint16_t size) $/;" f +reboot kernel/system/system.c /^void reboot()$/;" f +register_interrupt_handler kernel/arch/i386/handlers.c /^void register_interrupt_handler(uint8_t n, isr_t handler)$/;" f +registers kernel/include/system.h /^typedef struct registers$/;" s +registers sysroot/usr/include/system.h /^typedef struct registers$/;" s +registers_t kernel/include/system.h /^} registers_t; \/\/ registers for interrupts$/;" t typeref:struct:registers +registers_t sysroot/usr/include/system.h /^} registers_t; \/\/ registers for interrupts$/;" t typeref:struct:registers +regs kernel/include/task.h /^ t_regs_t regs;$/;" m struct:task +regs sysroot/usr/include/task.h /^ t_regs_t regs;$/;" m struct:task +remove_list libc/phapi/list.c /^void remove_list(uint32_t i, list_t *array)$/;" f +row kernel/drivers/vga.c /^size_t row;$/;" v +seconds kernel/include/time.h /^int seconds;$/;" v +seconds sysroot/usr/include/time.h /^int seconds;$/;" v +section kernel/arch/i386/boot/boot.asm /^section .bootstrap_stack$/;" l +section kernel/arch/i386/boot/boot.asm /^section .multiboot$/;" l +section kernel/arch/i386/boot/boot.asm /^section .text$/;" l +sel kernel/arch/i386/include/idt.h /^ uint16_t sel; $/;" m struct:idt_entry_struct +sel sysroot/usr/include/idt.h /^ uint16_t sel; $/;" m struct:idt_entry_struct +setID kernel/init/kernel_class.cpp /^void KernelClass::setID(const int ID)$/;" f class:KernelClass +setVersion kernel/init/kernel_class.cpp /^void KernelClass::setVersion(const char *version)$/;" f class:KernelClass +set_kernel_stack kernel/arch/i386/gdt.c /^void set_kernel_stack(uint32_t stack)$/;" f +shell kernel/system/system.c /^void shell(char *str) {$/;" f +shift kernel/include/keyboard.h /^int shift;$/;" v +shift sysroot/usr/include/keyboard.h /^int shift;$/;" v +shndx kernel/include/multiboot.h /^ uint32_t shndx;$/;" m struct:multiboot +shndx sysroot/usr/include/multiboot.h /^ uint32_t shndx;$/;" m struct:multiboot +size kernel/include/multiboot.h /^ uint32_t size;$/;" m struct:multiboot +size libc/include/list.h /^ uint32_t size;$/;" m struct:__anon1 +size sysroot/usr/include/list.h /^ uint32_t size;$/;" m struct:__anon2 +size sysroot/usr/include/multiboot.h /^ uint32_t size;$/;" m struct:multiboot +ss kernel/arch/i386/include/gdt.h /^ uint32_t ss; \/\/ The value to load into SS when we change to kernel mode.$/;" m struct:tss_entry_struct +ss kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +ss sysroot/usr/include/gdt.h /^ uint32_t ss; \/\/ The value to load into SS when we change to kernel mode.$/;" m struct:tss_entry_struct +ss sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +ss0 kernel/arch/i386/include/gdt.h /^ uint32_t ss0; \/\/ The stack segment to load when we change to kernel mode.$/;" m struct:tss_entry_struct +ss0 sysroot/usr/include/gdt.h /^ uint32_t ss0; \/\/ The stack segment to load when we change to kernel mode.$/;" m struct:tss_entry_struct +ss1 kernel/arch/i386/include/gdt.h /^ uint32_t ss1;$/;" m struct:tss_entry_struct +ss1 sysroot/usr/include/gdt.h /^ uint32_t ss1;$/;" m struct:tss_entry_struct +ss2 kernel/arch/i386/include/gdt.h /^ uint32_t ss2;$/;" m struct:tss_entry_struct +ss2 sysroot/usr/include/gdt.h /^ uint32_t ss2;$/;" m struct:tss_entry_struct +stack_bottom kernel/arch/i386/boot/boot.asm /^stack_bottom:$/;" l +stack_top kernel/arch/i386/boot/boot.asm /^stack_top:$/;" l +start_task kernel/include/task.h /^task_t *start_task;$/;" v +start_task sysroot/usr/include/task.h /^task_t *start_task;$/;" v +std_lessthan_pred libc/phapi/list.c /^int8_t std_lessthan_pred(type_t a, type_t b)$/;" f +stdin libc/include/stdio.h /^void* stdin;$/;" v +stdin sysroot/usr/include/stdio.h /^void* stdin;$/;" v +stdout libc/include/stdio.h /^void* stdout;$/;" v +stdout sysroot/usr/include/stdio.h /^void* stdout;$/;" v +sti kernel/include/system.h 14;" d +sti sysroot/usr/include/system.h 14;" d +strcmp libc/string/strcmp.c /^int strcmp(const char *s1, const char *s2)$/;" f +strlen libc/string/strlen.c /^size_t strlen(const char* string)$/;" f +strrev libc/string/strrev.c /^char *strrev(char *str)$/;" f +switch_task kernel/system/task.c /^void switch_task()$/;" f +syscall_handler kernel/system/task.c /^void syscall_handler(registers_t *regs)$/;" f +syscalls kernel/system/task.c /^void *syscalls[] = {$/;" v +t_regs kernel/include/system.h /^typedef struct t_regs {$/;" s +t_regs sysroot/usr/include/system.h /^typedef struct t_regs {$/;" s +t_regs_t kernel/include/system.h /^} t_regs_t; \/\/ task registers$/;" t typeref:struct:t_regs +t_regs_t sysroot/usr/include/system.h /^} t_regs_t; \/\/ task registers$/;" t typeref:struct:t_regs +tabstop kernel/drivers/vga.c /^int tabstop;$/;" v +task kernel/include/task.h /^typedef struct task {$/;" s +task sysroot/usr/include/task.h /^typedef struct task {$/;" s +task_t kernel/include/task.h /^} task_t;$/;" t typeref:struct:task +task_t sysroot/usr/include/task.h /^} task_t;$/;" t typeref:struct:task +testing_shell kernel/system/system.c /^static void testing_shell(char *str) $/;" f file: +tick kernel/arch/i386/pit.c /^int tick;$/;" v +timer_callback kernel/arch/i386/pit.c /^void timer_callback(__attribute__ ((unused)) registers_t *regs)$/;" f +trap kernel/arch/i386/include/gdt.h /^ uint16_t trap;$/;" m struct:tss_entry_struct +trap sysroot/usr/include/gdt.h /^ uint16_t trap;$/;" m struct:tss_entry_struct +tss_entry kernel/arch/i386/include/gdt.h /^tss_entry_t tss_entry;$/;" v +tss_entry sysroot/usr/include/gdt.h /^tss_entry_t tss_entry;$/;" v +tss_entry_struct kernel/arch/i386/include/gdt.h /^struct tss_entry_struct$/;" s +tss_entry_struct sysroot/usr/include/gdt.h /^struct tss_entry_struct$/;" s +tss_entry_t kernel/arch/i386/include/gdt.h /^typedef struct tss_entry_struct tss_entry_t; $/;" t typeref:struct:tss_entry_struct +tss_entry_t sysroot/usr/include/gdt.h /^typedef struct tss_entry_struct tss_entry_t; $/;" t typeref:struct:tss_entry_struct +tss_flush kernel/arch/i386/descriptor_tables.asm /^tss_flush:$/;" l +type_t kernel/include/system.h /^typedef void* type_t;$/;" t +type_t sysroot/usr/include/system.h /^typedef void* type_t;$/;" t +uarch_t kernel/include/icxxabi.h /^typedef unsigned uarch_t;$/;" t +uarch_t sysroot/usr/include/icxxabi.h /^typedef unsigned uarch_t;$/;" t +unhandled_interrupt kernel/arch/i386/idt.c /^static void unhandled_interrupt(__attribute__((unused)) registers_t *regs)$/;" f file: +update_time kernel/system/time.c /^void update_time()$/;" f +use_frame kernel/arch/i386/pmm.c /^void use_frame(uint32_t addr)$/;" f +user kernel/system/system.c /^char user[20];$/;" v +useresp kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +useresp sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers +vbe_control_info kernel/include/multiboot.h /^ uint32_t vbe_control_info;$/;" m struct:multiboot +vbe_control_info sysroot/usr/include/multiboot.h /^ uint32_t vbe_control_info;$/;" m struct:multiboot +vbe_interface_len kernel/include/multiboot.h /^ uint32_t vbe_interface_len;$/;" m struct:multiboot +vbe_interface_len sysroot/usr/include/multiboot.h /^ uint32_t vbe_interface_len;$/;" m struct:multiboot +vbe_interface_off kernel/include/multiboot.h /^ uint32_t vbe_interface_off;$/;" m struct:multiboot +vbe_interface_off sysroot/usr/include/multiboot.h /^ uint32_t vbe_interface_off;$/;" m struct:multiboot +vbe_interface_seg kernel/include/multiboot.h /^ uint32_t vbe_interface_seg;$/;" m struct:multiboot +vbe_interface_seg sysroot/usr/include/multiboot.h /^ uint32_t vbe_interface_seg;$/;" m struct:multiboot +vbe_mode kernel/include/multiboot.h /^ uint32_t vbe_mode;$/;" m struct:multiboot +vbe_mode sysroot/usr/include/multiboot.h /^ uint32_t vbe_mode;$/;" m struct:multiboot +vbe_mode_info kernel/include/multiboot.h /^ uint32_t vbe_mode_info;$/;" m struct:multiboot +vbe_mode_info sysroot/usr/include/multiboot.h /^ uint32_t vbe_mode_info;$/;" m struct:multiboot +version kernel/include/kernel_class.h /^ char version[30];$/;" m class:KernelClass +version sysroot/usr/include/kernel_class.h /^ char version[30];$/;" m class:KernelClass +version_name kernel/include/kernel_class.h /^ char version_name[50];$/;" m class:KernelClass +version_name sysroot/usr/include/kernel_class.h /^ char version_name[50];$/;" m class:KernelClass +vga_color kernel/include/vga.h /^enum vga_color$/;" g +vga_color sysroot/usr/include/vga.h /^enum vga_color$/;" g +vga_memory kernel/drivers/vga.c /^uint16_t *vga_memory;$/;" v +vga_move_cursor kernel/drivers/vga.c /^void vga_move_cursor(int row, int column)$/;" f +vga_putchar kernel/drivers/vga.c /^void vga_putchar(char c)$/;" f +vga_putchar_color kernel/drivers/vga.c /^void vga_putchar_color(char c, enum vga_color fg)$/;" f +vga_putentryat kernel/drivers/vga.c /^void vga_putentryat(char c, uint8_t color, size_t x, size_t y)$/;" f +vga_scroll kernel/drivers/vga.c /^int vga_scroll(size_t *row)$/;" f +vga_set_tab kernel/drivers/vga.c /^void vga_set_tab(int size)$/;" f +vga_setcolor kernel/drivers/vga.c /^void vga_setcolor(enum vga_color fg, enum vga_color bg)$/;" f +vga_writestring kernel/drivers/vga.c /^void vga_writestring(const char* data)$/;" f +welcome kernel/init/init.c /^void welcome() {$/;" f +write kernel/drivers/io.c /^int write(const char *buf, size_t len)$/;" f +write_char kernel/drivers/io.c /^int write_char(const char c)$/;" f +write_cr0 kernel/arch/i386/page.asm /^write_cr0:$/;" l +write_cr3 kernel/arch/i386/page.asm /^write_cr3:$/;" l +write_tss kernel/arch/i386/gdt.c /^void write_tss(int32_t num, uint16_t ss0, uint32_t esp0)$/;" f +wstr_color kernel/drivers/vga.c /^void wstr_color(const char* data, enum vga_color fg)$/;" f +zero_division_handler kernel/arch/i386/handlers.c /^static void zero_division_handler(__attribute__((unused)) registers_t *regs)$/;" f file: +~KernelClass kernel/init/kernel_class.cpp /^KernelClass::~KernelClass()$/;" f class:KernelClass From 023ca79c321c4b11b30b5d0e075391755ba190c5 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Sat, 12 Sep 2015 17:34:08 +0300 Subject: [PATCH 13/17] Fixed paging and enabled A20. --- kernel/Makefile | 2 +- kernel/arch/i386/a20.asm | 48 +++++++++++ kernel/arch/i386/include/pmm.h | 9 +- kernel/arch/i386/include/vmm.h | 32 ++++--- kernel/arch/i386/make.config | 1 + kernel/arch/i386/pmm.c | 53 +++++++----- kernel/arch/i386/vmm.c | 149 ++++++++++----------------------- kernel/drivers/io.c | 2 +- kernel/init/init.c | 25 ++++-- kernel/system/kheap.c | 8 +- kernel/system/system.c | 2 +- libc/Makefile | 1 + libc/include/bitmap.h | 13 +++ libc/phapi/bitmap.c | 17 ++++ 14 files changed, 201 insertions(+), 161 deletions(-) create mode 100644 kernel/arch/i386/a20.asm create mode 100644 libc/include/bitmap.h create mode 100644 libc/phapi/bitmap.c diff --git a/kernel/Makefile b/kernel/Makefile index 17cb1f2..da399c2 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -13,7 +13,7 @@ BOOTDIR?=$(EXEC_PREFIX)/boot INCLUDEDIR?=$(PREFIX)/include CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra -CPPFLAGS:=$(CPPFLAGS) -D__is_photon_kernel -D_TEXTMODE -Iinclude -Iarch/i386/include -I../libc/include +CPPFLAGS:=$(CPPFLAGS) -DBITMAP_FRAME_ALLOCATOR -D__is_photon_kernel -D_TEXTMODE -Iinclude -Iarch/i386/include -I../libc/include LDFLAGS:=$(LDFLAGS) LIBS:=$(LIBS) -nostdlib -lk -lgcc diff --git a/kernel/arch/i386/a20.asm b/kernel/arch/i386/a20.asm new file mode 100644 index 0000000..3a80b9e --- /dev/null +++ b/kernel/arch/i386/a20.asm @@ -0,0 +1,48 @@ +[bits 32] +[section .text] + +[global enable_A20] +enable_A20: + cli + + call a20wait + mov al,0xAD + out 0x64,al + + call a20wait + mov al,0xD0 + out 0x64,al + + call a20wait2 + in al,0x60 + push eax + + call a20wait + mov al,0xD1 + out 0x64,al + + call a20wait + pop eax + or al,2 + out 0x60,al + + call a20wait + mov al,0xAE + out 0x64,al + + call a20wait + sti + ret + +a20wait: + in al,0x64 + test al,2 + jnz a20wait + ret + + +a20wait2: + in al,0x64 + test al,1 + jz a20wait2 + ret diff --git a/kernel/arch/i386/include/pmm.h b/kernel/arch/i386/include/pmm.h index 5ff8904..5cead1a 100644 --- a/kernel/arch/i386/include/pmm.h +++ b/kernel/arch/i386/include/pmm.h @@ -23,14 +23,13 @@ #include #include -#define FRAME_SIZE 0x20 -#define FRAME_INDEX(x) (x / FRAME_SIZE) +#define FRAME_SIZE 0x1000 #define PAGE_ALIGN(x) (x & 0xFFFFF000) -#define FRAME_ADDR_FROM_INDEX(x) (x * FRAME_SIZE) void init_pmm(uint32_t mem_size); uint32_t find_frame(); -void use_frame(uint32_t frame); -void free_frame(uint32_t frame); +uint32_t alloc_frame(); +void free_frame(uint32_t address); #endif + diff --git a/kernel/arch/i386/include/vmm.h b/kernel/arch/i386/include/vmm.h index 4757e54..45e4d46 100644 --- a/kernel/arch/i386/include/vmm.h +++ b/kernel/arch/i386/include/vmm.h @@ -5,33 +5,29 @@ #include #include -typedef struct page { - uint32_t present : 1; - uint32_t rw : 1; - uint32_t us : 1; - uint32_t accessed : 1; - uint32_t dirty : 1; - uint32_t unused : 7; - uint32_t frame : 20; -} page_t; +#define PAGE_PRESENT 0x1 +#define PAGE_READ_WRITE 0x2 +#define PAGE_USER 0x4 +#define PAGE_WRITE_THROUGH 0x8 +#define PAGE_CACHE_DISABLE 0x16 +#define PAGE_ACCESSED 0x32 +#define PAGE_DIRTY 0x64 +#define PAGE_GLOBAL 0x128 typedef struct page_table { - page_t pages[1024]; -} page_table_t __attribute__((aligned(4096))); + uint32_t pages[1024]; +} page_table_t; typedef struct page_directory { - page_table_t *tables[1024]; uint32_t phys_tables[1024]; -} page_directory_t __attribute__((aligned(4096))); + page_table_t *virt_tables[1024]; +} page_directory_t; -void init_vmm(uint32_t mem_size); +void init_vmm(); void switch_page_directory(page_directory_t *dir); void enable_paging(); -void map(uint32_t va, uint32_t pa, uint32_t rw, uint32_t us); +void map(uint32_t va, uint32_t pa, uint32_t flags); void unmap(uint32_t va); -void create_page(page_t *page, uint32_t frame, uint32_t rw, uint32_t us); -page_t *get_page(uint32_t address, page_directory_t *dir); -void debug_mem_mngr(); void page_fault_handler(registers_t *regs); #endif diff --git a/kernel/arch/i386/make.config b/kernel/arch/i386/make.config index a8b44c9..6abb644 100644 --- a/kernel/arch/i386/make.config +++ b/kernel/arch/i386/make.config @@ -15,3 +15,4 @@ $(ARCHDIR)/pmm.o \ $(ARCHDIR)/vmm.o \ $(ARCHDIR)/pit.o \ $(ARCHDIR)/pic.o \ +$(ARCHDIR)/a20.o \ diff --git a/kernel/arch/i386/pmm.c b/kernel/arch/i386/pmm.c index b6d01a0..00362d9 100644 --- a/kernel/arch/i386/pmm.c +++ b/kernel/arch/i386/pmm.c @@ -15,42 +15,55 @@ #include #include -uint32_t nframes; -uint32_t *frames; uint32_t placement_addr = (uint32_t) &kernel_end; int paging_enabled = 0; +#ifdef BITMAP_FRAME_ALLOCATOR + +#include + +uint32_t nframes; +uint32_t *frames; + void init_pmm(uint32_t mem_size) { nframes = (mem_size * 1024) / FRAME_SIZE; - frames = kmalloc(sizeof(uint32_t) * nframes, 0, 0); + frames = kmalloc(sizeof(uint32_t) * nframes / 8 + + sizeof(uint32_t) * nframes % 8, + 0, + 0); + for (uint32_t i = 0; i < nframes; i++) { - free_frame(FRAME_ADDR_FROM_INDEX(i)); + free_bit(frames, i); } - printk("Number of frames: %d and memory size: %d\n", nframes, mem_size / 1024); } uint32_t find_frame() { - for (uint32_t i = 0; i < nframes; i++) { - if (!frames[i]) { - uint32_t frame_addr = FRAME_ADDR_FROM_INDEX(i); - use_frame(frame_addr); - return frame_addr; - } - } - printk("[ERROR] No free frames!"); - keep_running(); + for (uint32_t i = 0; i < nframes; i++) { + if (test_bit(frames, i)) { + return i; + } + } + return -1; } -void use_frame(uint32_t addr) +uint32_t alloc_frame() { - int frame_index = FRAME_INDEX(addr); - frames[frame_index] = 1; + int frame_index = find_frame(); + if (frame_index != -1) { + use_bit(frames, frame_index); + return frame_index * FRAME_SIZE; + } + + panic("No free frames!", __LINE__, __FILE__); + return -1; } -void free_frame(uint32_t addr) +void free_frame(uint32_t address) { - int frame_index = FRAME_INDEX(addr); - frames[frame_index] = 0; + uint32_t frame_index = address / FRAME_SIZE; + free_bit(frames, frame_index); } + +#endif diff --git a/kernel/arch/i386/vmm.c b/kernel/arch/i386/vmm.c index b7a318c..7129865 100644 --- a/kernel/arch/i386/vmm.c +++ b/kernel/arch/i386/vmm.c @@ -14,43 +14,47 @@ extern uint32_t read_cr0(); extern uint32_t *frames; extern uint32_t nframes; extern int paging_enabled; +extern uint32_t placement_addr; +extern size_t kernel_end; page_directory_t *kernel_directory; page_directory_t *current_directory; -void init_vmm(uint32_t mem_size) +static void map_area(uint32_t from_va, uint32_t to_va) { - // Register interrupt handler - register_interrupt_handler(14, &page_fault_handler); + for (uint32_t va = from_va; va < to_va; va += 0x1000) { + uint32_t pa = alloc_frame(); + map(va, pa, PAGE_READ_WRITE | PAGE_PRESENT); + } +} + +void init_vmm() +{ + register_interrupt_handler(14, page_fault_handler); - // Alloc space for kernel directory kernel_directory = kmalloc(sizeof(page_directory_t), 1, 0); - - // Empty it memset(kernel_directory, 0, sizeof(page_directory_t)); - - // Set current directory to kernel diretory - current_directory = kernel_directory; - - // Map the memory - uint32_t mem_addr = 0x0; - uint32_t frame_addr = 0x0; - while (mem_addr < (size_t) &kernel_end + 0x10000) { - frame_addr = find_frame(); - map(mem_addr, frame_addr, 1, 1); - mem_addr += 32; + + for (int i = 0; i < 1024; i++) { + kernel_directory->phys_tables[i] = 0x0 | PAGE_READ_WRITE; } - // Switch current directory + + current_directory = kernel_directory; + + // Map BIOS + map_area(0x0, 0x10000); + + // Map Kernel + map_area(0x10000, (uint32_t) &kernel_end); + switch_page_directory(kernel_directory); - - // Enable paging enable_paging(); } void switch_page_directory(page_directory_t *dir) { current_directory = dir; - write_cr3((uint32_t) &(dir->phys_tables)); + write_cr3(current_directory); } void enable_paging() @@ -59,98 +63,35 @@ void enable_paging() cr0 |= 0x80000000; write_cr0(cr0); paging_enabled = 1; + + // Temp settings + placement_addr = 0x20000; } -void map(uint32_t va, uint32_t pa, uint32_t rw, uint32_t us) +void map(uint32_t va, uint32_t pa, uint32_t flags) { - page_t *page = get_page(va, current_directory); - create_page(page, pa, rw, us); + uint32_t page_num = (va / 4096) % 1024; + uint32_t table_num = (va / 4096) / 1024; + + if (!current_directory->virt_tables[table_num]) { + uint32_t phys; + current_directory->virt_tables[table_num] = kmalloc(sizeof(page_table_t), + 1, + &phys); + + current_directory->phys_tables[table_num] = phys | PAGE_READ_WRITE | PAGE_PRESENT; + } + current_directory->virt_tables[table_num]->pages[page_num] = pa | flags; } void unmap(uint32_t va) { - page_t *page = get_page(va, current_directory); - free_frame(page->frame); - memset(page, 0, sizeof(page_t)); - asm volatile ("invlpg (%0)" : : "a" (va)); -} - -void create_page(page_t *page, uint32_t frame, uint32_t rw, uint32_t us) -{ - page->present = 1; - page->rw = rw; - page->us = us; - page->frame = frame; -} - -page_t *get_page(uint32_t address, page_directory_t *dir) -{ - int page_index = address / 0x1000; - int table_index = page_index / 1024; - - if (dir->tables[table_index] != 0) { - return &(dir->tables[table_index]->pages[page_index]); - } else { - uint32_t phys_table_addr; - dir->tables[table_index] = kmalloc(sizeof(page_table_t), - 1, &phys_table_addr); - memset((void*) dir->tables[table_index], 0, sizeof(page_table_t)); - dir->phys_tables[table_index] = phys_table_addr | 0x7; - return &(dir->tables[table_index]->pages[page_index]); - } - return NULL; -} - - -void debug_mem_mngr() -{ - printk("[DEBUG] Testing memory manager...\n"); - printk("page %d page_table %d page_directory %d\n", sizeof(page_t), sizeof(page_table_t), sizeof(page_directory_t)); - printk("Frame allocator test:\n"); - uint32_t addr_a = find_frame(); - uint32_t addr_b = find_frame(); - - int index_a = FRAME_INDEX(addr_a); - int index_b = FRAME_INDEX(addr_b); - - printk("Frame A: %x, index: %d, used: %d\n", addr_a, index_a, frames[index_a]); - printk("Frame B: %x, index: %d, used: %d\n", addr_b, index_b, frames[index_b]); - - free_frame(addr_a); - - printk("After free, value of frame A: %d\n", frames[index_a]); - - uint32_t addr_c = find_frame(); - uint32_t addr_d = find_frame(); - - int index_c = FRAME_INDEX(addr_c); - int index_d = FRAME_INDEX(addr_d); - - printk("Frame C: %x, index: %d, used: %d\n", addr_c, index_c, frames[index_c]); - printk("Frame D: %x, index: %d, used: %d\n", addr_d, index_d, frames[index_d]); - - if (index_c != index_a || addr_c != addr_a) { - panic("[ERROR] Page frame allocator crash.\n", __LINE__, __FILE__); - } else { - printk("[INFO] Page frame allocator works fine.\n"); - } + uint32_t page_num = (va / 4096) % 1024; + uint32_t table_num = (va / 4096) / 1024; - free_frame(addr_a); - free_frame(addr_b); - free_frame(addr_c); - free_frame(addr_d); + current_directory->virt_tables[table_num]->pages[page_num] = 0x0; - printk("[INFO] Testing page directory.\n"); - if (current_directory->tables[0]->pages[0].frame != 0x0) { - panic("[ERROR] Map function error.", __LINE__, __FILE__); - } else { - printk("[INFO] All is good.\n"); - page_t *page3 = &(current_directory->tables[0]->pages[2]); - printk("Page 3: frame: %x present: %x rw: %x us: %x\n", page3->frame, page3->present, page3->rw, page3->us); - } - - void *error = kmalloc(sizeof(int), 0, 0); - printk("%d", (uint32_t*) error); + asm volatile ("invlpg (%0)" : : "a" (va)); } void page_fault_handler(registers_t *regs) diff --git a/kernel/drivers/io.c b/kernel/drivers/io.c index 27adbe9..4cef756 100644 --- a/kernel/drivers/io.c +++ b/kernel/drivers/io.c @@ -69,7 +69,7 @@ int write_char(const char c) { //((unsigned char*) stdout)[out_crs] = c; //out_crs++; - vga_putchar(c); + vga_putchar(c); // temp return 0; } diff --git a/kernel/init/init.c b/kernel/init/init.c index ae1222b..b170add 100644 --- a/kernel/init/init.c +++ b/kernel/init/init.c @@ -30,10 +30,20 @@ #include #include +extern void enable_A20(); + +extern uint32_t nframes; + extern int detect_cpu(void); #define FREQ 100 +static uint32_t get_total_memory() +{ + // return memory in MiB + return nframes * FRAME_SIZE / 1024 / 1024; +} + void init_stdio() { inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE, 0, 0); outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE, 0, 0); @@ -93,16 +103,17 @@ void init(multiboot *mboot_ptr, uint32_t init_stack) { install_keyboard(); wstr_color("[OK]\n", COLOR_GREEN); + printk("Enable A20. "); + enable_A20(); + wstr_color("[OK]\n", COLOR_GREEN); + printk("Initialize PMM and VMM. "); init_pmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); - init_vmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); + init_vmm(); wstr_color("[OK]\n", COLOR_GREEN); - debug_mem_mngr(); - - printk("Memory info:\n"); - printk("\tKernel starts at: %x\n", (size_t)&kernel_start); - printk("\tKernel ends at: %x\n", (size_t)&kernel_end); - //printk("\tRAM: %d MB\n", mem_size_mb); + + printk("Total system memory: %d MiB in %d frames.\n", get_total_memory(), + nframes); printk("Initialize stdio (allow using of stdio header). "); init_stdio(); diff --git a/kernel/system/kheap.c b/kernel/system/kheap.c index aeece51..cc9a2c3 100644 --- a/kernel/system/kheap.c +++ b/kernel/system/kheap.c @@ -26,9 +26,9 @@ void init_heap () void *kmalloc(size_t size, int align, uint32_t *phys) { - if (paging_enabled) { - panic("kmalloc isn't ready to work with paging.\n", __LINE__, __FILE__); - } else { + //if (paging_enabled) { + + //} else { if (align && (placement_addr & 0xFFFFF000)) { placement_addr &= 0xFFFFF000; placement_addr += 0x1000; @@ -41,7 +41,7 @@ void *kmalloc(size_t size, int align, uint32_t *phys) placement_addr += size; void *ret_p = (void*) ret_addr; return ret_p; - } + //} return NULL; } diff --git a/kernel/system/system.c b/kernel/system/system.c index b41e1cd..6891cfc 100644 --- a/kernel/system/system.c +++ b/kernel/system/system.c @@ -173,7 +173,7 @@ void shell(char *str) { kfree(i); } else if (!strcmp(str, "usermode")) { printk("CPU will jump to usermode, this will stop shell, because it is running only in kernel mode.\n"); - //init_usermode(); + init_usermode(); char s[] = "Welcome in usermode!\n"; call(1, (uint32_t) s, (uint32_t) strlen(s), 0, 0, 0); } else if (!strcmp(str, "sys-info")) { diff --git a/libc/Makefile b/libc/Makefile index e065b14..d700418 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -47,6 +47,7 @@ string/strcmp.o \ string/strlen.o \ string/strrev.o \ phapi/list.o \ +phapi/bitmap.o \ HOSTEDOBJS:=\ $(ARCH_HOSTEDOBJS) \ diff --git a/libc/include/bitmap.h b/libc/include/bitmap.h new file mode 100644 index 0000000..01cad09 --- /dev/null +++ b/libc/include/bitmap.h @@ -0,0 +1,13 @@ +#ifndef _bitmap_h +#define _bitmap_h + +#include + +#define BIT_INDEX(x) (x / 0x20) +#define BIT_OFFSET(x) (x % 0x20) + +void use_bit(uint32_t *bitmap, uint32_t bit); +void free_bit(uint32_t *bitmap, uint32_t bit); +uint32_t test_bit(uint32_t *bitmap, uint32_t bit); + +#endif diff --git a/libc/phapi/bitmap.c b/libc/phapi/bitmap.c new file mode 100644 index 0000000..b726e77 --- /dev/null +++ b/libc/phapi/bitmap.c @@ -0,0 +1,17 @@ +#include +#include + +void use_bit(uint32_t *bitmap, uint32_t bit) +{ + bitmap[BIT_INDEX(bit)] |= (0x1 << BIT_OFFSET(bit)); +} + +void free_bit(uint32_t *bitmap, uint32_t bit) +{ + bitmap[BIT_INDEX(bit)] &= ~(0x1 << BIT_OFFSET(bit)); +} + +uint32_t test_bit(uint32_t *bitmap, uint32_t bit) +{ + return !(bitmap[BIT_INDEX(bit)] & (0x1 << BIT_OFFSET(bit))); +} From ebf381cc36128378f1786fa2ad5c80a1f8a27ea2 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Mon, 28 Sep 2015 15:19:07 +0300 Subject: [PATCH 14/17] Redesign the kernel and implement a kernel heap. --- : | 179 ---- all | 5 - kernel/include/init.h | 46 - kernel/include/kheap.h | 26 - kernel/init/init.c | 189 ---- kernel/init/main.cpp | 63 -- kernel/system/kheap.c | 51 - libc/stdio/putchar.c | 8 - serial.log | 0 all.sh => src/all.sh | 0 build.sh => src/build.sh | 0 clean.sh => src/clean.sh | 0 config.sh => src/config.sh | 0 default-host.sh => src/default-host.sh | 0 headers.sh => src/headers.sh | 0 iso.sh => src/iso.sh | 0 {kernel => src/kernel}/Makefile | 3 +- {kernel => src/kernel}/arch/i386/a20.asm | 0 .../kernel}/arch/i386/boot/boot.asm | 15 +- {kernel => src/kernel}/arch/i386/crti.S | 0 {kernel => src/kernel}/arch/i386/crtn.S | 0 .../kernel}/arch/i386/descriptor_tables.asm | 0 {kernel => src/kernel}/arch/i386/gdt.c | 15 +- {kernel => src/kernel}/arch/i386/handlers.c | 11 +- {kernel => src/kernel}/arch/i386/idt.c | 13 +- .../kernel}/arch/i386/include/gdt.h | 12 +- .../kernel}/arch/i386/include/handlers.h | 8 +- .../kernel}/arch/i386/include/idt.h | 10 +- .../kernel}/arch/i386/include/pic.h | 0 .../kernel}/arch/i386/include/pit.h | 8 +- .../kernel}/arch/i386/include/pmm.h | 7 +- .../kernel}/arch/i386/include/vmm.h | 6 +- .../kernel}/arch/i386/interrupt.asm | 0 {kernel => src/kernel}/arch/i386/linker.ld | 0 {kernel => src/kernel}/arch/i386/make.config | 0 {kernel => src/kernel}/arch/i386/page.asm | 0 {kernel => src/kernel}/arch/i386/pic.c | 8 +- {kernel => src/kernel}/arch/i386/pit.c | 20 +- {kernel => src/kernel}/arch/i386/pmm.c | 14 +- {kernel => src/kernel}/arch/i386/vmm.c | 32 +- {kernel => src/kernel}/drivers/io.c | 11 +- {kernel => src/kernel}/drivers/keyboard.c | 34 +- {kernel => src/kernel}/drivers/vga.c | 23 +- src/kernel/include/heap.h | 43 + {kernel => src/kernel}/include/icxxabi.h | 0 {kernel => src/kernel}/include/io.h | 10 +- {kernel => src/kernel}/include/kernel_class.h | 0 {kernel => src/kernel}/include/keyboard.h | 16 +- {kernel => src/kernel}/include/multiboot.h | 0 {kernel => src/kernel}/include/system.h | 70 +- {kernel => src/kernel}/include/task.h | 10 +- {kernel => src/kernel}/include/time.h | 9 +- {kernel => src/kernel}/include/vga.h | 12 +- {kernel => src/kernel}/init/icxxabi.cpp | 0 {kernel => src/kernel}/init/kernel_class.cpp | 0 src/kernel/init/main.cpp | 148 +++ {kernel => src/kernel}/system/cpu.c | 0 src/kernel/system/heap.c | 214 ++++ {kernel => src/kernel}/system/system.c | 79 +- {kernel => src/kernel}/system/task.c | 12 +- {kernel => src/kernel}/system/time.c | 12 +- {libc => src/libc}/Makefile | 3 + {libc => src/libc}/arch/i386/crt0.S | 0 {libc => src/libc}/arch/i386/crti.S | 0 {libc => src/libc}/arch/i386/crtn.S | 0 {libc => src/libc}/arch/i386/make.config | 0 {libc => src/libc}/include/bitmap.h | 17 +- src/libc/include/linked_list.h | 24 + {libc => src/libc}/include/list.h | 7 +- {libc => src/libc}/include/phapi.h | 7 + {libc => src/libc}/include/stdio.h | 15 +- {libc => src/libc}/include/stdlib.h | 20 +- {libc => src/libc}/include/string.h | 9 +- {libc => src/libc}/include/sys/cdefs.h | 0 {libc => src/libc}/phapi/bitmap.c | 7 +- src/libc/phapi/linked_list.c | 85 ++ {libc => src/libc}/phapi/list.c | 11 +- {libc => src/libc}/stdio/getch.c | 12 +- {libc => src/libc}/stdio/getchar.c | 5 +- {libc => src/libc}/stdio/gets.c | 4 + {libc => src/libc}/stdio/printf.c | 9 +- src/libc/stdio/putchar.c | 10 + {libc => src/libc}/stdio/puts.c | 4 + {libc => src/libc}/stdlib/abort.c | 6 +- {libc => src/libc}/stdlib/atoi.c | 6 +- {libc => src/libc}/stdlib/exit.c | 7 +- src/libc/stdlib/free.c | 13 + {libc => src/libc}/stdlib/intlen.c | 6 +- {libc => src/libc}/stdlib/itoa.c | 5 +- src/libc/stdlib/malloc.c | 31 + {libc => src/libc}/string/memcmp.c | 4 + {libc => src/libc}/string/memcpy.c | 4 + {libc => src/libc}/string/memmove.c | 4 + {libc => src/libc}/string/memset.c | 4 + {libc => src/libc}/string/memsetw.c | 4 + {libc => src/libc}/string/strcmp.c | 4 + {libc => src/libc}/string/strlen.c | 4 + {libc => src/libc}/string/strrev.c | 0 .../target-triplet-to-arch.sh | 0 tags | 914 ------------------ 100 files changed, 991 insertions(+), 1726 deletions(-) delete mode 100644 : delete mode 100755 all delete mode 100644 kernel/include/init.h delete mode 100644 kernel/include/kheap.h delete mode 100644 kernel/init/init.c delete mode 100644 kernel/init/main.cpp delete mode 100644 kernel/system/kheap.c delete mode 100644 libc/stdio/putchar.c delete mode 100644 serial.log rename all.sh => src/all.sh (100%) rename build.sh => src/build.sh (100%) rename clean.sh => src/clean.sh (100%) rename config.sh => src/config.sh (100%) rename default-host.sh => src/default-host.sh (100%) rename headers.sh => src/headers.sh (100%) rename iso.sh => src/iso.sh (100%) rename {kernel => src/kernel}/Makefile (98%) rename {kernel => src/kernel}/arch/i386/a20.asm (100%) rename {kernel => src/kernel}/arch/i386/boot/boot.asm (87%) rename {kernel => src/kernel}/arch/i386/crti.S (100%) rename {kernel => src/kernel}/arch/i386/crtn.S (100%) rename {kernel => src/kernel}/arch/i386/descriptor_tables.asm (100%) rename {kernel => src/kernel}/arch/i386/gdt.c (91%) rename {kernel => src/kernel}/arch/i386/handlers.c (97%) rename {kernel => src/kernel}/arch/i386/idt.c (92%) rename {kernel => src/kernel}/arch/i386/include/gdt.h (96%) rename {kernel => src/kernel}/arch/i386/include/handlers.h (97%) rename {kernel => src/kernel}/arch/i386/include/idt.h (93%) rename {kernel => src/kernel}/arch/i386/include/pic.h (100%) rename {kernel => src/kernel}/arch/i386/include/pit.h (91%) rename {kernel => src/kernel}/arch/i386/include/pmm.h (91%) rename {kernel => src/kernel}/arch/i386/include/vmm.h (89%) rename {kernel => src/kernel}/arch/i386/interrupt.asm (100%) rename {kernel => src/kernel}/arch/i386/linker.ld (100%) rename {kernel => src/kernel}/arch/i386/make.config (100%) rename {kernel => src/kernel}/arch/i386/page.asm (100%) rename {kernel => src/kernel}/arch/i386/pic.c (84%) rename {kernel => src/kernel}/arch/i386/pit.c (86%) rename {kernel => src/kernel}/arch/i386/pmm.c (90%) rename {kernel => src/kernel}/arch/i386/vmm.c (81%) rename {kernel => src/kernel}/drivers/io.c (96%) rename {kernel => src/kernel}/drivers/keyboard.c (86%) rename {kernel => src/kernel}/drivers/vga.c (90%) create mode 100644 src/kernel/include/heap.h rename {kernel => src/kernel}/include/icxxabi.h (100%) rename {kernel => src/kernel}/include/io.h (82%) rename {kernel => src/kernel}/include/kernel_class.h (100%) rename {kernel => src/kernel}/include/keyboard.h (87%) rename {kernel => src/kernel}/include/multiboot.h (100%) rename {kernel => src/kernel}/include/system.h (62%) rename {kernel => src/kernel}/include/task.h (85%) rename {kernel => src/kernel}/include/time.h (75%) rename {kernel => src/kernel}/include/vga.h (89%) rename {kernel => src/kernel}/init/icxxabi.cpp (100%) rename {kernel => src/kernel}/init/kernel_class.cpp (100%) create mode 100644 src/kernel/init/main.cpp rename {kernel => src/kernel}/system/cpu.c (100%) create mode 100644 src/kernel/system/heap.c rename {kernel => src/kernel}/system/system.c (61%) rename {kernel => src/kernel}/system/task.c (96%) rename {kernel => src/kernel}/system/time.c (86%) rename {libc => src/libc}/Makefile (97%) rename {libc => src/libc}/arch/i386/crt0.S (100%) rename {libc => src/libc}/arch/i386/crti.S (100%) rename {libc => src/libc}/arch/i386/crtn.S (100%) rename {libc => src/libc}/arch/i386/make.config (100%) rename {libc => src/libc}/include/bitmap.h (56%) create mode 100644 src/libc/include/linked_list.h rename {libc => src/libc}/include/list.h (91%) rename {libc => src/libc}/include/phapi.h (53%) rename {libc => src/libc}/include/stdio.h (76%) rename {libc => src/libc}/include/stdlib.h (74%) rename {libc => src/libc}/include/string.h (85%) rename {libc => src/libc}/include/sys/cdefs.h (100%) rename {libc => src/libc}/phapi/bitmap.c (76%) create mode 100644 src/libc/phapi/linked_list.c rename {libc => src/libc}/phapi/list.c (90%) rename {libc => src/libc}/stdio/getch.c (56%) rename {libc => src/libc}/stdio/getchar.c (53%) rename {libc => src/libc}/stdio/gets.c (81%) rename {libc => src/libc}/stdio/printf.c (94%) create mode 100644 src/libc/stdio/putchar.c rename {libc => src/libc}/stdio/puts.c (51%) rename {libc => src/libc}/stdlib/abort.c (82%) rename {libc => src/libc}/stdlib/atoi.c (71%) rename {libc => src/libc}/stdlib/exit.c (56%) create mode 100644 src/libc/stdlib/free.c rename {libc => src/libc}/stdlib/intlen.c (51%) rename {libc => src/libc}/stdlib/itoa.c (87%) create mode 100644 src/libc/stdlib/malloc.c rename {libc => src/libc}/string/memcmp.c (81%) rename {libc => src/libc}/string/memcpy.c (76%) rename {libc => src/libc}/string/memmove.c (81%) rename {libc => src/libc}/string/memset.c (72%) rename {libc => src/libc}/string/memsetw.c (70%) rename {libc => src/libc}/string/strcmp.c (71%) rename {libc => src/libc}/string/strlen.c (62%) rename {libc => src/libc}/string/strrev.c (100%) rename target-triplet-to-arch.sh => src/target-triplet-to-arch.sh (100%) delete mode 100644 tags diff --git a/: b/: deleted file mode 100644 index 5fa1a8a..0000000 --- a/: +++ /dev/null @@ -1,179 +0,0 @@ -/* Initialization interface - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern int detect_cpu(void); - -#define FREQ 100 - -void init_stdio() { - inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE, 0, 0); - outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE, 0, 0); - - stdin = (uint8_t*) inbuffer; - stdout = (char*) outbuffer; - - for (int i = 0; i <= STDIO_SIZE; i++) { - inbuffer[i] = 0; - outbuffer[i] = 0; - } -} - -void init(multiboot *mboot_ptr, uint32_t init_stack) { - cli(); - init_esp = init_stack; - - init_vga(); - - printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); - detect_cpu(); - printk("\n-------------------------------------------------------------------\n"); - - printk("VGA driver was installed!"); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize GDT. "); - init_gdt(); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize IDT and interrupts. "); - init_idt(); - wstr_color("[OK]\n", COLOR_GREEN); - - - // mask some interrupts - IRQ_set_mask(2); - IRQ_set_mask(3); - IRQ_set_mask(4); - IRQ_set_mask(5); - IRQ_set_mask(6); - IRQ_set_mask(7); - IRQ_set_mask(8); - IRQ_set_mask(9); - IRQ_set_mask(10); - IRQ_set_mask(11); - IRQ_set_mask(12); - IRQ_set_mask(13); - IRQ_set_mask(14); - IRQ_set_mask(15); - - printk("Install timer and clock. "); - init_timer(FREQ); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Install keyboard support. "); - install_keyboard(); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize PMM and VMM. "); - init_pmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); - init_vmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); - wstr_color("[OK]\n", COLOR_GREEN); - debug_mem_mngr(); - keep_running(); - - printk("Memory info:\n"); - printk("\tKernel starts at: %x\n", (size_t)&kernel_start); - printk("\tKernel ends at: %x\n", (size_t)&kernel_end); - //printk("\tRAM: %d MB\n", mem_size_mb); - - printk("Initialize stdio (allow using of stdio header). "); - init_stdio(); - wstr_color("[OK]\n", COLOR_GREEN); - - /* tasking is useless, because switcher crashes every time - init_tasking(); - - uint32_t cr3, eflags; - asm volatile("movl %%cr3, %%eax; movl %%eax, %0;":"=r"(cr3)::"%eax"); - asm volatile("pushfl; movl (%%esp), %%eax; movl %%eax, %0; popfl;":"=r"(eflags)::"%eax"); - - task_t *clock_task = create_task(clock_task, &update_time, eflags, cr3); - */ - - wstr_color("\nDONE!\n", COLOR_GREEN); - - sti(); - - getch(); -} - -void welcome() { - clear_vga(); - - wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); - wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); - wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); - wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); - wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); - wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); - wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); - - wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); - wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | (___) |\n", COLOR_YELLOW); - wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); - - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk(" by Feraru Mihail"); - - getch(); - clear_vga(); -} - -void login() { - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk("Log in please.\n"); - printk("Username: "); - gets(user); - printk("Machine: "); - gets(machine); - printk("Loged in!\n"); -} diff --git a/all b/all deleted file mode 100755 index 91c5282..0000000 --- a/all +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -e -. ./iso.sh - -qemu-system-$(./target-triplet-to-arch.sh $HOST) -cdrom photon.iso diff --git a/kernel/include/init.h b/kernel/include/init.h deleted file mode 100644 index f806006..0000000 --- a/kernel/include/init.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _init_h -#define _init_h - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define FREQ 100 -uint8_t *inbuffer; -char *outbuffer; - -/** - * Initialize standard i/o. - */ -void init_stdio(); - -/** - * Initialize all system. - */ -void init(multiboot *mboot_ptr, uint32_t init_stack); - -/** - * Print welcome screen. - */ -void welcome(); - -/** - * Log in to system. - */ -void login(); - -#endif diff --git a/kernel/include/kheap.h b/kernel/include/kheap.h deleted file mode 100644 index 2f45067..0000000 --- a/kernel/include/kheap.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _kheap_h -#define _kheap_h - -#include -#include -#include -#include -#include - -#define HEAP_START 0xD0000000 -#define HEAP_END 0xFFBFF000 - -typedef struct header -{ - struct header *prev, *next; - uint32_t allocated : 1; - uint32_t length : 31; -} header_t; - -void init_heap (); - -void *kmalloc (size_t size, int align, uint32_t *phys); - -void kfree (void *p); - -#endif diff --git a/kernel/init/init.c b/kernel/init/init.c deleted file mode 100644 index b170add..0000000 --- a/kernel/init/init.c +++ /dev/null @@ -1,189 +0,0 @@ -/* Initialization interface - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern void enable_A20(); - -extern uint32_t nframes; - -extern int detect_cpu(void); - -#define FREQ 100 - -static uint32_t get_total_memory() -{ - // return memory in MiB - return nframes * FRAME_SIZE / 1024 / 1024; -} - -void init_stdio() { - inbuffer = (uint8_t*) kmalloc(sizeof(uint8_t) * STDIO_SIZE, 0, 0); - outbuffer = (char*) kmalloc(sizeof(char) * STDIO_SIZE, 0, 0); - - stdin = (uint8_t*) inbuffer; - stdout = (char*) outbuffer; - - for (int i = 0; i <= STDIO_SIZE; i++) { - inbuffer[i] = 0; - outbuffer[i] = 0; - } -} - -void init(multiboot *mboot_ptr, uint32_t init_stack) { - cli(); - init_esp = init_stack; - - init_vga(); - - printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); - detect_cpu(); - printk("\n-------------------------------------------------------------------\n"); - - printk("VGA driver was installed!"); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize GDT. "); - init_gdt(); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize IDT and interrupts. "); - init_idt(); - wstr_color("[OK]\n", COLOR_GREEN); - - - // mask some interrupts - IRQ_set_mask(2); - IRQ_set_mask(3); - IRQ_set_mask(4); - IRQ_set_mask(5); - IRQ_set_mask(6); - IRQ_set_mask(7); - IRQ_set_mask(8); - IRQ_set_mask(9); - IRQ_set_mask(10); - IRQ_set_mask(11); - IRQ_set_mask(12); - IRQ_set_mask(13); - IRQ_set_mask(14); - IRQ_set_mask(15); - - printk("Install timer and clock. "); - init_timer(FREQ); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Install keyboard support. "); - install_keyboard(); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Enable A20. "); - enable_A20(); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Initialize PMM and VMM. "); - init_pmm(mboot_ptr->mem_lower + mboot_ptr->mem_upper); - init_vmm(); - wstr_color("[OK]\n", COLOR_GREEN); - - printk("Total system memory: %d MiB in %d frames.\n", get_total_memory(), - nframes); - - printk("Initialize stdio (allow using of stdio header). "); - init_stdio(); - wstr_color("[OK]\n", COLOR_GREEN); - - /* tasking is useless, because switcher crashes every time - init_tasking(); - - uint32_t cr3, eflags; - asm volatile("movl %%cr3, %%eax; movl %%eax, %0;":"=r"(cr3)::"%eax"); - asm volatile("pushfl; movl (%%esp), %%eax; movl %%eax, %0; popfl;":"=r"(eflags)::"%eax"); - - task_t *clock_task = create_task(clock_task, &update_time, eflags, cr3); - */ - - wstr_color("\nDONE!\n", COLOR_GREEN); - - sti(); - - getch(); -} - -void welcome() { - clear_vga(); - - wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); - wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); - wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); - wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); - wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); - wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); - wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); - - wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); - wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | (___) |\n", COLOR_YELLOW); - wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); - - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk(" by Feraru Mihail"); - - getch(); - clear_vga(); -} - -void login() { - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk("Log in please.\n"); - printk("Username: "); - gets(user); - printk("Machine: "); - gets(machine); - printk("Loged in!\n"); -} diff --git a/kernel/init/main.cpp b/kernel/init/main.cpp deleted file mode 100644 index bbe7ba7..0000000 --- a/kernel/init/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* All starts here! - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void kmain(multiboot *mboot_ptr, uint32_t init_stack) { - init(mboot_ptr, init_stack); - welcome(); - login(); - - /* C++ Test */ - printk("\n"); - - KernelClass my_kernel; - my_kernel.setID(16072015); - my_kernel.setVersion("v0.0.1cpp"); - int ID = my_kernel.getID(); - char version[30]; - memcpy(version, my_kernel.getVersion(), strlen(my_kernel.getVersion()) + 1); - - printk("KERNEL ID: %d\n", ID); - printk("KERNEL VERSION: %s\n", version); - - printk("\n"); - - prompt(); - cli(); - keep_running(); -} - -#ifdef __cplusplus -} -#endif diff --git a/kernel/system/kheap.c b/kernel/system/kheap.c deleted file mode 100644 index cc9a2c3..0000000 --- a/kernel/system/kheap.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Kernel heap driver - * - * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern int paging_enabled; -extern uint32_t placement_addr; - -void init_heap () -{ -} - -void *kmalloc(size_t size, int align, uint32_t *phys) -{ - //if (paging_enabled) { - - //} else { - if (align && (placement_addr & 0xFFFFF000)) { - placement_addr &= 0xFFFFF000; - placement_addr += 0x1000; - } - - if (phys) { - *phys = placement_addr; - } - uint32_t ret_addr = placement_addr; - placement_addr += size; - void *ret_p = (void*) ret_addr; - return ret_p; - //} - return NULL; -} - -void kfree(void *p) -{ - printk("%d", (uint32_t) p); -} diff --git a/libc/stdio/putchar.c b/libc/stdio/putchar.c deleted file mode 100644 index 251d440..0000000 --- a/libc/stdio/putchar.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include - -void putchar(char c) -{ - write_char(c); -} diff --git a/serial.log b/serial.log deleted file mode 100644 index e69de29..0000000 diff --git a/all.sh b/src/all.sh similarity index 100% rename from all.sh rename to src/all.sh diff --git a/build.sh b/src/build.sh similarity index 100% rename from build.sh rename to src/build.sh diff --git a/clean.sh b/src/clean.sh similarity index 100% rename from clean.sh rename to src/clean.sh diff --git a/config.sh b/src/config.sh similarity index 100% rename from config.sh rename to src/config.sh diff --git a/default-host.sh b/src/default-host.sh similarity index 100% rename from default-host.sh rename to src/default-host.sh diff --git a/headers.sh b/src/headers.sh similarity index 100% rename from headers.sh rename to src/headers.sh diff --git a/iso.sh b/src/iso.sh similarity index 100% rename from iso.sh rename to src/iso.sh diff --git a/kernel/Makefile b/src/kernel/Makefile similarity index 98% rename from kernel/Makefile rename to src/kernel/Makefile index da399c2..ce3a3a7 100644 --- a/kernel/Makefile +++ b/src/kernel/Makefile @@ -34,12 +34,11 @@ system/cpu.o \ drivers/keyboard.o \ drivers/io.o \ drivers/vga.o \ -init/init.o \ init/main.o \ system/system.o \ system/time.o \ system/task.o \ -system/kheap.o \ +system/heap.o \ CRTI_OBJ:=$(ARCHDIR)/crti.o CRTBEGIN_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtbegin.o) diff --git a/kernel/arch/i386/a20.asm b/src/kernel/arch/i386/a20.asm similarity index 100% rename from kernel/arch/i386/a20.asm rename to src/kernel/arch/i386/a20.asm diff --git a/kernel/arch/i386/boot/boot.asm b/src/kernel/arch/i386/boot/boot.asm similarity index 87% rename from kernel/arch/i386/boot/boot.asm rename to src/kernel/arch/i386/boot/boot.asm index 2cb86ed..6799987 100644 --- a/kernel/arch/i386/boot/boot.asm +++ b/src/kernel/arch/i386/boot/boot.asm @@ -35,13 +35,20 @@ stack_top: section .text global _start _start: + extern kernel_main + extern kernel_init + mov esp, stack_top ; set stack push esp ; push stack pointer - push ebx ; push multiboot structure - cli - extern kmain - call kmain ; let's GO!!! + push ebx ; push multiboot structure + + cli + + call kernel_init + call kernel_main + cli ; if kmain ends, disable interrupts and go to infinite loop + .hang: hlt ; if I am here, something went wrong :P jmp .hang diff --git a/kernel/arch/i386/crti.S b/src/kernel/arch/i386/crti.S similarity index 100% rename from kernel/arch/i386/crti.S rename to src/kernel/arch/i386/crti.S diff --git a/kernel/arch/i386/crtn.S b/src/kernel/arch/i386/crtn.S similarity index 100% rename from kernel/arch/i386/crtn.S rename to src/kernel/arch/i386/crtn.S diff --git a/kernel/arch/i386/descriptor_tables.asm b/src/kernel/arch/i386/descriptor_tables.asm similarity index 100% rename from kernel/arch/i386/descriptor_tables.asm rename to src/kernel/arch/i386/descriptor_tables.asm diff --git a/kernel/arch/i386/gdt.c b/src/kernel/arch/i386/gdt.c similarity index 91% rename from kernel/arch/i386/gdt.c rename to src/kernel/arch/i386/gdt.c index 08f6b95..9ab40d7 100644 --- a/kernel/arch/i386/gdt.c +++ b/src/kernel/arch/i386/gdt.c @@ -7,12 +7,15 @@ * any later version. */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +gdt_entry_t gdt_entries[5]; +gdt_ptr_t gdt_ptr; +tss_entry_t tss_entry; void init_gdt() { diff --git a/kernel/arch/i386/handlers.c b/src/kernel/arch/i386/handlers.c similarity index 97% rename from kernel/arch/i386/handlers.c rename to src/kernel/arch/i386/handlers.c index 7e55bee..bf3dc6b 100644 --- a/kernel/arch/i386/handlers.c +++ b/src/kernel/arch/i386/handlers.c @@ -1,11 +1,10 @@ -#include -#include -#include #include -#include -#include -#include +#include +#include +#include +#include +int tick; isr_t interrupt_handlers[256]; void std_handler(registers_t *regs) diff --git a/kernel/arch/i386/idt.c b/src/kernel/arch/i386/idt.c similarity index 92% rename from kernel/arch/i386/idt.c rename to src/kernel/arch/i386/idt.c index 34d5977..02d44dd 100644 --- a/kernel/arch/i386/idt.c +++ b/src/kernel/arch/i386/idt.c @@ -7,13 +7,14 @@ * any later version. */ -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include + +idt_entry_t idt_entries[256]; +idt_ptr_t idt_ptr; static void unhandled_interrupt(__attribute__((unused)) registers_t *regs) { diff --git a/kernel/arch/i386/include/gdt.h b/src/kernel/arch/i386/include/gdt.h similarity index 96% rename from kernel/arch/i386/include/gdt.h rename to src/kernel/arch/i386/include/gdt.h index 72bdc5c..711b185 100644 --- a/kernel/arch/i386/include/gdt.h +++ b/src/kernel/arch/i386/include/gdt.h @@ -17,10 +17,11 @@ #ifndef _gdt_h #define _gdt_h -#include -#include -#include #include +#include +#include +#include +#include /* The GDT */ @@ -83,8 +84,6 @@ struct tss_entry_struct } __attribute__((packed)); typedef struct tss_entry_struct tss_entry_t; -tss_entry_t tss_entry; - /** * Flush the TSS. */ @@ -100,9 +99,6 @@ void write_tss(int32_t num, uint16_t ss0, uint32_t esp0); */ void set_kernel_stack(uint32_t stack); -gdt_entry_t gdt_entries[5]; -gdt_ptr_t gdt_ptr; - /** * Flush the GDT. Extern function implemented in 'asm_dt.asm'. */ diff --git a/kernel/arch/i386/include/handlers.h b/src/kernel/arch/i386/include/handlers.h similarity index 97% rename from kernel/arch/i386/include/handlers.h rename to src/kernel/arch/i386/include/handlers.h index eab5020..4fe54c9 100644 --- a/kernel/arch/i386/include/handlers.h +++ b/src/kernel/arch/i386/include/handlers.h @@ -16,9 +16,11 @@ #ifndef _handlers_h #define _handlers_h -#include -#include #include +#include +#include +#include +#include /** * Initialize the ISR. @@ -65,8 +67,6 @@ extern void isr30(); extern void isr31(); extern void isr128(); -extern isr_t interrupt_handlers[256]; - #define IRQ0 32 // Programmable Interrupt Timer Interrupt (handled) #define IRQ1 33 // Keyboard Interrupt (handled) #define IRQ2 34 // Cascade (used internally by the two PICs. never raised) diff --git a/kernel/arch/i386/include/idt.h b/src/kernel/arch/i386/include/idt.h similarity index 93% rename from kernel/arch/i386/include/idt.h rename to src/kernel/arch/i386/include/idt.h index 8970a16..028aa75 100644 --- a/kernel/arch/i386/include/idt.h +++ b/src/kernel/arch/i386/include/idt.h @@ -14,10 +14,11 @@ #ifndef _idt_h #define _idt_h -#include -#include -#include #include +#include +#include +#include +#include /* The IDT */ @@ -44,9 +45,6 @@ struct idt_ptr_struct } __attribute__((packed)); typedef struct idt_ptr_struct idt_ptr_t; -idt_entry_t idt_entries[256]; -idt_ptr_t idt_ptr; - /** * Flush the IDT. Extern function implemented in 'asm_dt.asm'. */ diff --git a/kernel/arch/i386/include/pic.h b/src/kernel/arch/i386/include/pic.h similarity index 100% rename from kernel/arch/i386/include/pic.h rename to src/kernel/arch/i386/include/pic.h diff --git a/kernel/arch/i386/include/pit.h b/src/kernel/arch/i386/include/pit.h similarity index 91% rename from kernel/arch/i386/include/pit.h rename to src/kernel/arch/i386/include/pit.h index 9068d63..ecc22fe 100644 --- a/kernel/arch/i386/include/pit.h +++ b/src/kernel/arch/i386/include/pit.h @@ -14,11 +14,11 @@ #ifndef _clock_h #define _clock_h -#include -#include -#include #include - +#include +#include +#include +#include /** * Function called by PIT handler. */ diff --git a/kernel/arch/i386/include/pmm.h b/src/kernel/arch/i386/include/pmm.h similarity index 91% rename from kernel/arch/i386/include/pmm.h rename to src/kernel/arch/i386/include/pmm.h index 5cead1a..1534df9 100644 --- a/kernel/arch/i386/include/pmm.h +++ b/src/kernel/arch/i386/include/pmm.h @@ -20,8 +20,11 @@ #ifndef _pmm_h #define _pmm_h -#include -#include +#include +#include +#include +#include +#include #define FRAME_SIZE 0x1000 #define PAGE_ALIGN(x) (x & 0xFFFFF000) diff --git a/kernel/arch/i386/include/vmm.h b/src/kernel/arch/i386/include/vmm.h similarity index 89% rename from kernel/arch/i386/include/vmm.h rename to src/kernel/arch/i386/include/vmm.h index 45e4d46..4815353 100644 --- a/kernel/arch/i386/include/vmm.h +++ b/src/kernel/arch/i386/include/vmm.h @@ -1,9 +1,11 @@ #ifndef _vmm_h #define _vmm_h -#include -#include #include +#include +#include +#include +#include #define PAGE_PRESENT 0x1 #define PAGE_READ_WRITE 0x2 diff --git a/kernel/arch/i386/interrupt.asm b/src/kernel/arch/i386/interrupt.asm similarity index 100% rename from kernel/arch/i386/interrupt.asm rename to src/kernel/arch/i386/interrupt.asm diff --git a/kernel/arch/i386/linker.ld b/src/kernel/arch/i386/linker.ld similarity index 100% rename from kernel/arch/i386/linker.ld rename to src/kernel/arch/i386/linker.ld diff --git a/kernel/arch/i386/make.config b/src/kernel/arch/i386/make.config similarity index 100% rename from kernel/arch/i386/make.config rename to src/kernel/arch/i386/make.config diff --git a/kernel/arch/i386/page.asm b/src/kernel/arch/i386/page.asm similarity index 100% rename from kernel/arch/i386/page.asm rename to src/kernel/arch/i386/page.asm diff --git a/kernel/arch/i386/pic.c b/src/kernel/arch/i386/pic.c similarity index 84% rename from kernel/arch/i386/pic.c rename to src/kernel/arch/i386/pic.c index 3ae65fd..db33f96 100644 --- a/kernel/arch/i386/pic.c +++ b/src/kernel/arch/i386/pic.c @@ -1,6 +1,8 @@ -#include -#include -#include +#include +#include +#include +#include +#include void IRQ_set_mask(unsigned char IRQline) { uint16_t port; diff --git a/kernel/arch/i386/pit.c b/src/kernel/arch/i386/pit.c similarity index 86% rename from kernel/arch/i386/pit.c rename to src/kernel/arch/i386/pit.c index 4af1de9..8ff22aa 100644 --- a/kernel/arch/i386/pit.c +++ b/src/kernel/arch/i386/pit.c @@ -7,26 +7,24 @@ * any later version. */ -#include -#include -#include -#include -#include +#include #include #include -#include -#include -#include -#include +#include +#include -int tick; +extern mem_heap_t *kernel_heap; +extern int tick; +extern volatile int in_size; void timer_callback(__attribute__ ((unused)) registers_t *regs) { cli(); tick++; update_time(); - //preempt(); useless, because it crashes + if (in_size >= STDIO_SIZE) { + in_size = 0; + } sti(); } diff --git a/kernel/arch/i386/pmm.c b/src/kernel/arch/i386/pmm.c similarity index 90% rename from kernel/arch/i386/pmm.c rename to src/kernel/arch/i386/pmm.c index 00362d9..4560aa8 100644 --- a/kernel/arch/i386/pmm.c +++ b/src/kernel/arch/i386/pmm.c @@ -7,14 +7,16 @@ * any later version. */ -#include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +uint32_t phys_ram_bytes; +uint32_t phys_ram_kb; +uint32_t phys_ram_mb; +uint32_t phys_ram_gb; uint32_t placement_addr = (uint32_t) &kernel_end; int paging_enabled = 0; diff --git a/kernel/arch/i386/vmm.c b/src/kernel/arch/i386/vmm.c similarity index 81% rename from kernel/arch/i386/vmm.c rename to src/kernel/arch/i386/vmm.c index 7129865..54827f6 100644 --- a/kernel/arch/i386/vmm.c +++ b/src/kernel/arch/i386/vmm.c @@ -1,24 +1,17 @@ -#include -#include -#include #include -#include -#include +#include +#include #include -#include +#include -extern void write_cr3(); -extern void write_cr0(); -extern uint32_t read_cr3(); -extern uint32_t read_cr0(); -extern uint32_t *frames; -extern uint32_t nframes; -extern int paging_enabled; extern uint32_t placement_addr; -extern size_t kernel_end; +extern uint32_t paging_enabled; page_directory_t *kernel_directory; page_directory_t *current_directory; +multiboot *kernel_mboot; +uint32_t kernel_init_stack; +uint32_t init_esp; static void map_area(uint32_t from_va, uint32_t to_va) { @@ -41,11 +34,9 @@ void init_vmm() current_directory = kernel_directory; - // Map BIOS - map_area(0x0, 0x10000); - - // Map Kernel - map_area(0x10000, (uint32_t) &kernel_end); + // Map kernel + 1 MiB + uint32_t mem_to_map = (size_t) &kernel_end + 0x10000; + map_area(0x0, mem_to_map); switch_page_directory(kernel_directory); enable_paging(); @@ -63,9 +54,6 @@ void enable_paging() cr0 |= 0x80000000; write_cr0(cr0); paging_enabled = 1; - - // Temp settings - placement_addr = 0x20000; } void map(uint32_t va, uint32_t pa, uint32_t flags) diff --git a/kernel/drivers/io.c b/src/kernel/drivers/io.c similarity index 96% rename from kernel/drivers/io.c rename to src/kernel/drivers/io.c index 4cef756..417e26a 100644 --- a/kernel/drivers/io.c +++ b/src/kernel/drivers/io.c @@ -7,16 +7,11 @@ * any later version. */ -#include -#include -#include -#include -#include +#include #include +#include #include -#include -#include -#include +#include /* output byte */ void outb(uint32_t ad, uint8_t v) diff --git a/kernel/drivers/keyboard.c b/src/kernel/drivers/keyboard.c similarity index 86% rename from kernel/drivers/keyboard.c rename to src/kernel/drivers/keyboard.c index f0e39cf..52789c1 100644 --- a/kernel/drivers/keyboard.c +++ b/src/kernel/drivers/keyboard.c @@ -7,17 +7,16 @@ * any later version. */ -#include -#include #include -#include +#include #include -#include -#include +#include +#include - /* USA keyboard. */ -// Non-Shifted scancodes to ASCII: -static char USasciiNonShift[] = { +void (*keyboard_handler)(uint8_t *buf, uint16_t size); + +// Keyboard map +char USasciiNonShift[] = { 0, ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', BACKSPACE, TAB, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', ENTER, 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', @@ -26,7 +25,7 @@ KF1, KF2, KF3, KF4, KF5, KF6, KF7, KF8, KF9, KF10, 0, 0, KHOME, KUP, KPGUP,'-', KLEFT, '5', KRIGHT, '+', KEND, KDOWN, KPGDN, KINS, KDEL, 0, 0, 0, KF11, KF12 }; // Shifted scancodes to ASCII: -static char USasciiShift[] = { +char USasciiShift[] = { 0, ESC, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', BACKSPACE, TAB, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', ENTER, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '\"', '~', 0, '|', @@ -34,6 +33,15 @@ TAB, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', ENTER, 0, KF1, KF2, KF3, KF4, KF5, KF6, KF7, KF8, KF9, KF10, 0, 0, KHOME, KUP, KPGUP, '-', KLEFT, '5', KRIGHT, '+', KEND, KDOWN, KPGDN, KINS, KDEL, 0, 0, 0, KF11, KF12 }; +uint8_t kb_buffer[KEYBOARD_BUFFER_SIZE]; +int last; +int shift; +char *ascii_s; +char *ascii_S; + +extern void *stdin; +extern uint32_t in_size; + void install_keyboard() { in_size = 0; @@ -53,9 +61,10 @@ void keyboard_set_handler(void (*callback)(uint8_t *buf, uint16_t size)) void keyboard_interrupt_handler(__attribute__ ((unused)) registers_t *regs) { + cli(); uint8_t scancode = inb(0x60); int special = 0; - + if (scancode & 0x80) { scancode &= 0x7F; if (scancode == KRLEFT_SHIFT || scancode == KRRIGHT_SHIFT) { @@ -75,18 +84,17 @@ void keyboard_interrupt_handler(__attribute__ ((unused)) registers_t *regs) } if (special != 1) { - cli(); keyboard_handler(kb_buffer, last); - sti(); } if (last == KEYBOARD_BUFFER_SIZE) { last = 0; } } + sti(); } void read_kb_buff(uint8_t *buf, uint16_t size) { - ((uint8_t*) stdin)[in_size] = buf[size - 1]; + ((uint8_t*) stdin)[in_size] = buf[size - 1]; } diff --git a/kernel/drivers/vga.c b/src/kernel/drivers/vga.c similarity index 90% rename from kernel/drivers/vga.c rename to src/kernel/drivers/vga.c index 9d7291b..2e03155 100644 --- a/kernel/drivers/vga.c +++ b/src/kernel/drivers/vga.c @@ -7,15 +7,11 @@ * any later version. */ -#include +#include +#include #include -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include #include -#include +#include uint16_t *vga_memory; #ifdef _TEXTMODE @@ -24,7 +20,11 @@ size_t row; size_t col; enum vga_color default_bg = COLOR_BLACK; enum vga_color default_fg = COLOR_LIGHT_GREY; +static const size_t VGA_WIDTH = 80; +static const size_t VGA_HEIGHT = 25; +#endif +#ifdef _TEXTMODE uint8_t make_color(enum vga_color fg, enum vga_color bg) { return fg | bg << 4; @@ -45,6 +45,8 @@ void init_vga() row = 0; col = 0; tabstop = 4; + default_bg = COLOR_BLACK; + default_fg = COLOR_LIGHT_GREY; clear_vga(); #endif } @@ -115,6 +117,13 @@ void vga_putchar(char c) vga_putentryat(' ', make_color(default_fg, default_bg), --col, row); --col; break; + case '~': + printk("[INFO] Halt char printed.\n STOP."); + keep_running(); + break; + case 0: + printk("!000!"); + break; default: vga_putentryat(c, make_color(default_fg, default_bg), col, row); break; diff --git a/src/kernel/include/heap.h b/src/kernel/include/heap.h new file mode 100644 index 0000000..ed68299 --- /dev/null +++ b/src/kernel/include/heap.h @@ -0,0 +1,43 @@ +#ifndef _heap_h +#define _heap_h + +#include +#include +#include +#include +#include + +#define KERNEL_HEAP_SIZE 0x10000 + +typedef struct mem_chunk { + char used; + size_t size; +} mem_chunk_t; + +typedef struct mem_heap { + int magic; + size_t mem_size; + size_t mem_used; + size_t mem_free; + Llist_t *head; +} mem_heap_t; + +#define MEM_HEADER_SIZE (sizeof(Llist_t) + sizeof(mem_chunk_t)) + +void init_heap (); + +void *kmalloc (size_t size, int align, uint32_t *phys); + +void kfree (void *p); + +Llist_t *split_mem_chunk(Llist_t *chunk, size_t size); + +void glue_mem_chunk(Llist_t *chunk1, Llist_t *chunk2); + +Llist_t *find_mem_chunk(mem_heap_t *heap, size_t size); + +Llist_t *alloc_mem_chunk(mem_heap_t *heap, size_t size); + +void free_mem_chunk(mem_heap_t *heap, Llist_t *mem); + +#endif diff --git a/kernel/include/icxxabi.h b/src/kernel/include/icxxabi.h similarity index 100% rename from kernel/include/icxxabi.h rename to src/kernel/include/icxxabi.h diff --git a/kernel/include/io.h b/src/kernel/include/io.h similarity index 82% rename from kernel/include/io.h rename to src/kernel/include/io.h index a5a7bc3..9257b13 100644 --- a/kernel/include/io.h +++ b/src/kernel/include/io.h @@ -1,13 +1,11 @@ #ifndef _io_h #define _io_h -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include -#include #include +#include +#include +#include +#include /* output byte */ void outb(uint32_t ad, uint8_t v); diff --git a/kernel/include/kernel_class.h b/src/kernel/include/kernel_class.h similarity index 100% rename from kernel/include/kernel_class.h rename to src/kernel/include/kernel_class.h diff --git a/kernel/include/keyboard.h b/src/kernel/include/keyboard.h similarity index 87% rename from kernel/include/keyboard.h rename to src/kernel/include/keyboard.h index 4736e82..c01d364 100644 --- a/kernel/include/keyboard.h +++ b/src/kernel/include/keyboard.h @@ -1,21 +1,15 @@ #ifndef _keyboard_h #define _keyboard_h -#include -#include -#include #include - /* Defines. */ -void (*keyboard_handler)(uint8_t *buf, uint16_t size); +#include +#include +#include +#include + /* Defines. */ #define KEYBOARD_BUFFER_SIZE 32 -uint8_t kb_buffer[KEYBOARD_BUFFER_SIZE]; -int last; -int shift; -char *ascii_s; -char *ascii_S; - #define ESC 27 #define BACKSPACE '\b' #define TAB '\t' diff --git a/kernel/include/multiboot.h b/src/kernel/include/multiboot.h similarity index 100% rename from kernel/include/multiboot.h rename to src/kernel/include/multiboot.h diff --git a/kernel/include/system.h b/src/kernel/include/system.h similarity index 62% rename from kernel/include/system.h rename to src/kernel/include/system.h index 0b80044..4bd18e9 100644 --- a/kernel/include/system.h +++ b/src/kernel/include/system.h @@ -1,24 +1,18 @@ #ifndef _system_h #define _system_h +#define LOW_TASK_TIME 1 +#define NORMAL_TASK_TIME 10 +#define HIGH_TASK_TIME 100 + +/* Standard headers */ #include #include #include +#include #include -#define OS_Name "PhotonOS" -#define Version "v0.0.1cpp" -#define Relase_Date "16 July 2015" -#define Author "Feraru Mihail" - -#define sti() asm volatile("sti") -#define cli() asm volatile("cli") -#define hlt() asm volatile("hlt") -#define keep_running() while(true) { hlt(); } - -#define INDEX_FROM_BIT(a) (a/(8*4)) -#define OFFSET_FROM_BIT(a) (a%(8*4)) - +/* Kernel Data Structures */ typedef struct registers { uint32_t ds; // Data segment selector @@ -45,18 +39,58 @@ typedef void (*isr_t)(registers_t*); void register_interrupt_handler(uint8_t n, isr_t handler); typedef void* type_t; -extern size_t kernel_end; -extern size_t kernel_start; + +/* Kernel headers */ + +/* Arch i386 headers */ +#include +#include +#include +#include +#include +#include +#include + +/* General headers */ +#include +#include +#include +#include +#include +#include +#include + +/* Kernel defines */ +#define OS_Name "PhotonOS" +#define Version "v0.0.1cpp" +#define Relase_Date "16 July 2015" +#define Author "Feraru Mihail" + +#define sti() asm volatile("sti") +#define cli() asm volatile("cli") +#define hlt() asm volatile("hlt") +#define keep_running() while(true) { hlt(); } + +/* Kernel ASM variables */ extern uint32_t stack_top; extern uint32_t stack_bottom; -extern uint32_t init_esp; +extern uint32_t kernel_end; +extern uint32_t kernel_start; -extern char user[20]; -extern char machine[30]; +/* Kernel ASM functions */ +extern void enable_A20(); +extern int detect_cpu(void); +extern void write_cr3(); +extern void write_cr0(); +extern uint32_t read_cr3(); +extern uint32_t read_cr0(); +/* Kernel system functions */ void panic(const char *msg, int line, char *file); void reboot(); void shell(char *str); void prompt(); +void welcome(); +void login(); #endif diff --git a/kernel/include/task.h b/src/kernel/include/task.h similarity index 85% rename from kernel/include/task.h rename to src/kernel/include/task.h index 730712b..c20c832 100644 --- a/kernel/include/task.h +++ b/src/kernel/include/task.h @@ -1,7 +1,11 @@ #ifndef _task_h #define _task_h -#include +#include +#include +#include +#include +#include typedef struct task { uint32_t pid; @@ -9,10 +13,6 @@ typedef struct task { struct task *next; } task_t; -task_t *current_task; -task_t *start_task; -uint32_t pid; - /** * Init user mode. */ diff --git a/kernel/include/time.h b/src/kernel/include/time.h similarity index 75% rename from kernel/include/time.h rename to src/kernel/include/time.h index 31fd200..ce9a432 100644 --- a/kernel/include/time.h +++ b/src/kernel/include/time.h @@ -2,11 +2,10 @@ #define _time_h #include - -int mseconds; -int seconds; -int minutes; -int hours; +#include +#include +#include +#include /** * Init clock to 0:0:0:0. diff --git a/kernel/include/vga.h b/src/kernel/include/vga.h similarity index 89% rename from kernel/include/vga.h rename to src/kernel/include/vga.h index 319b30c..b7436a3 100644 --- a/kernel/include/vga.h +++ b/src/kernel/include/vga.h @@ -1,12 +1,11 @@ #ifndef _vga_h #define _vga_h -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include #include +#include +#include +#include +#include extern uint16_t *vga_memory; @@ -100,7 +99,4 @@ void putchar_color(char c, enum vga_color fg); */ void wstr_color(const char* data, enum vga_color fg); -static const size_t VGA_WIDTH = 80; -static const size_t VGA_HEIGHT = 25; - #endif diff --git a/kernel/init/icxxabi.cpp b/src/kernel/init/icxxabi.cpp similarity index 100% rename from kernel/init/icxxabi.cpp rename to src/kernel/init/icxxabi.cpp diff --git a/kernel/init/kernel_class.cpp b/src/kernel/init/kernel_class.cpp similarity index 100% rename from kernel/init/kernel_class.cpp rename to src/kernel/init/kernel_class.cpp diff --git a/src/kernel/init/main.cpp b/src/kernel/init/main.cpp new file mode 100644 index 0000000..8816315 --- /dev/null +++ b/src/kernel/init/main.cpp @@ -0,0 +1,148 @@ +/* All starts here! + * + * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +#define TIMER_FREQ 100 + +extern uint32_t kernel_init_stack; +extern multiboot *kernel_mboot; + +extern uint32_t nframes; +extern uint32_t init_esp; +extern uint32_t kernel_init_stack; +extern multiboot *kernel_mboot; +extern mem_heap_t *kernel_heap; + +extern char user[20]; +extern char machine[30]; + +void* stdout; +void* stdin; +volatile int in_size; +int out_crs; + +uint8_t inbuffer[STDIO_SIZE]; +char outbuffer[STDIO_SIZE]; + +static uint32_t get_total_memory() +{ + // return memory in MiB + return nframes * FRAME_SIZE / 1024 / 1024; +} + +void kernel_init(multiboot *mboot_ptr, uint32_t init_stack) +{ + kernel_init_stack = init_stack; + kernel_mboot = mboot_ptr; + + cli(); + init_esp = kernel_init_stack; + + init_vga(); + + printk("%s %s (%s) by %s. Copyright C 2015 %s. All rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); + detect_cpu(); + printk("\n-------------------------------------------------------------------\n"); + + printk("VGA driver was installed!"); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize GDT. "); + init_gdt(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize IDT and interrupts. "); + init_idt(); + wstr_color("[OK]\n", COLOR_GREEN); + + + // mask some interrupts + IRQ_set_mask(2); + IRQ_set_mask(3); + IRQ_set_mask(4); + IRQ_set_mask(5); + IRQ_set_mask(6); + IRQ_set_mask(7); + IRQ_set_mask(8); + IRQ_set_mask(9); + IRQ_set_mask(10); + IRQ_set_mask(11); + IRQ_set_mask(12); + IRQ_set_mask(13); + IRQ_set_mask(14); + IRQ_set_mask(15); + + printk("Install timer and clock. "); + init_timer(TIMER_FREQ); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Install keyboard support. "); + install_keyboard(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Enable A20. "); + enable_A20(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize PMM and VMM. "); + init_pmm(kernel_mboot->mem_lower + kernel_mboot->mem_upper); + init_vmm(); + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Total system memory: %d MiB in %d frames.\n", get_total_memory(), + nframes); + + printk("Initialize stdio (allow using of stdio header). "); + + stdin = (uint8_t*) inbuffer; + stdout = (char*) outbuffer; + + for (int i = 0; i < STDIO_SIZE; i++) { + inbuffer[i] = 0; + outbuffer[i] = 0; + } + wstr_color("[OK]\n", COLOR_GREEN); + + printk("Initialize kernel heap. "); + init_heap(); + wstr_color("[OK]\n", COLOR_GREEN); + printk("Initialized kernel heap at %x and created main block of %d bytes.\n", + (size_t) kernel_heap + MEM_HEADER_SIZE, kernel_heap->mem_size); + + wstr_color("\nDONE!\n", COLOR_GREEN); + + sti(); + getch(); +} + +void kernel_main() +{ + sti(); + printk("\nPress any key to continue..."); + getch(); + + welcome(); + login(); + prompt(); +} + +#ifdef __cplusplus +} +#endif diff --git a/kernel/system/cpu.c b/src/kernel/system/cpu.c similarity index 100% rename from kernel/system/cpu.c rename to src/kernel/system/cpu.c diff --git a/src/kernel/system/heap.c b/src/kernel/system/heap.c new file mode 100644 index 0000000..a321061 --- /dev/null +++ b/src/kernel/system/heap.c @@ -0,0 +1,214 @@ +/* Kernel heap driver + * + * Copyright (c) 2015 Feraru Mihail (mihailferaru2000@gmail.com). + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include +#include +#include + +// TODO: resolve size recalculation bug after kfree() + +extern uint32_t placement_addr; + +int kheap_initialized = 0; +mem_heap_t *kernel_heap; +Llist_t *kernel_free_mem_head; +mem_chunk_t *free_mem_chunk_head; + +void init_heap () +{ + kernel_heap = kmalloc(sizeof(mem_heap_t), 0, 0); + kernel_free_mem_head = kmalloc(sizeof(Llist_t), 0, 0); + free_mem_chunk_head = kmalloc(sizeof(mem_chunk_t), 0, 0); + + kernel_heap->magic = 0xbeefbeef; + kernel_heap->head = kernel_free_mem_head; + kernel_heap->head->prev = NULL; + kernel_heap->head->next = NULL; + kernel_heap->head->data = (void*) free_mem_chunk_head; + free_mem_chunk_head->used = 0; + free_mem_chunk_head->size = KERNEL_HEAP_SIZE; + kernel_heap->mem_size = KERNEL_HEAP_SIZE; + kernel_heap->mem_free = KERNEL_HEAP_SIZE; + kernel_heap->mem_used = 0; + kheap_initialized = 1; +} + +/* Kernel only allocator */ +void *kmalloc(size_t size, int align, uint32_t *phys) +{ + if (kheap_initialized) { + Llist_t *mem_chunk = alloc_mem_chunk(kernel_heap, size); + if (mem_chunk == NULL) { + return NULL; + } + + void *ret_p = (void*) ((size_t) mem_chunk + MEM_HEADER_SIZE); + return ret_p; + } else { + if (align && (placement_addr & 0xFFFFF000)) { + placement_addr &= 0xFFFFF000; + placement_addr += 0x1000; + } + + if (phys) { + *phys = placement_addr; + } + uint32_t ret_addr = placement_addr; + placement_addr += size; + void *ret_p = (void*) ret_addr; + + return ret_p; + } + return NULL; +} + +void kfree(void *p) +{ + if (kheap_initialized) { + Llist_t *chunk = (Llist_t*) ((size_t) p - MEM_HEADER_SIZE); + free_mem_chunk(kernel_heap, chunk); + } else { + return; + } +} +/* ------------------------------------ */ + +Llist_t *split_mem_chunk(Llist_t *chunk, size_t size) +{ + mem_chunk_t *chunk_data = (mem_chunk_t*) chunk->data; + + Llist_t *next = chunk->next; + + if (size >= chunk_data->size) { + return NULL; + } + + size_t new_chunk_size = chunk_data->size - size - MEM_HEADER_SIZE; + + chunk_data->size = size; + chunk->next = (Llist_t*) ((size_t) chunk + MEM_HEADER_SIZE + chunk_data->size); + chunk->next->data = (void*) chunk->next + sizeof(int) * 3; + + mem_chunk_t *new_chunk_data = (mem_chunk_t*) chunk->next->data; + new_chunk_data->used = chunk_data->used; + new_chunk_data->size = new_chunk_size; + chunk->next->next = next; + chunk->next->prev = chunk; + + if (next != NULL) { + next->prev = chunk->next; + } + + return chunk; +} + +void glue_mem_chunk(Llist_t *chunk1, Llist_t *chunk2) +{ + Llist_t *next = chunk2->next; + Llist_t *prev = chunk1->prev; + + mem_chunk_t *chunk1_data = (mem_chunk_t*) chunk1->data; + mem_chunk_t *chunk2_data = (mem_chunk_t*) chunk2->data; + + size_t new_size = chunk1_data->size + chunk2_data->size + MEM_HEADER_SIZE; + chunk1_data->size = new_size; + + chunk1->next = next; + chunk1->prev = prev; + + if (next != NULL) { + next->prev = chunk1; + } + + if (prev != NULL) { + prev->next = chunk1; + } +} + +Llist_t *find_mem_chunk(mem_heap_t *heap, size_t size) +{ + if (heap->mem_free < size) { + return NULL; + } + + Llist_t *chunk = heap->head; + mem_chunk_t *header = (mem_chunk_t*) chunk->data; + + while (chunk != NULL) { + if (header->size >= size && header->used == 0) { + return chunk; + } + chunk = chunk->next; + + if (chunk != NULL) { + header = (mem_chunk_t*) chunk->data; + } + } + + return NULL; +} + +Llist_t *alloc_mem_chunk(mem_heap_t *heap, size_t size) +{ + Llist_t *free_chunk = find_mem_chunk(heap, size); + if (free_chunk == NULL) { + return NULL; + } + + mem_chunk_t *chunk_data = (mem_chunk_t*) free_chunk->data; + + if (chunk_data->size == size) { + chunk_data->used = 1; + heap->mem_free -= size; + heap->mem_used += size; + + return free_chunk; + } else { + Llist_t *allocated_chunk = split_mem_chunk(free_chunk, size); + + if (allocated_chunk == NULL) { + return NULL; + } + + chunk_data = (mem_chunk_t*) allocated_chunk->data; + heap->mem_free -= (size + MEM_HEADER_SIZE); + heap->mem_used += (size + MEM_HEADER_SIZE); + + chunk_data->used = 1; + return allocated_chunk; + } + + return NULL; +} + +void free_mem_chunk(mem_heap_t *heap, Llist_t *mem) +{ + mem_chunk_t *data = (mem_chunk_t*) mem->data; + data->used = 0; + heap->mem_free += data->size; + heap->mem_used -= data->size; + + if (mem->prev != NULL) { + mem_chunk_t *prev_data = (mem_chunk_t*) mem->prev->data; + if (prev_data->used == 0) { + Llist_t *new_chunk = mem->prev; + glue_mem_chunk(mem->prev, mem); + mem = new_chunk; + } + } + + if (mem->next != NULL) { + mem_chunk_t *next_data = (mem_chunk_t*) mem->next->data; + if (next_data->used == 0) { + glue_mem_chunk(mem, mem->next); + } + } +} diff --git a/kernel/system/system.c b/src/kernel/system/system.c similarity index 61% rename from kernel/system/system.c rename to src/kernel/system/system.c index 6891cfc..43df9ca 100644 --- a/kernel/system/system.c +++ b/src/kernel/system/system.c @@ -8,21 +8,21 @@ */ #include +#include #include -#include #include -#include -#include -#include -#include -#include -#include - -uint32_t init_esp; +#include char user[20]; char machine[30]; +extern mem_heap_t *kernel_heap; +extern int mseconds; +extern int seconds; +extern int minutes; +extern int hours; +extern void *stdin; + static void testing_shell(char *str) { @@ -109,8 +109,8 @@ static void testing_shell(char *str) kfree(tmp); } else if (!strcmp(str, "vga")) { - printk("Ab_C\b\b\nNew\tLineWasWritten NUM~%x%s%c%c\n", 0x123ABC, "test", 'f', 55); - printk("Expected:\nAb\nNew LineWasWritten NUM~0x123abctestf7\n"); + printk("Ab_C\b\b\nNew\tLineWasWritten NUM%x%s%c%c\n", 0x123ABC, "test", 'f', 55); + printk("Expected:\nAb\nNew LineWasWritten NUM0x123abctestf7\n"); } else { printk("Command not found!\n"); } @@ -159,9 +159,9 @@ void shell(char *str) { } else if (!strcmp(str, "write")) { char *to_write = (char*) kmalloc(sizeof(char) * 30, 0, 0); - size_t len = strlen("\nLet's write this...\n"); + size_t len = strlen("Let's write this...\n"); - memcpy(to_write, "Let's write this...\n\0", len + 1); + memcpy(to_write, "Let's write this...\n", len); call(1, (uint32_t) to_write, (uint32_t) len, 0, 0, 0); kfree(to_write); @@ -171,6 +171,7 @@ void shell(char *str) { } else if (!strcmp(str, "huge-alloc")) { int *i = (void *) kmalloc(sizeof(int), 0, 0); kfree(i); + } else if (!strcmp(str, "usermode")) { printk("CPU will jump to usermode, this will stop shell, because it is running only in kernel mode.\n"); init_usermode(); @@ -213,3 +214,55 @@ void prompt() { shell(cmd); } } + +void welcome() { + clear_vga(); + + wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); + wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); + wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); + wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); + wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); + wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); + wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); + + wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); + wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | (___) |\n", COLOR_YELLOW); + wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); + + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk(" by Feraru Mihail"); + + getch(); + clear_vga(); +} + +void login() { + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk("Log in please.\n"); + printk("Username: "); + gets(user); + printk("Machine: "); + gets(machine); + printk("Loged in!\n"); +} diff --git a/kernel/system/task.c b/src/kernel/system/task.c similarity index 96% rename from kernel/system/task.c rename to src/kernel/system/task.c index fa3ceee..816db96 100644 --- a/kernel/system/task.c +++ b/src/kernel/system/task.c @@ -7,13 +7,15 @@ * any later version. */ -#include -#include -#include -#include #include +#include +#include +#include +#include -extern uint32_t stack_top; +task_t *current_task; +task_t *start_task; +uint32_t pid; void *syscalls[] = { &write diff --git a/kernel/system/time.c b/src/kernel/system/time.c similarity index 86% rename from kernel/system/time.c rename to src/kernel/system/time.c index 1855830..84bf032 100644 --- a/kernel/system/time.c +++ b/src/kernel/system/time.c @@ -7,10 +7,16 @@ * any later version. */ -#include -#include +#include +#include #include -#include +#include +#include + +int mseconds; +int seconds; +int minutes; +int hours; void init_time() { diff --git a/libc/Makefile b/src/libc/Makefile similarity index 97% rename from libc/Makefile rename to src/libc/Makefile index d700418..211d503 100644 --- a/libc/Makefile +++ b/src/libc/Makefile @@ -38,6 +38,8 @@ stdlib/abort.o \ stdlib/intlen.o \ stdlib/atoi.o \ stdlib/itoa.o \ +stdlib/malloc.o \ +stdlib/free.o \ string/memcmp.o \ string/memcpy.o \ string/memmove.o \ @@ -47,6 +49,7 @@ string/strcmp.o \ string/strlen.o \ string/strrev.o \ phapi/list.o \ +phapi/linked_list.o \ phapi/bitmap.o \ HOSTEDOBJS:=\ diff --git a/libc/arch/i386/crt0.S b/src/libc/arch/i386/crt0.S similarity index 100% rename from libc/arch/i386/crt0.S rename to src/libc/arch/i386/crt0.S diff --git a/libc/arch/i386/crti.S b/src/libc/arch/i386/crti.S similarity index 100% rename from libc/arch/i386/crti.S rename to src/libc/arch/i386/crti.S diff --git a/libc/arch/i386/crtn.S b/src/libc/arch/i386/crtn.S similarity index 100% rename from libc/arch/i386/crtn.S rename to src/libc/arch/i386/crtn.S diff --git a/libc/arch/i386/make.config b/src/libc/arch/i386/make.config similarity index 100% rename from libc/arch/i386/make.config rename to src/libc/arch/i386/make.config diff --git a/libc/include/bitmap.h b/src/libc/include/bitmap.h similarity index 56% rename from libc/include/bitmap.h rename to src/libc/include/bitmap.h index 01cad09..6bf64c0 100644 --- a/libc/include/bitmap.h +++ b/src/libc/include/bitmap.h @@ -1,13 +1,28 @@ #ifndef _bitmap_h #define _bitmap_h -#include +#include +#include +#include +#include +#include #define BIT_INDEX(x) (x / 0x20) #define BIT_OFFSET(x) (x % 0x20) +/** + * Set bit as used. + */ void use_bit(uint32_t *bitmap, uint32_t bit); + +/** + * Set bit as free. + */ void free_bit(uint32_t *bitmap, uint32_t bit); + +/** + * Test if bit is free or not. + */ uint32_t test_bit(uint32_t *bitmap, uint32_t bit); #endif diff --git a/src/libc/include/linked_list.h b/src/libc/include/linked_list.h new file mode 100644 index 0000000..cc6dd78 --- /dev/null +++ b/src/libc/include/linked_list.h @@ -0,0 +1,24 @@ +#ifndef _linked_list_h +#define _linked_list_h + +#include +#include +#include +#include +#include + +typedef struct Llist { + struct Llist *prev; + struct Llist *next; + void *data; +} Llist_t; + +Llist_t *Llist_create(); +void Llist_push(Llist_t *head, Llist_t *last); +void List_pop(Llist_t *head); +void Llist_insert_after(Llist_t *location, Llist_t *element); +void Llist_insert_before(Llist_t *location, Llist_t *element); +void Llist_remove(Llist_t *location); +void Llist_destroy(Llist_t *head); + +#endif diff --git a/libc/include/list.h b/src/libc/include/list.h similarity index 91% rename from libc/include/list.h rename to src/libc/include/list.h index a88fdf8..5967926 100644 --- a/libc/include/list.h +++ b/src/libc/include/list.h @@ -1,9 +1,10 @@ #ifndef _list_h #define _list_h -#include -#include -#include +#include +#include +#include +#include #include typedef int8_t (*lessthan_pred_t)(type_t, type_t); diff --git a/libc/include/phapi.h b/src/libc/include/phapi.h similarity index 53% rename from libc/include/phapi.h rename to src/libc/include/phapi.h index 68799d5..93e0288 100644 --- a/libc/include/phapi.h +++ b/src/libc/include/phapi.h @@ -2,7 +2,14 @@ #define _phapi_h // include all Photon API headers +#include +#include +#include +#include +#include #include +#include +#include // types & structs of Photon API diff --git a/libc/include/stdio.h b/src/libc/include/stdio.h similarity index 76% rename from libc/include/stdio.h rename to src/libc/include/stdio.h index 1a872a1..629b576 100644 --- a/libc/include/stdio.h +++ b/src/libc/include/stdio.h @@ -1,18 +1,13 @@ #ifndef _stdio_h #define _stdio_h -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include +#include +#include +#include +#include #include -#define STDIO_SIZE 4096 -void* stdout; -void* stdin; -volatile int in_size; -int out_crs; +#define STDIO_SIZE 4096 /** * Puts a char in standard out buffer. diff --git a/libc/include/stdlib.h b/src/libc/include/stdlib.h similarity index 74% rename from libc/include/stdlib.h rename to src/libc/include/stdlib.h index d3fd0c9..fe70fa3 100644 --- a/libc/include/stdlib.h +++ b/src/libc/include/stdlib.h @@ -1,13 +1,11 @@ #ifndef _stdlib_h #define _stdlib_h -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include -#include #include +#include +#include +#include +#include #define ASSERT(b) ((#b) ? (void)0 : panic("Assertion failed!", __LINE__, __FILE__)) @@ -31,4 +29,14 @@ int intlen(int n, int base); */ int atoi(char *str); +/** + * Allocate n bytes of memory. + */ +void *malloc(size_t n); + +/** + * Free allocated memory. + */ +void free(void *p); + #endif diff --git a/libc/include/string.h b/src/libc/include/string.h similarity index 85% rename from libc/include/string.h rename to src/libc/include/string.h index 23cf307..5a98ea9 100644 --- a/libc/include/string.h +++ b/src/libc/include/string.h @@ -1,11 +1,10 @@ #ifndef _string_h #define _string_h -#if !defined(__cplusplus) -#include /* C doesn't have booleans by default. */ -#endif -#include -#include +#include +#include +#include +#include #include /** diff --git a/libc/include/sys/cdefs.h b/src/libc/include/sys/cdefs.h similarity index 100% rename from libc/include/sys/cdefs.h rename to src/libc/include/sys/cdefs.h diff --git a/libc/phapi/bitmap.c b/src/libc/phapi/bitmap.c similarity index 76% rename from libc/phapi/bitmap.c rename to src/libc/phapi/bitmap.c index b726e77..51cbdbf 100644 --- a/libc/phapi/bitmap.c +++ b/src/libc/phapi/bitmap.c @@ -1,5 +1,8 @@ -#include -#include +#include +#include +#include +#include +#include void use_bit(uint32_t *bitmap, uint32_t bit) { diff --git a/src/libc/phapi/linked_list.c b/src/libc/phapi/linked_list.c new file mode 100644 index 0000000..5b5358c --- /dev/null +++ b/src/libc/phapi/linked_list.c @@ -0,0 +1,85 @@ +#include +#include +#include +#include +#include + +Llist_t *Llist_create() +{ + Llist_t *head = malloc(sizeof(Llist_t)); + head->prev = NULL; + head->next = NULL; + + return head; +} + +void Llist_push(Llist_t *head, Llist_t *last) +{ + Llist_t *current = head; + while (current->next != NULL) { + current = current->next; + } + + current->next = last; + current->next->next = NULL; + current->next->prev = current; +} + +void List_pop(Llist_t *head) +{ + Llist_t *current = head; + while (current->next != NULL) { + current = current->next; + } + + current->prev->next = NULL; + free(current); +} + +void Llist_insert_after(Llist_t *location, Llist_t *element) +{ + Llist_t *next_location = location->next; + + location->next = element; + element->next = next_location; + + next_location->prev = element; + element->prev = location; +} + +void Llist_insert_before(Llist_t *location, Llist_t *element) +{ + Llist_t *prev_location = location->prev; + + location->prev = element; + element->prev = prev_location; + + prev_location->next = element; + element->next = location; +} + +void Llist_remove(Llist_t *location) +{ + Llist_t *next = location->next; + Llist_t *prev = location->prev; + + location->prev->next = next; + location->next->prev = prev; + + free(location); +} + +void Llist_destroy(Llist_t *head) +{ + Llist_t *current = head; + + while (current->next != NULL) { + current->prev = NULL; + current = current->next; + free(current->prev); + } + current->prev = NULL; + current->next = NULL; + free(current); +} + diff --git a/libc/phapi/list.c b/src/libc/phapi/list.c similarity index 90% rename from libc/phapi/list.c rename to src/libc/phapi/list.c index da1e49a..d9c2d48 100644 --- a/libc/phapi/list.c +++ b/src/libc/phapi/list.c @@ -1,9 +1,8 @@ -#include -#include -#include -#include -#include +#include +#include #include +#include +#include int8_t std_lessthan_pred(type_t a, type_t b) { @@ -13,7 +12,7 @@ int8_t std_lessthan_pred(type_t a, type_t b) list_t create_list(uint32_t max_size, lessthan_pred_t lessthan) { list_t ret; - ret.array = (void*) kmalloc(max_size * sizeof(type_t), 0, 0); + ret.array = malloc(max_size * sizeof(type_t)); memset(ret.array, 0, max_size * sizeof(type_t)); ret.size = 0; ret.max_size = max_size; diff --git a/libc/stdio/getch.c b/src/libc/stdio/getch.c similarity index 56% rename from libc/stdio/getch.c rename to src/libc/stdio/getch.c index 6edf8f6..0678025 100644 --- a/libc/stdio/getch.c +++ b/src/libc/stdio/getch.c @@ -1,16 +1,20 @@ +#include #include -#include -#include +#include +#include +#include + +extern void *stdin; +extern volatile uint32_t in_size; int getch() { - for (;;) { + while (true) { if (((uint8_t*)stdin)[in_size] != 0) { in_size++; break; } } int c = ((uint8_t*)stdin)[in_size - 1]; - return c; } diff --git a/libc/stdio/getchar.c b/src/libc/stdio/getchar.c similarity index 53% rename from libc/stdio/getchar.c rename to src/libc/stdio/getchar.c index 3b3bb5a..1e45c1e 100644 --- a/libc/stdio/getchar.c +++ b/src/libc/stdio/getchar.c @@ -1,5 +1,8 @@ +#include #include -#include +#include +#include +#include int getchar() { diff --git a/libc/stdio/gets.c b/src/libc/stdio/gets.c similarity index 81% rename from libc/stdio/gets.c rename to src/libc/stdio/gets.c index f5a1d6c..ecdf8a9 100644 --- a/libc/stdio/gets.c +++ b/src/libc/stdio/gets.c @@ -1,4 +1,8 @@ +#include #include +#include +#include +#include char *gets(char *str) { diff --git a/libc/stdio/printf.c b/src/libc/stdio/printf.c similarity index 94% rename from libc/stdio/printf.c rename to src/libc/stdio/printf.c index 3bb92d0..6a04691 100644 --- a/libc/stdio/printf.c +++ b/src/libc/stdio/printf.c @@ -1,11 +1,8 @@ -#include -#include -#include +#include #include -#include -#include #include -#include +#include +#include int printf(const char* restrict format, ...) { diff --git a/src/libc/stdio/putchar.c b/src/libc/stdio/putchar.c new file mode 100644 index 0000000..c781773 --- /dev/null +++ b/src/libc/stdio/putchar.c @@ -0,0 +1,10 @@ +#include +#include +#include +#include +#include + +void putchar(char c) +{ + write_char(c); +} diff --git a/libc/stdio/puts.c b/src/libc/stdio/puts.c similarity index 51% rename from libc/stdio/puts.c rename to src/libc/stdio/puts.c index 3c696bf..9ffc66d 100644 --- a/libc/stdio/puts.c +++ b/src/libc/stdio/puts.c @@ -1,4 +1,8 @@ +#include #include +#include +#include +#include int puts(const char* string) { diff --git a/libc/stdlib/abort.c b/src/libc/stdlib/abort.c similarity index 82% rename from libc/stdlib/abort.c rename to src/libc/stdlib/abort.c index a4d535c..6d5531e 100644 --- a/libc/stdlib/abort.c +++ b/src/libc/stdlib/abort.c @@ -1,6 +1,8 @@ -#include +#include #include -#include +#include +#include +#include __attribute__((__noreturn__)) void abort(void) diff --git a/libc/stdlib/atoi.c b/src/libc/stdlib/atoi.c similarity index 71% rename from libc/stdlib/atoi.c rename to src/libc/stdlib/atoi.c index 7f7446b..6a05b86 100644 --- a/libc/stdlib/atoi.c +++ b/src/libc/stdlib/atoi.c @@ -1,4 +1,8 @@ -#include +#include +#include +#include +#include +#include int atoi(char *str) { diff --git a/libc/stdlib/exit.c b/src/libc/stdlib/exit.c similarity index 56% rename from libc/stdlib/exit.c rename to src/libc/stdlib/exit.c index 23a14f5..adcdf2a 100644 --- a/libc/stdlib/exit.c +++ b/src/libc/stdlib/exit.c @@ -1,5 +1,8 @@ -#include -#include +#include +#include +#include +#include +#include void exit(int status) { diff --git a/src/libc/stdlib/free.c b/src/libc/stdlib/free.c new file mode 100644 index 0000000..4e2d997 --- /dev/null +++ b/src/libc/stdlib/free.c @@ -0,0 +1,13 @@ +#include +#include +#include +#include +#include + +extern mem_heap_t *user_heap; + +void free(void *p) +{ + Llist_t *chunk = (Llist_t*) ((size_t) p - MEM_HEADER_SIZE); + free_mem_chunk(user_heap, chunk); +} diff --git a/libc/stdlib/intlen.c b/src/libc/stdlib/intlen.c similarity index 51% rename from libc/stdlib/intlen.c rename to src/libc/stdlib/intlen.c index 7ba004f..13462a8 100644 --- a/libc/stdlib/intlen.c +++ b/src/libc/stdlib/intlen.c @@ -1,4 +1,8 @@ -#include +#include +#include +#include +#include +#include int intlen(int n, int base) { diff --git a/libc/stdlib/itoa.c b/src/libc/stdlib/itoa.c similarity index 87% rename from libc/stdlib/itoa.c rename to src/libc/stdlib/itoa.c index 017c4d0..0b39e29 100644 --- a/libc/stdlib/itoa.c +++ b/src/libc/stdlib/itoa.c @@ -1,5 +1,8 @@ -#include +#include +#include #include +#include +#include static void add_hex_prefix(char *buf) { diff --git a/src/libc/stdlib/malloc.c b/src/libc/stdlib/malloc.c new file mode 100644 index 0000000..6db9dc3 --- /dev/null +++ b/src/libc/stdlib/malloc.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include + +mem_heap_t *user_heap; +Llist_t *user_free_mem_head; +mem_chunk_t *user_mem_chunk_head; +char malloc_initialized = 0; + +static void init_malloc() +{ + +} + +void *malloc(size_t n) +{ + if (!malloc_initialized) { + return NULL; + } + + Llist_t *chunk = alloc_mem_chunk(user_heap, n); + printk("Malloc: %x\n", chunk); + if (chunk == NULL) { + return NULL; + } + + void *ret_p = (void*) ((size_t) chunk - MEM_HEADER_SIZE); + return ret_p; +} diff --git a/libc/string/memcmp.c b/src/libc/string/memcmp.c similarity index 81% rename from libc/string/memcmp.c rename to src/libc/string/memcmp.c index 9035a88..669c702 100644 --- a/libc/string/memcmp.c +++ b/src/libc/string/memcmp.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include int memcmp(const void* aptr, const void* bptr, size_t size) { diff --git a/libc/string/memcpy.c b/src/libc/string/memcpy.c similarity index 76% rename from libc/string/memcpy.c rename to src/libc/string/memcpy.c index f400f77..e5cc75a 100644 --- a/libc/string/memcpy.c +++ b/src/libc/string/memcpy.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include void* memcpy(void* dstptr, const void* srcptr, size_t size) { diff --git a/libc/string/memmove.c b/src/libc/string/memmove.c similarity index 81% rename from libc/string/memmove.c rename to src/libc/string/memmove.c index 99aac5d..60a4b19 100644 --- a/libc/string/memmove.c +++ b/src/libc/string/memmove.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include void* memmove(void* dstptr, const void* srcptr, size_t size) { diff --git a/libc/string/memset.c b/src/libc/string/memset.c similarity index 72% rename from libc/string/memset.c rename to src/libc/string/memset.c index db0c002..e98fca7 100644 --- a/libc/string/memset.c +++ b/src/libc/string/memset.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include void* memset(void* bufptr, int value, size_t size) { diff --git a/libc/string/memsetw.c b/src/libc/string/memsetw.c similarity index 70% rename from libc/string/memsetw.c rename to src/libc/string/memsetw.c index 0671241..9a33f87 100644 --- a/libc/string/memsetw.c +++ b/src/libc/string/memsetw.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include void *memsetw(void *s, int c, size_t n) { diff --git a/libc/string/strcmp.c b/src/libc/string/strcmp.c similarity index 71% rename from libc/string/strcmp.c rename to src/libc/string/strcmp.c index 5264db0..8b33fc7 100644 --- a/libc/string/strcmp.c +++ b/src/libc/string/strcmp.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include int strcmp(const char *s1, const char *s2) { diff --git a/libc/string/strlen.c b/src/libc/string/strlen.c similarity index 62% rename from libc/string/strlen.c rename to src/libc/string/strlen.c index 00506a4..f4cabb3 100644 --- a/libc/string/strlen.c +++ b/src/libc/string/strlen.c @@ -1,4 +1,8 @@ +#include +#include #include +#include +#include size_t strlen(const char* string) { diff --git a/libc/string/strrev.c b/src/libc/string/strrev.c similarity index 100% rename from libc/string/strrev.c rename to src/libc/string/strrev.c diff --git a/target-triplet-to-arch.sh b/src/target-triplet-to-arch.sh similarity index 100% rename from target-triplet-to-arch.sh rename to src/target-triplet-to-arch.sh diff --git a/tags b/tags deleted file mode 100644 index 5ef02fc..0000000 --- a/tags +++ /dev/null @@ -1,914 +0,0 @@ -!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ -!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ -!_TAG_PROGRAM_NAME Exuberant Ctags // -!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ -!_TAG_PROGRAM_VERSION 5.9~svn20110310 // -ALL_OUR_OBJS kernel/Makefile /^ALL_OUR_OBJS:=\\$/;" m -ARCHDIR kernel/Makefile /^ARCHDIR:=arch\/$(HOSTARCH)$/;" m -ARCHDIR libc/Makefile /^ARCHDIR:=arch\/$(HOSTARCH)$/;" m -ASSERT libc/include/stdlib.h 12;" d -ASSERT sysroot/usr/include/stdlib.h 12;" d -ATEXIT_MAX_FUNCS kernel/include/icxxabi.h 4;" d -ATEXIT_MAX_FUNCS sysroot/usr/include/icxxabi.h 4;" d -Author kernel/include/system.h 12;" d -Author sysroot/usr/include/system.h 12;" d -BACKSPACE kernel/include/keyboard.h 20;" d -BACKSPACE sysroot/usr/include/keyboard.h 20;" d -BINARIES libc/Makefile /^BINARIES=libg.a libk.a $(ARCHDIR)\/crt0.o $(ARCHDIR)\/crti.o $(ARCHDIR)\/crtn.o # add libc.a when user space is ready$/;" m -BOOTDIR kernel/Makefile /^BOOTDIR?=$(EXEC_PREFIX)\/boot$/;" m -CFLAGS kernel/Makefile /^CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS)$/;" m -CFLAGS kernel/Makefile /^CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra$/;" m -CFLAGS kernel/Makefile /^CFLAGS?=-O2 -g$/;" m -CFLAGS libc/Makefile /^CFLAGS:=$(CFLAGS) $(ARCH_CFLAGS)$/;" m -CFLAGS libc/Makefile /^CFLAGS:=$(CFLAGS) -Wall -Wextra$/;" m -CFLAGS libc/Makefile /^CFLAGS?=-O2 -g$/;" m -CHECKSUM kernel/arch/i386/boot/boot.asm /^CHECKSUM equ -(MAGIC + FLAGS) $/;" d -COLOR_BLACK kernel/include/vga.h /^ COLOR_BLACK = 0,$/;" e enum:vga_color -COLOR_BLACK sysroot/usr/include/vga.h /^ COLOR_BLACK = 0,$/;" e enum:vga_color -COLOR_BLUE kernel/include/vga.h /^ COLOR_BLUE = 1,$/;" e enum:vga_color -COLOR_BLUE sysroot/usr/include/vga.h /^ COLOR_BLUE = 1,$/;" e enum:vga_color -COLOR_BROWN kernel/include/vga.h /^ COLOR_BROWN = 6,$/;" e enum:vga_color -COLOR_BROWN sysroot/usr/include/vga.h /^ COLOR_BROWN = 6,$/;" e enum:vga_color -COLOR_CYAN kernel/include/vga.h /^ COLOR_CYAN = 3,$/;" e enum:vga_color -COLOR_CYAN sysroot/usr/include/vga.h /^ COLOR_CYAN = 3,$/;" e enum:vga_color -COLOR_DARK_GREY kernel/include/vga.h /^ COLOR_DARK_GREY = 8,$/;" e enum:vga_color -COLOR_DARK_GREY sysroot/usr/include/vga.h /^ COLOR_DARK_GREY = 8,$/;" e enum:vga_color -COLOR_GREEN kernel/include/vga.h /^ COLOR_GREEN = 2,$/;" e enum:vga_color -COLOR_GREEN sysroot/usr/include/vga.h /^ COLOR_GREEN = 2,$/;" e enum:vga_color -COLOR_LIGHT_BLUE kernel/include/vga.h /^ COLOR_LIGHT_BLUE = 9,$/;" e enum:vga_color -COLOR_LIGHT_BLUE sysroot/usr/include/vga.h /^ COLOR_LIGHT_BLUE = 9,$/;" e enum:vga_color -COLOR_LIGHT_CYAN kernel/include/vga.h /^ COLOR_LIGHT_CYAN = 11,$/;" e enum:vga_color -COLOR_LIGHT_CYAN sysroot/usr/include/vga.h /^ COLOR_LIGHT_CYAN = 11,$/;" e enum:vga_color -COLOR_LIGHT_GREEN kernel/include/vga.h /^ COLOR_LIGHT_GREEN = 10,$/;" e enum:vga_color -COLOR_LIGHT_GREEN sysroot/usr/include/vga.h /^ COLOR_LIGHT_GREEN = 10,$/;" e enum:vga_color -COLOR_LIGHT_GREY kernel/include/vga.h /^ COLOR_LIGHT_GREY = 7,$/;" e enum:vga_color -COLOR_LIGHT_GREY sysroot/usr/include/vga.h /^ COLOR_LIGHT_GREY = 7,$/;" e enum:vga_color -COLOR_LIGHT_MAGENTA kernel/include/vga.h /^ COLOR_LIGHT_MAGENTA = 13,$/;" e enum:vga_color -COLOR_LIGHT_MAGENTA sysroot/usr/include/vga.h /^ COLOR_LIGHT_MAGENTA = 13,$/;" e enum:vga_color -COLOR_LIGHT_RED kernel/include/vga.h /^ COLOR_LIGHT_RED = 12,$/;" e enum:vga_color -COLOR_LIGHT_RED sysroot/usr/include/vga.h /^ COLOR_LIGHT_RED = 12,$/;" e enum:vga_color -COLOR_MAGENTA kernel/include/vga.h /^ COLOR_MAGENTA = 5,$/;" e enum:vga_color -COLOR_MAGENTA sysroot/usr/include/vga.h /^ COLOR_MAGENTA = 5,$/;" e enum:vga_color -COLOR_RED kernel/include/vga.h /^ COLOR_RED = 4,$/;" e enum:vga_color -COLOR_RED sysroot/usr/include/vga.h /^ COLOR_RED = 4,$/;" e enum:vga_color -COLOR_WHITE kernel/include/vga.h /^ COLOR_WHITE = 15,$/;" e enum:vga_color -COLOR_WHITE sysroot/usr/include/vga.h /^ COLOR_WHITE = 15,$/;" e enum:vga_color -COLOR_YELLOW kernel/include/vga.h /^ COLOR_YELLOW = 14,$/;" e enum:vga_color -COLOR_YELLOW sysroot/usr/include/vga.h /^ COLOR_YELLOW = 14,$/;" e enum:vga_color -CPFLAGS kernel/Makefile /^CPFLAGS:=$(CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)$/;" m -CPFLAGS libc/Makefile /^CPFLAGS:=$(CPPFLAGS) $(ARCH_CPPFLAGS)$/;" m -CPPFLAGS kernel/Makefile /^CPPFLAGS:=$(CPPFLAGS) -D__is_photon_kernel -D_TEXTMODE -Iinclude -Iarch\/i386\/include -I..\/libc\/include$/;" m -CPPFLAGS kernel/Makefile /^CPPFLAGS?= $/;" m -CPPFLAGS libc/Makefile /^CPPFLAGS:=$(CPPFLAGS) -D__is_photon_libc -Iinclude$/;" m -CPPFLAGS libc/Makefile /^CPPFLAGS?=$/;" m -CRTBEGIN_OBJ kernel/Makefile /^CRTBEGIN_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtbegin.o)$/;" m -CRTEND_OBJ kernel/Makefile /^CRTEND_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtend.o)$/;" m -CRTI_OBJ kernel/Makefile /^CRTI_OBJ:=$(ARCHDIR)\/crti.o$/;" m -CRTN_OBJ kernel/Makefile /^CRTN_OBJ:=$(ARCHDIR)\/crtn.o$/;" m -DESTDIR kernel/Makefile /^DESTDIR?=$/;" m -DESTDIR libc/Makefile /^DESTDIR?=$/;" m -ENTER kernel/include/keyboard.h 22;" d -ENTER sysroot/usr/include/keyboard.h 22;" d -ESC kernel/include/keyboard.h 19;" d -ESC sysroot/usr/include/keyboard.h 19;" d -EXEC_PREFIX kernel/Makefile /^EXEC_PREFIX?=$(PREFIX)$/;" m -EXEC_PREFIX libc/Makefile /^EXEC_PREFIX?=$(PREFIX)$/;" m -FLAGS kernel/arch/i386/boot/boot.asm /^FLAGS equ MBALIGN | MEMINFO $/;" d -FRAME_ADDR_FROM_INDEX kernel/arch/i386/include/pmm.h 29;" d -FRAME_ADDR_FROM_INDEX sysroot/usr/include/pmm.h 29;" d -FRAME_INDEX kernel/arch/i386/include/pmm.h 27;" d -FRAME_INDEX sysroot/usr/include/pmm.h 27;" d -FRAME_SIZE kernel/arch/i386/include/pmm.h 26;" d -FRAME_SIZE sysroot/usr/include/pmm.h 26;" d -FREEOBJS libc/Makefile /^FREEOBJS:=\\$/;" m -FREQ kernel/include/init.h 22;" d -FREQ kernel/init/init.c 35;" d file: -FREQ sysroot/usr/include/init.h 22;" d -HEAP_END kernel/include/kheap.h 11;" d -HEAP_END sysroot/usr/include/kheap.h 11;" d -HEAP_START kernel/include/kheap.h 10;" d -HEAP_START sysroot/usr/include/kheap.h 10;" d -HOST kernel/Makefile /^HOST?=$(shell ..\/default-host.sh)$/;" m -HOST libc/Makefile /^HOST?=$(shell ..\/default-host.sh)$/;" m -HOSTARCH kernel/Makefile /^HOSTARCH:=$(shell ..\/target-triplet-to-arch.sh $(HOST))$/;" m -HOSTARCH libc/Makefile /^HOSTARCH:=$(shell ..\/target-triplet-to-arch.sh $(HOST))$/;" m -HOSTEDOBJS libc/Makefile /^HOSTEDOBJS:=\\$/;" m -ID_number kernel/include/kernel_class.h /^ int ID_number;$/;" m class:KernelClass -ID_number sysroot/usr/include/kernel_class.h /^ int ID_number;$/;" m class:KernelClass -INCLUDEDIR kernel/Makefile /^INCLUDEDIR?=$(PREFIX)\/include$/;" m -INCLUDEDIR libc/Makefile /^INCLUDEDIR?=$(PREFIX)\/include$/;" m -INDEX_FROM_BIT kernel/include/system.h 19;" d -INDEX_FROM_BIT sysroot/usr/include/system.h 19;" d -IRQ kernel/arch/i386/interrupt.asm /^IRQ 0, 32$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 1, 33$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 2, 34$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 3, 35$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 4, 36$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 5, 37$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 6, 38$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 7, 39$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 8, 40$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 9, 41$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 10, 42$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 11, 43$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 12, 44$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 13, 45$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 14, 46$/;" l -IRQ kernel/arch/i386/interrupt.asm /^IRQ 15, 47$/;" l -IRQ0 kernel/arch/i386/include/handlers.h 70;" d -IRQ0 sysroot/usr/include/handlers.h 70;" d -IRQ1 kernel/arch/i386/include/handlers.h 71;" d -IRQ1 sysroot/usr/include/handlers.h 71;" d -IRQ10 kernel/arch/i386/include/handlers.h 80;" d -IRQ10 sysroot/usr/include/handlers.h 80;" d -IRQ11 kernel/arch/i386/include/handlers.h 81;" d -IRQ11 sysroot/usr/include/handlers.h 81;" d -IRQ12 kernel/arch/i386/include/handlers.h 82;" d -IRQ12 sysroot/usr/include/handlers.h 82;" d -IRQ13 kernel/arch/i386/include/handlers.h 83;" d -IRQ13 sysroot/usr/include/handlers.h 83;" d -IRQ14 kernel/arch/i386/include/handlers.h 84;" d -IRQ14 sysroot/usr/include/handlers.h 84;" d -IRQ15 kernel/arch/i386/include/handlers.h 85;" d -IRQ15 sysroot/usr/include/handlers.h 85;" d -IRQ2 kernel/arch/i386/include/handlers.h 72;" d -IRQ2 sysroot/usr/include/handlers.h 72;" d -IRQ3 kernel/arch/i386/include/handlers.h 73;" d -IRQ3 sysroot/usr/include/handlers.h 73;" d -IRQ4 kernel/arch/i386/include/handlers.h 74;" d -IRQ4 sysroot/usr/include/handlers.h 74;" d -IRQ5 kernel/arch/i386/include/handlers.h 75;" d -IRQ5 sysroot/usr/include/handlers.h 75;" d -IRQ6 kernel/arch/i386/include/handlers.h 76;" d -IRQ6 sysroot/usr/include/handlers.h 76;" d -IRQ7 kernel/arch/i386/include/handlers.h 77;" d -IRQ7 sysroot/usr/include/handlers.h 77;" d -IRQ8 kernel/arch/i386/include/handlers.h 78;" d -IRQ8 sysroot/usr/include/handlers.h 78;" d -IRQ9 kernel/arch/i386/include/handlers.h 79;" d -IRQ9 sysroot/usr/include/handlers.h 79;" d -IRQ_clear_mask kernel/arch/i386/pic.c /^void IRQ_clear_mask(unsigned char IRQline) {$/;" f -IRQ_set_mask kernel/arch/i386/pic.c /^void IRQ_set_mask(unsigned char IRQline) {$/;" f -ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 10$/;" l -ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 11$/;" l -ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 12$/;" l -ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 13$/;" l -ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 14$/;" l -ISR_ERRCODE kernel/arch/i386/interrupt.asm /^ISR_ERRCODE 8$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 0$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 1$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 128$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 15$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 16$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 17$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 18$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 19$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 2$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 20$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 21$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 22$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 23$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 24$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 25$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 26$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 27$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 28$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 29$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 3$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 30$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 31$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 4$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 5$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 6$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 7$/;" l -ISR_NOERRCODE kernel/arch/i386/interrupt.asm /^ISR_NOERRCODE 9$/;" l -Intel kernel/system/cpu.c /^char *Intel[] = {$/;" v -Intel_Other kernel/system/cpu.c /^char *Intel_Other[] = {$/;" v -KDEL kernel/include/keyboard.h 43;" d -KDEL sysroot/usr/include/keyboard.h 43;" d -KDOWN kernel/include/keyboard.h 50;" d -KDOWN sysroot/usr/include/keyboard.h 50;" d -KEND kernel/include/keyboard.h 45;" d -KEND sysroot/usr/include/keyboard.h 45;" d -KESC kernel/include/keyboard.h 27;" d -KESC sysroot/usr/include/keyboard.h 27;" d -KEYBOARD_BUFFER_SIZE kernel/include/keyboard.h 11;" d -KEYBOARD_BUFFER_SIZE sysroot/usr/include/keyboard.h 11;" d -KF1 kernel/include/keyboard.h 28;" d -KF1 sysroot/usr/include/keyboard.h 28;" d -KF10 kernel/include/keyboard.h 37;" d -KF10 sysroot/usr/include/keyboard.h 37;" d -KF11 kernel/include/keyboard.h 38;" d -KF11 sysroot/usr/include/keyboard.h 38;" d -KF12 kernel/include/keyboard.h 39;" d -KF12 sysroot/usr/include/keyboard.h 39;" d -KF2 kernel/include/keyboard.h 29;" d -KF2 sysroot/usr/include/keyboard.h 29;" d -KF3 kernel/include/keyboard.h 30;" d -KF3 sysroot/usr/include/keyboard.h 30;" d -KF4 kernel/include/keyboard.h 31;" d -KF4 sysroot/usr/include/keyboard.h 31;" d -KF5 kernel/include/keyboard.h 32;" d -KF5 sysroot/usr/include/keyboard.h 32;" d -KF6 kernel/include/keyboard.h 33;" d -KF6 sysroot/usr/include/keyboard.h 33;" d -KF7 kernel/include/keyboard.h 34;" d -KF7 sysroot/usr/include/keyboard.h 34;" d -KF8 kernel/include/keyboard.h 35;" d -KF8 sysroot/usr/include/keyboard.h 35;" d -KF9 kernel/include/keyboard.h 36;" d -KF9 sysroot/usr/include/keyboard.h 36;" d -KHOME kernel/include/keyboard.h 44;" d -KHOME sysroot/usr/include/keyboard.h 44;" d -KINS kernel/include/keyboard.h 42;" d -KINS sysroot/usr/include/keyboard.h 42;" d -KLEFT kernel/include/keyboard.h 48;" d -KLEFT sysroot/usr/include/keyboard.h 48;" d -KLWIN kernel/include/keyboard.h 65;" d -KLWIN sysroot/usr/include/keyboard.h 65;" d -KMENU kernel/include/keyboard.h 67;" d -KMENU sysroot/usr/include/keyboard.h 67;" d -KMETA_ALT kernel/include/keyboard.h 54;" d -KMETA_ALT sysroot/usr/include/keyboard.h 54;" d -KMETA_ANY kernel/include/keyboard.h 57;" d -KMETA_ANY sysroot/usr/include/keyboard.h 57;" d -KMETA_CAPS kernel/include/keyboard.h 58;" d -KMETA_CAPS sysroot/usr/include/keyboard.h 58;" d -KMETA_CTRL kernel/include/keyboard.h 55;" d -KMETA_CTRL sysroot/usr/include/keyboard.h 55;" d -KMETA_NUM kernel/include/keyboard.h 59;" d -KMETA_NUM sysroot/usr/include/keyboard.h 59;" d -KMETA_SCRL kernel/include/keyboard.h 60;" d -KMETA_SCRL sysroot/usr/include/keyboard.h 60;" d -KMETA_SHIFT kernel/include/keyboard.h 56;" d -KMETA_SHIFT sysroot/usr/include/keyboard.h 56;" d -KPAUSE kernel/include/keyboard.h 64;" d -KPAUSE sysroot/usr/include/keyboard.h 64;" d -KPGDN kernel/include/keyboard.h 47;" d -KPGDN sysroot/usr/include/keyboard.h 47;" d -KPGUP kernel/include/keyboard.h 46;" d -KPGUP sysroot/usr/include/keyboard.h 46;" d -KPRNT kernel/include/keyboard.h 63;" d -KPRNT sysroot/usr/include/keyboard.h 63;" d -KRCAPS_LOCK kernel/include/keyboard.h 74;" d -KRCAPS_LOCK sysroot/usr/include/keyboard.h 74;" d -KRDEL kernel/include/keyboard.h 77;" d -KRDEL sysroot/usr/include/keyboard.h 77;" d -KRIGHT kernel/include/keyboard.h 51;" d -KRIGHT sysroot/usr/include/keyboard.h 51;" d -KRLEFT_ALT kernel/include/keyboard.h 70;" d -KRLEFT_ALT sysroot/usr/include/keyboard.h 70;" d -KRLEFT_CTRL kernel/include/keyboard.h 68;" d -KRLEFT_CTRL sysroot/usr/include/keyboard.h 68;" d -KRLEFT_SHIFT kernel/include/keyboard.h 72;" d -KRLEFT_SHIFT sysroot/usr/include/keyboard.h 72;" d -KRNUM_LOCK kernel/include/keyboard.h 76;" d -KRNUM_LOCK sysroot/usr/include/keyboard.h 76;" d -KRRIGHT_ALT kernel/include/keyboard.h 71;" d -KRRIGHT_ALT sysroot/usr/include/keyboard.h 71;" d -KRRIGHT_CTRL kernel/include/keyboard.h 69;" d -KRRIGHT_CTRL sysroot/usr/include/keyboard.h 69;" d -KRRIGHT_SHIFT kernel/include/keyboard.h 73;" d -KRRIGHT_SHIFT sysroot/usr/include/keyboard.h 73;" d -KRSCROLL_LOCK kernel/include/keyboard.h 75;" d -KRSCROLL_LOCK sysroot/usr/include/keyboard.h 75;" d -KRWIN kernel/include/keyboard.h 66;" d -KRWIN sysroot/usr/include/keyboard.h 66;" d -KUP kernel/include/keyboard.h 49;" d -KUP sysroot/usr/include/keyboard.h 49;" d -KernelClass kernel/include/kernel_class.h /^class KernelClass {$/;" c -KernelClass kernel/init/kernel_class.cpp /^KernelClass::KernelClass()$/;" f class:KernelClass -KernelClass sysroot/usr/include/kernel_class.h /^class KernelClass {$/;" c -LDFLAGS kernel/Makefile /^LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS)$/;" m -LDFLAGS kernel/Makefile /^LDFLAGS:=$(LDFLAGS)$/;" m -LDFLAGS kernel/Makefile /^LDFLAGS?=$/;" m -LDFLAGS libc/Makefile /^LDFLAGS?=$/;" m -LIBDIR libc/Makefile /^LIBDIR?=$(EXEC_PREFIX)\/lib$/;" m -LIBK_CFLAGS libc/Makefile /^LIBK_CFLAGS:=$(CFLAGS) -ffreestanding$/;" m -LIBK_CFLAGS libc/Makefile /^LIBK_CFLAGS:=$(LIBK_CFLAGS) $(KERNEL_ARCH_CFLAGS)$/;" m -LIBK_CPFLAGS libc/Makefile /^LIBK_CPFLAGS:=$(LIBK_CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)$/;" m -LIBK_CPPFLAGS libc/Makefile /^LIBK_CPPFLAGS:=$(CPPFLAGS) -D__is_photon_kernel$/;" m -LIBK_OBJS libc/Makefile /^LIBK_OBJS:=$(FREEOBJS:.o=.libk.o)$/;" m -LIBS kernel/Makefile /^LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS)$/;" m -LIBS kernel/Makefile /^LIBS:=$(LIBS) -nostdlib -lk -lgcc$/;" m -LIBS kernel/Makefile /^LIBS?= -L..\/libc$/;" m -LIBS libc/Makefile /^LIBS?=$/;" m -MAGIC kernel/arch/i386/boot/boot.asm /^MAGIC equ 0x1BADB002 $/;" d -MBALIGN kernel/arch/i386/boot/boot.asm /^MBALIGN equ 1<<0 $/;" d -MEMINFO kernel/arch/i386/boot/boot.asm /^MEMINFO equ 1<<1 $/;" d -MULTIBOOT_FLAG_AOUT kernel/include/multiboot.h 8;" d -MULTIBOOT_FLAG_AOUT sysroot/usr/include/multiboot.h 8;" d -MULTIBOOT_FLAG_APM kernel/include/multiboot.h 13;" d -MULTIBOOT_FLAG_APM sysroot/usr/include/multiboot.h 13;" d -MULTIBOOT_FLAG_CMDLINE kernel/include/multiboot.h 6;" d -MULTIBOOT_FLAG_CMDLINE sysroot/usr/include/multiboot.h 6;" d -MULTIBOOT_FLAG_CONFIG kernel/include/multiboot.h 11;" d -MULTIBOOT_FLAG_CONFIG sysroot/usr/include/multiboot.h 11;" d -MULTIBOOT_FLAG_DEVICE kernel/include/multiboot.h 5;" d -MULTIBOOT_FLAG_DEVICE sysroot/usr/include/multiboot.h 5;" d -MULTIBOOT_FLAG_ELF kernel/include/multiboot.h 9;" d -MULTIBOOT_FLAG_ELF sysroot/usr/include/multiboot.h 9;" d -MULTIBOOT_FLAG_LOADER kernel/include/multiboot.h 12;" d -MULTIBOOT_FLAG_LOADER sysroot/usr/include/multiboot.h 12;" d -MULTIBOOT_FLAG_MEM kernel/include/multiboot.h 4;" d -MULTIBOOT_FLAG_MEM sysroot/usr/include/multiboot.h 4;" d -MULTIBOOT_FLAG_MMAP kernel/include/multiboot.h 10;" d -MULTIBOOT_FLAG_MMAP sysroot/usr/include/multiboot.h 10;" d -MULTIBOOT_FLAG_MODS kernel/include/multiboot.h 7;" d -MULTIBOOT_FLAG_MODS sysroot/usr/include/multiboot.h 7;" d -MULTIBOOT_FLAG_VBE kernel/include/multiboot.h 14;" d -MULTIBOOT_FLAG_VBE sysroot/usr/include/multiboot.h 14;" d -NEWLINE kernel/include/keyboard.h 24;" d -NEWLINE sysroot/usr/include/keyboard.h 24;" d -OBJS kernel/Makefile /^OBJS:=\\$/;" m -OBJS libc/Makefile /^OBJS:=\\$/;" m -OBJ_LINK_LIST kernel/Makefile /^OBJ_LINK_LIST:=\\$/;" m -OFFSET_FROM_BIT kernel/include/system.h 20;" d -OFFSET_FROM_BIT sysroot/usr/include/system.h 20;" d -OS_Name kernel/include/system.h 9;" d -OS_Name sysroot/usr/include/system.h 9;" d -PAGE_ALIGN kernel/arch/i386/include/pmm.h 28;" d -PAGE_ALIGN sysroot/usr/include/pmm.h 28;" d -PIC1 kernel/arch/i386/include/pic.h 4;" d -PIC1 sysroot/usr/include/pic.h 4;" d -PIC1_COMMAND kernel/arch/i386/include/pic.h 6;" d -PIC1_COMMAND sysroot/usr/include/pic.h 6;" d -PIC1_DATA kernel/arch/i386/include/pic.h 7;" d -PIC1_DATA sysroot/usr/include/pic.h 7;" d -PIC2 kernel/arch/i386/include/pic.h 5;" d -PIC2 sysroot/usr/include/pic.h 5;" d -PIC2_COMMAND kernel/arch/i386/include/pic.h 8;" d -PIC2_COMMAND sysroot/usr/include/pic.h 8;" d -PIC2_DATA kernel/arch/i386/include/pic.h 9;" d -PIC2_DATA sysroot/usr/include/pic.h 9;" d -PREFIX kernel/Makefile /^PREFIX?=\/usr\/local$/;" m -PREFIX libc/Makefile /^PREFIX?=\/usr\/local$/;" m -RETURN kernel/include/keyboard.h 23;" d -RETURN sysroot/usr/include/keyboard.h 23;" d -Relase_Date kernel/include/system.h 11;" d -Relase_Date sysroot/usr/include/system.h 11;" d -STDIO_SIZE libc/include/stdio.h 10;" d -STDIO_SIZE sysroot/usr/include/stdio.h 10;" d -TAB kernel/include/keyboard.h 21;" d -TAB sysroot/usr/include/keyboard.h 21;" d -USasciiNonShift kernel/drivers/keyboard.c /^static char USasciiNonShift[] = {$/;" v file: -USasciiShift kernel/drivers/keyboard.c /^static char USasciiShift[] = {$/;" v file: -VGA_HEIGHT kernel/include/vga.h /^static const size_t VGA_HEIGHT = 25;$/;" v -VGA_HEIGHT sysroot/usr/include/vga.h /^static const size_t VGA_HEIGHT = 25;$/;" v -VGA_WIDTH kernel/include/vga.h /^static const size_t VGA_WIDTH = 80;$/;" v -VGA_WIDTH sysroot/usr/include/vga.h /^static const size_t VGA_WIDTH = 80;$/;" v -Version kernel/include/system.h 10;" d -Version sysroot/usr/include/system.h 10;" d -_ICXXABI_H kernel/include/icxxabi.h 2;" d -_ICXXABI_H sysroot/usr/include/icxxabi.h 2;" d -_SYS_CDEFS_H libc/include/sys/cdefs.h 2;" d -_SYS_CDEFS_H sysroot/usr/include/sys/cdefs.h 2;" d -__MULTIBOOT_H kernel/include/multiboot.h 2;" d -__MULTIBOOT_H sysroot/usr/include/multiboot.h 2;" d -__atexit_func_count kernel/init/icxxabi.cpp /^uarch_t __atexit_func_count = 0;$/;" v -__atexit_funcs kernel/init/icxxabi.cpp /^atexit_func_entry_t __atexit_funcs[ATEXIT_MAX_FUNCS];$/;" v -__cxa_atexit kernel/init/icxxabi.cpp /^int __cxa_atexit(void (*f)(void *), void *objptr, void *dso)$/;" f -__cxa_finalize kernel/init/icxxabi.cpp /^void __cxa_finalize(void *f)$/;" f -__cxa_pure_virtual kernel/init/icxxabi.cpp /^extern "C" void __cxa_pure_virtual()$/;" f -__myos_libc libc/include/sys/cdefs.h 4;" d -__myos_libc sysroot/usr/include/sys/cdefs.h 4;" d -_clock_h kernel/arch/i386/include/pit.h 15;" d -_clock_h sysroot/usr/include/pit.h 15;" d -_fini kernel/arch/i386/crti.S /^_fini:$/;" l -_fini libc/arch/i386/crti.S /^_fini:$/;" l -_gdt_h kernel/arch/i386/include/gdt.h 18;" d -_gdt_h sysroot/usr/include/gdt.h 18;" d -_handlers_h kernel/arch/i386/include/handlers.h 17;" d -_handlers_h sysroot/usr/include/handlers.h 17;" d -_idt_h kernel/arch/i386/include/idt.h 15;" d -_idt_h sysroot/usr/include/idt.h 15;" d -_init kernel/arch/i386/crti.S /^_init:$/;" l -_init libc/arch/i386/crti.S /^_init:$/;" l -_init_h kernel/include/init.h 2;" d -_init_h sysroot/usr/include/init.h 2;" d -_io_h kernel/include/io.h 2;" d -_io_h sysroot/usr/include/io.h 2;" d -_kernel_class_h kernel/include/kernel_class.h 2;" d -_kernel_class_h sysroot/usr/include/kernel_class.h 2;" d -_keyboard_h kernel/include/keyboard.h 2;" d -_keyboard_h sysroot/usr/include/keyboard.h 2;" d -_kheap_h kernel/include/kheap.h 2;" d -_kheap_h sysroot/usr/include/kheap.h 2;" d -_list_h libc/include/list.h 2;" d -_list_h sysroot/usr/include/list.h 2;" d -_phapi_h libc/include/phapi.h 2;" d -_phapi_h sysroot/usr/include/phapi.h 2;" d -_pic_h kernel/arch/i386/include/pic.h 2;" d -_pic_h sysroot/usr/include/pic.h 2;" d -_pmm_h kernel/arch/i386/include/pmm.h 21;" d -_pmm_h sysroot/usr/include/pmm.h 21;" d -_start kernel/arch/i386/boot/boot.asm /^_start:$/;" l -_start libc/arch/i386/crt0.S /^_start:$/;" l -_stdio_h libc/include/stdio.h 2;" d -_stdio_h sysroot/usr/include/stdio.h 2;" d -_stdlib_h libc/include/stdlib.h 2;" d -_stdlib_h sysroot/usr/include/stdlib.h 2;" d -_string_h libc/include/string.h 2;" d -_string_h sysroot/usr/include/string.h 2;" d -_system_h kernel/include/system.h 2;" d -_system_h sysroot/usr/include/system.h 2;" d -_task_h kernel/include/task.h 2;" d -_task_h sysroot/usr/include/task.h 2;" d -_time_h kernel/include/time.h 2;" d -_time_h sysroot/usr/include/time.h 2;" d -_vga_h kernel/include/vga.h 2;" d -_vga_h sysroot/usr/include/vga.h 2;" d -_vmm_h kernel/arch/i386/include/vmm.h 2;" d -_vmm_h sysroot/usr/include/vmm.h 2;" d -abort libc/stdlib/abort.c /^void abort(void)$/;" f -access kernel/arch/i386/include/gdt.h /^ uint8_t access;$/;" m struct:gdt_entry_struct -access sysroot/usr/include/gdt.h /^ uint8_t access;$/;" m struct:gdt_entry_struct -add_hex_prefix libc/stdlib/itoa.c /^static void add_hex_prefix(char *buf)$/;" f file: -addr kernel/include/multiboot.h /^ uint32_t addr;$/;" m struct:multiboot -addr sysroot/usr/include/multiboot.h /^ uint32_t addr;$/;" m struct:multiboot -allocated kernel/include/kheap.h /^ uint32_t allocated : 1;$/;" m struct:header -allocated sysroot/usr/include/kheap.h /^ uint32_t allocated : 1;$/;" m struct:header -always0 kernel/arch/i386/include/idt.h /^ uint8_t always0; $/;" m struct:idt_entry_struct -always0 sysroot/usr/include/idt.h /^ uint8_t always0; $/;" m struct:idt_entry_struct -apm_table kernel/include/multiboot.h /^ uint32_t apm_table;$/;" m struct:multiboot -apm_table sysroot/usr/include/multiboot.h /^ uint32_t apm_table;$/;" m struct:multiboot -array libc/include/list.h /^ type_t *array;$/;" m struct:__anon1 -array sysroot/usr/include/list.h /^ type_t *array;$/;" m struct:__anon2 -ascii_S kernel/include/keyboard.h /^char *ascii_S;$/;" v -ascii_S sysroot/usr/include/keyboard.h /^char *ascii_S;$/;" v -ascii_s kernel/include/keyboard.h /^char *ascii_s;$/;" v -ascii_s sysroot/usr/include/keyboard.h /^char *ascii_s;$/;" v -atexit_func_entry_t kernel/include/icxxabi.h /^struct atexit_func_entry_t$/;" s -atexit_func_entry_t sysroot/usr/include/icxxabi.h /^struct atexit_func_entry_t$/;" s -atoi libc/stdlib/atoi.c /^int atoi(char *str)$/;" f -base kernel/arch/i386/include/gdt.h /^ uint32_t base;$/;" m struct:gdt_ptr_struct -base kernel/arch/i386/include/idt.h /^ uint32_t base; $/;" m struct:idt_ptr_struct -base sysroot/usr/include/gdt.h /^ uint32_t base;$/;" m struct:gdt_ptr_struct -base sysroot/usr/include/idt.h /^ uint32_t base; $/;" m struct:idt_ptr_struct -base_hi kernel/arch/i386/include/idt.h /^ uint16_t base_hi; $/;" m struct:idt_entry_struct -base_hi sysroot/usr/include/idt.h /^ uint16_t base_hi; $/;" m struct:idt_entry_struct -base_high kernel/arch/i386/include/gdt.h /^ uint8_t base_high;$/;" m struct:gdt_entry_struct -base_high sysroot/usr/include/gdt.h /^ uint8_t base_high;$/;" m struct:gdt_entry_struct -base_lo kernel/arch/i386/include/idt.h /^ uint16_t base_lo;$/;" m struct:idt_entry_struct -base_lo sysroot/usr/include/idt.h /^ uint16_t base_lo;$/;" m struct:idt_entry_struct -base_low kernel/arch/i386/include/gdt.h /^ uint16_t base_low;$/;" m struct:gdt_entry_struct -base_low sysroot/usr/include/gdt.h /^ uint16_t base_low;$/;" m struct:gdt_entry_struct -base_mid kernel/arch/i386/include/gdt.h /^ uint8_t base_mid;$/;" m struct:gdt_entry_struct -base_mid sysroot/usr/include/gdt.h /^ uint8_t base_mid;$/;" m struct:gdt_entry_struct -boot_device kernel/include/multiboot.h /^ uint32_t boot_device;$/;" m struct:multiboot -boot_device sysroot/usr/include/multiboot.h /^ uint32_t boot_device;$/;" m struct:multiboot -boot_loader_name kernel/include/multiboot.h /^ uint32_t boot_loader_name;$/;" m struct:multiboot -boot_loader_name sysroot/usr/include/multiboot.h /^ uint32_t boot_loader_name;$/;" m struct:multiboot -call kernel/drivers/io.c /^void call(int32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx, uint32_t esi, uint32_t edi)$/;" f -clear_vga kernel/drivers/vga.c /^void clear_vga()$/;" f -cli kernel/include/system.h 15;" d -cli sysroot/usr/include/system.h 15;" d -cmdline kernel/include/multiboot.h /^ uint32_t cmdline;$/;" m struct:multiboot -cmdline sysroot/usr/include/multiboot.h /^ uint32_t cmdline;$/;" m struct:multiboot -col kernel/drivers/vga.c /^size_t col;$/;" v -config_table kernel/include/multiboot.h /^ uint32_t config_table;$/;" m struct:multiboot -config_table sysroot/usr/include/multiboot.h /^ uint32_t config_table;$/;" m struct:multiboot -cpuid kernel/system/cpu.c 35;" d file: -cr3 kernel/arch/i386/include/gdt.h /^ uint32_t cr3;$/;" m struct:tss_entry_struct -cr3 kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -cr3 sysroot/usr/include/gdt.h /^ uint32_t cr3;$/;" m struct:tss_entry_struct -cr3 sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -create_list libc/phapi/list.c /^list_t create_list(uint32_t max_size, lessthan_pred_t lessthan)$/;" f -create_task kernel/system/task.c /^task_t *create_task(task_t *new_task, void (*main)(), int32_t flags, uint32_t pagedir)$/;" f -cs kernel/arch/i386/include/gdt.h /^ uint32_t cs; \/\/ The value to load into CS when we change to kernel mode.$/;" m struct:tss_entry_struct -cs kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -cs sysroot/usr/include/gdt.h /^ uint32_t cs; \/\/ The value to load into CS when we change to kernel mode.$/;" m struct:tss_entry_struct -cs sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -current_task kernel/include/task.h /^task_t *current_task;$/;" v -current_task sysroot/usr/include/task.h /^task_t *current_task;$/;" v -debug_mem_mngr kernel/arch/i386/vmm.c /^void debug_mem_mngr()$/;" f -default_bg kernel/drivers/vga.c /^enum vga_color default_bg = COLOR_BLACK;$/;" v typeref:enum:vga_color -default_fg kernel/drivers/vga.c /^enum vga_color default_fg = COLOR_LIGHT_GREY;$/;" v typeref:enum:vga_color -destroy_list libc/phapi/list.c /^void destroy_list(list_t *array)$/;" f -destructor_func kernel/include/icxxabi.h /^ void (*destructor_func)(void *);$/;" m struct:atexit_func_entry_t -destructor_func sysroot/usr/include/icxxabi.h /^ void (*destructor_func)(void *);$/;" m struct:atexit_func_entry_t -detect_cpu kernel/system/cpu.c /^int detect_cpu(void) { \/* or main() if your trying to port this as an independant application *\/$/;" f -do_amd kernel/system/cpu.c /^int do_amd(void) {$/;" f -do_intel kernel/system/cpu.c /^int do_intel(void) {$/;" f -drives_addr kernel/include/multiboot.h /^ uint32_t drives_addr;$/;" m struct:multiboot -drives_addr sysroot/usr/include/multiboot.h /^ uint32_t drives_addr;$/;" m struct:multiboot -drives_length kernel/include/multiboot.h /^ uint32_t drives_length;$/;" m struct:multiboot -drives_length sysroot/usr/include/multiboot.h /^ uint32_t drives_length;$/;" m struct:multiboot -ds kernel/arch/i386/include/gdt.h /^ uint32_t ds; \/\/ The value to load into DS when we change to kernel mode.$/;" m struct:tss_entry_struct -ds kernel/include/system.h /^ uint32_t ds; \/\/ Data segment selector$/;" m struct:registers -ds sysroot/usr/include/gdt.h /^ uint32_t ds; \/\/ The value to load into DS when we change to kernel mode.$/;" m struct:tss_entry_struct -ds sysroot/usr/include/system.h /^ uint32_t ds; \/\/ Data segment selector$/;" m struct:registers -dso_handle kernel/include/icxxabi.h /^ void *dso_handle;$/;" m struct:atexit_func_entry_t -dso_handle sysroot/usr/include/icxxabi.h /^ void *dso_handle;$/;" m struct:atexit_func_entry_t -eax kernel/arch/i386/include/gdt.h /^ uint32_t eax;$/;" m struct:tss_entry_struct -eax kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -eax kernel/include/system.h /^ uint32_t eax;$/;" m struct:g_regs -eax kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -eax sysroot/usr/include/gdt.h /^ uint32_t eax;$/;" m struct:tss_entry_struct -eax sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -eax sysroot/usr/include/system.h /^ uint32_t eax;$/;" m struct:g_regs -eax sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -ebp kernel/arch/i386/include/gdt.h /^ uint32_t ebp;$/;" m struct:tss_entry_struct -ebp kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -ebp kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -ebp sysroot/usr/include/gdt.h /^ uint32_t ebp;$/;" m struct:tss_entry_struct -ebp sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -ebp sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -ebx kernel/arch/i386/include/gdt.h /^ uint32_t ebx;$/;" m struct:tss_entry_struct -ebx kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -ebx kernel/include/system.h /^ uint32_t ebx;$/;" m struct:g_regs -ebx kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -ebx sysroot/usr/include/gdt.h /^ uint32_t ebx;$/;" m struct:tss_entry_struct -ebx sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -ebx sysroot/usr/include/system.h /^ uint32_t ebx;$/;" m struct:g_regs -ebx sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -ecx kernel/arch/i386/include/gdt.h /^ uint32_t ecx;$/;" m struct:tss_entry_struct -ecx kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -ecx kernel/include/system.h /^ uint32_t ecx;$/;" m struct:g_regs -ecx kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -ecx sysroot/usr/include/gdt.h /^ uint32_t ecx;$/;" m struct:tss_entry_struct -ecx sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -ecx sysroot/usr/include/system.h /^ uint32_t ecx;$/;" m struct:g_regs -ecx sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -edi kernel/arch/i386/include/gdt.h /^ uint32_t edi;$/;" m struct:tss_entry_struct -edi kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -edi kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -edi kernel/include/system.h /^ uint32_t edi;$/;" m struct:g_regs -edi sysroot/usr/include/gdt.h /^ uint32_t edi;$/;" m struct:tss_entry_struct -edi sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -edi sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -edi sysroot/usr/include/system.h /^ uint32_t edi;$/;" m struct:g_regs -edx kernel/arch/i386/include/gdt.h /^ uint32_t edx;$/;" m struct:tss_entry_struct -edx kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -edx kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -edx kernel/include/system.h /^ uint32_t edx;$/;" m struct:g_regs -edx sysroot/usr/include/gdt.h /^ uint32_t edx;$/;" m struct:tss_entry_struct -edx sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -edx sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -edx sysroot/usr/include/system.h /^ uint32_t edx;$/;" m struct:g_regs -eflags kernel/arch/i386/include/gdt.h /^ uint32_t eflags;$/;" m struct:tss_entry_struct -eflags kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -eflags kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -eflags sysroot/usr/include/gdt.h /^ uint32_t eflags;$/;" m struct:tss_entry_struct -eflags sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -eflags sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -eip kernel/arch/i386/include/gdt.h /^ uint32_t eip;$/;" m struct:tss_entry_struct -eip kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -eip kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -eip sysroot/usr/include/gdt.h /^ uint32_t eip;$/;" m struct:tss_entry_struct -eip sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -eip sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -err_code kernel/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers -err_code sysroot/usr/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers -es kernel/arch/i386/include/gdt.h /^ uint32_t es; \/\/ The value to load into ES when we change to kernel mode.$/;" m struct:tss_entry_struct -es sysroot/usr/include/gdt.h /^ uint32_t es; \/\/ The value to load into ES when we change to kernel mode.$/;" m struct:tss_entry_struct -esi kernel/arch/i386/include/gdt.h /^ uint32_t esi;$/;" m struct:tss_entry_struct -esi kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -esi kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -esi kernel/include/system.h /^ uint32_t esi;$/;" m struct:g_regs -esi sysroot/usr/include/gdt.h /^ uint32_t esi;$/;" m struct:tss_entry_struct -esi sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -esi sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -esi sysroot/usr/include/system.h /^ uint32_t esi;$/;" m struct:g_regs -esp kernel/arch/i386/include/gdt.h /^ uint32_t esp;$/;" m struct:tss_entry_struct -esp kernel/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -esp kernel/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -esp sysroot/usr/include/gdt.h /^ uint32_t esp;$/;" m struct:tss_entry_struct -esp sysroot/usr/include/system.h /^ uint32_t eax, ebx, ecx, edx, esi, edi, esp, ebp, eip, eflags, cr3;$/;" m struct:t_regs -esp sysroot/usr/include/system.h /^ uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; \/\/ Pushed by pusha.$/;" m struct:registers -esp0 kernel/arch/i386/include/gdt.h /^ uint32_t esp0; \/\/ The stack pointer to load when we change to kernel mode.$/;" m struct:tss_entry_struct -esp0 sysroot/usr/include/gdt.h /^ uint32_t esp0; \/\/ The stack pointer to load when we change to kernel mode.$/;" m struct:tss_entry_struct -esp1 kernel/arch/i386/include/gdt.h /^ uint32_t esp1; \/\/ Unused...$/;" m struct:tss_entry_struct -esp1 sysroot/usr/include/gdt.h /^ uint32_t esp1; \/\/ Unused...$/;" m struct:tss_entry_struct -esp2 kernel/arch/i386/include/gdt.h /^ uint32_t esp2;$/;" m struct:tss_entry_struct -esp2 sysroot/usr/include/gdt.h /^ uint32_t esp2;$/;" m struct:tss_entry_struct -exit libc/stdlib/exit.c /^void exit(int status)$/;" f -extern kernel/arch/i386/interrupt.asm /^extern irq_handler$/;" l -extern kernel/arch/i386/interrupt.asm /^extern isr_handler$/;" l -find_frame kernel/arch/i386/pmm.c /^uint32_t find_frame()$/;" f -flags kernel/arch/i386/include/idt.h /^ uint8_t flags; $/;" m struct:idt_entry_struct -flags kernel/include/multiboot.h /^ uint32_t flags;$/;" m struct:multiboot -flags sysroot/usr/include/idt.h /^ uint8_t flags; $/;" m struct:idt_entry_struct -flags sysroot/usr/include/multiboot.h /^ uint32_t flags;$/;" m struct:multiboot -flush_tlb kernel/arch/i386/page.asm /^flush_tlb:$/;" l -frames kernel/arch/i386/pmm.c /^uint32_t *frames;$/;" v -free_frame kernel/arch/i386/pmm.c /^void free_frame(uint32_t addr)$/;" f -fs kernel/arch/i386/include/gdt.h /^ uint32_t fs; \/\/ The value to load into FS when we change to kernel mode.$/;" m struct:tss_entry_struct -fs sysroot/usr/include/gdt.h /^ uint32_t fs; \/\/ The value to load into FS when we change to kernel mode.$/;" m struct:tss_entry_struct -g_regs kernel/include/system.h /^typedef struct g_regs$/;" s -g_regs sysroot/usr/include/system.h /^typedef struct g_regs$/;" s -g_regs_t kernel/include/system.h /^} g_regs_t; \/\/ general registers for system calls$/;" t typeref:struct:g_regs -g_regs_t sysroot/usr/include/system.h /^} g_regs_t; \/\/ general registers for system calls$/;" t typeref:struct:g_regs -gdt_entries kernel/arch/i386/include/gdt.h /^gdt_entry_t gdt_entries[5];$/;" v -gdt_entries sysroot/usr/include/gdt.h /^gdt_entry_t gdt_entries[5];$/;" v -gdt_entry_struct kernel/arch/i386/include/gdt.h /^struct gdt_entry_struct$/;" s -gdt_entry_struct sysroot/usr/include/gdt.h /^struct gdt_entry_struct$/;" s -gdt_entry_t kernel/arch/i386/include/gdt.h /^typedef struct gdt_entry_struct gdt_entry_t;$/;" t typeref:struct:gdt_entry_struct -gdt_entry_t sysroot/usr/include/gdt.h /^typedef struct gdt_entry_struct gdt_entry_t;$/;" t typeref:struct:gdt_entry_struct -gdt_flush kernel/arch/i386/descriptor_tables.asm /^gdt_flush:$/;" l -gdt_ptr kernel/arch/i386/include/gdt.h /^gdt_ptr_t gdt_ptr;$/;" v -gdt_ptr sysroot/usr/include/gdt.h /^gdt_ptr_t gdt_ptr;$/;" v -gdt_ptr_struct kernel/arch/i386/include/gdt.h /^struct gdt_ptr_struct$/;" s -gdt_ptr_struct sysroot/usr/include/gdt.h /^struct gdt_ptr_struct$/;" s -gdt_ptr_t kernel/arch/i386/include/gdt.h /^typedef struct gdt_ptr_struct gdt_ptr_t;$/;" t typeref:struct:gdt_ptr_struct -gdt_ptr_t sysroot/usr/include/gdt.h /^typedef struct gdt_ptr_struct gdt_ptr_t;$/;" t typeref:struct:gdt_ptr_struct -gdt_set_gate kernel/arch/i386/gdt.c /^void gdt_set_gate(int32_t num, uint32_t base, uint32_t limit, uint8_t access, uint8_t gran)$/;" f -getID kernel/init/kernel_class.cpp /^int KernelClass::getID()$/;" f class:KernelClass -getVersion kernel/init/kernel_class.cpp /^char *KernelClass::getVersion()$/;" f class:KernelClass -get_tick kernel/arch/i386/pit.c /^int get_tick()$/;" f -getch libc/stdio/getch.c /^int getch()$/;" f -getchar libc/stdio/getchar.c /^int getchar()$/;" f -gets libc/stdio/gets.c /^char *gets(char *str)$/;" f -global kernel/arch/i386/boot/boot.asm /^global _start$/;" l -global kernel/arch/i386/boot/boot.asm /^global stack_bottom$/;" l -global kernel/arch/i386/boot/boot.asm /^global stack_top$/;" l -granularity kernel/arch/i386/include/gdt.h /^ uint8_t granularity;$/;" m struct:gdt_entry_struct -granularity sysroot/usr/include/gdt.h /^ uint8_t granularity;$/;" m struct:gdt_entry_struct -gs kernel/arch/i386/include/gdt.h /^ uint32_t gs; \/\/ The value to load into GS when we change to kernel mode.$/;" m struct:tss_entry_struct -gs sysroot/usr/include/gdt.h /^ uint32_t gs; \/\/ The value to load into GS when we change to kernel mode.$/;" m struct:tss_entry_struct -header kernel/include/kheap.h /^typedef struct header$/;" s -header sysroot/usr/include/kheap.h /^typedef struct header$/;" s -header_t kernel/include/kheap.h /^} header_t;$/;" t typeref:struct:header -header_t sysroot/usr/include/kheap.h /^} header_t;$/;" t typeref:struct:header -hlt kernel/include/system.h 16;" d -hlt sysroot/usr/include/system.h 16;" d -hours kernel/include/time.h /^int hours;$/;" v -hours sysroot/usr/include/time.h /^int hours;$/;" v -idt_entries kernel/arch/i386/include/idt.h /^idt_entry_t idt_entries[256];$/;" v -idt_entries sysroot/usr/include/idt.h /^idt_entry_t idt_entries[256];$/;" v -idt_entry_struct kernel/arch/i386/include/idt.h /^struct idt_entry_struct$/;" s -idt_entry_struct sysroot/usr/include/idt.h /^struct idt_entry_struct$/;" s -idt_entry_t kernel/arch/i386/include/idt.h /^typedef struct idt_entry_struct idt_entry_t;$/;" t typeref:struct:idt_entry_struct -idt_entry_t sysroot/usr/include/idt.h /^typedef struct idt_entry_struct idt_entry_t;$/;" t typeref:struct:idt_entry_struct -idt_flush kernel/arch/i386/descriptor_tables.asm /^idt_flush:$/;" l -idt_ptr kernel/arch/i386/include/idt.h /^idt_ptr_t idt_ptr; $/;" v -idt_ptr sysroot/usr/include/idt.h /^idt_ptr_t idt_ptr; $/;" v -idt_ptr_struct kernel/arch/i386/include/idt.h /^struct idt_ptr_struct$/;" s -idt_ptr_struct sysroot/usr/include/idt.h /^struct idt_ptr_struct$/;" s -idt_ptr_t kernel/arch/i386/include/idt.h /^typedef struct idt_ptr_struct idt_ptr_t;$/;" t typeref:struct:idt_ptr_struct -idt_ptr_t sysroot/usr/include/idt.h /^typedef struct idt_ptr_struct idt_ptr_t;$/;" t typeref:struct:idt_ptr_struct -idt_set_gate kernel/arch/i386/idt.c /^void idt_set_gate(uint8_t num, uint32_t base, uint16_t sel, uint8_t flags)$/;" f -in_size libc/include/stdio.h /^volatile int in_size;$/;" v -in_size sysroot/usr/include/stdio.h /^volatile int in_size;$/;" v -inb kernel/drivers/io.c /^uint8_t inb(uint32_t ad)$/;" f -inbuffer kernel/include/init.h /^uint8_t *inbuffer;$/;" v -inbuffer sysroot/usr/include/init.h /^uint8_t *inbuffer;$/;" v -init kernel/init/init.c /^void init(multiboot *mboot_ptr, uint32_t init_stack) {$/;" f -init_esp kernel/system/system.c /^uint32_t init_esp;$/;" v -init_gdt kernel/arch/i386/gdt.c /^void init_gdt()$/;" f -init_heap kernel/system/kheap.c /^void init_heap ()$/;" f -init_idt kernel/arch/i386/idt.c /^void init_idt()$/;" f -init_irq kernel/arch/i386/handlers.c /^void init_irq()$/;" f -init_isr kernel/arch/i386/handlers.c /^void init_isr()$/;" f -init_pmm kernel/arch/i386/pmm.c /^void init_pmm(uint32_t mem_size)$/;" f -init_stdio kernel/init/init.c /^void init_stdio() {$/;" f -init_tasking kernel/system/task.c /^void init_tasking()$/;" f -init_time kernel/system/time.c /^void init_time()$/;" f -init_timer kernel/arch/i386/pit.c /^void init_timer(uint32_t frequency)$/;" f -init_usermode kernel/system/task.c /^void init_usermode() {$/;" f -init_vga kernel/drivers/vga.c /^void init_vga()$/;" f -init_vmm kernel/arch/i386/vmm.c /^void init_vmm()$/;" f -inl kernel/drivers/io.c /^uint32_t inl(uint32_t ad)$/;" f -insert_list libc/phapi/list.c /^void insert_list(type_t item, list_t *array)$/;" f -install_keyboard kernel/drivers/keyboard.c /^void install_keyboard()$/;" f -int_no kernel/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers -int_no sysroot/usr/include/system.h /^ uint32_t int_no, err_code; \/\/ Interrupt number and error code (if applicable)$/;" m struct:registers -interrupt_handlers kernel/arch/i386/handlers.c /^isr_t interrupt_handlers[256];$/;" v -intlen libc/stdlib/intlen.c /^int intlen(int n, int base)$/;" f -inw kernel/drivers/io.c /^uint16_t inw(uint32_t ad)$/;" f -iomap_base kernel/arch/i386/include/gdt.h /^ uint16_t iomap_base;$/;" m struct:tss_entry_struct -iomap_base sysroot/usr/include/gdt.h /^ uint16_t iomap_base;$/;" m struct:tss_entry_struct -irq_common_stub kernel/arch/i386/interrupt.asm /^irq_common_stub:$/;" l -irq_handler kernel/arch/i386/handlers.c /^void irq_handler(registers_t regs)$/;" f -isr_common_stub kernel/arch/i386/interrupt.asm /^isr_common_stub:$/;" l -isr_handler kernel/arch/i386/handlers.c /^void isr_handler(registers_t regs)$/;" f -isr_t kernel/include/system.h /^typedef void (*isr_t)(registers_t*);$/;" t -isr_t sysroot/usr/include/system.h /^typedef void (*isr_t)(registers_t*);$/;" t -itoa libc/stdlib/itoa.c /^void itoa(char *buf, unsigned long int n, int base)$/;" f -kb_buffer kernel/include/keyboard.h /^uint8_t kb_buffer[KEYBOARD_BUFFER_SIZE];$/;" v -kb_buffer sysroot/usr/include/keyboard.h /^uint8_t kb_buffer[KEYBOARD_BUFFER_SIZE];$/;" v -keep_running kernel/include/system.h 17;" d -keep_running sysroot/usr/include/system.h 17;" d -keyboard_handler kernel/include/keyboard.h /^void (*keyboard_handler)(uint8_t *buf, uint16_t size); $/;" v -keyboard_handler sysroot/usr/include/keyboard.h /^void (*keyboard_handler)(uint8_t *buf, uint16_t size); $/;" v -keyboard_interrupt_handler kernel/drivers/keyboard.c /^void keyboard_interrupt_handler(__attribute__ ((unused)) registers_t *regs)$/;" f -keyboard_set_handler kernel/drivers/keyboard.c /^void keyboard_set_handler(void (*callback)(uint8_t *buf, uint16_t size))$/;" f -kfree kernel/system/kheap.c /^void kfree (void *p)$/;" f -kmain kernel/init/main.cpp /^void kmain(multiboot *mboot_ptr, uint32_t init_stack) {$/;" f -kmalloc kernel/system/kheap.c /^void *kmalloc (uint32_t p)$/;" f -last kernel/include/keyboard.h /^int last;$/;" v -last sysroot/usr/include/keyboard.h /^int last;$/;" v -ldt kernel/arch/i386/include/gdt.h /^ uint32_t ldt; \/\/ Unused...$/;" m struct:tss_entry_struct -ldt sysroot/usr/include/gdt.h /^ uint32_t ldt; \/\/ Unused...$/;" m struct:tss_entry_struct -length kernel/include/kheap.h /^ uint32_t length : 31;$/;" m struct:header -length sysroot/usr/include/kheap.h /^ uint32_t length : 31;$/;" m struct:header -lessthan libc/include/list.h /^ lessthan_pred_t lessthan;$/;" m struct:__anon1 -lessthan sysroot/usr/include/list.h /^ lessthan_pred_t lessthan;$/;" m struct:__anon2 -lessthan_pred_t libc/include/list.h /^typedef int8_t (*lessthan_pred_t)(type_t, type_t);$/;" t -lessthan_pred_t sysroot/usr/include/list.h /^typedef int8_t (*lessthan_pred_t)(type_t, type_t);$/;" t -lim kernel/arch/i386/include/gdt.h /^ uint16_t lim;$/;" m struct:gdt_ptr_struct -lim sysroot/usr/include/gdt.h /^ uint16_t lim;$/;" m struct:gdt_ptr_struct -lim_low kernel/arch/i386/include/gdt.h /^ uint16_t lim_low;$/;" m struct:gdt_entry_struct -lim_low sysroot/usr/include/gdt.h /^ uint16_t lim_low;$/;" m struct:gdt_entry_struct -limit kernel/arch/i386/include/idt.h /^ uint16_t limit;$/;" m struct:idt_ptr_struct -limit sysroot/usr/include/idt.h /^ uint16_t limit;$/;" m struct:idt_ptr_struct -list_t libc/include/list.h /^} list_t;$/;" t typeref:struct:__anon1 -list_t sysroot/usr/include/list.h /^} list_t;$/;" t typeref:struct:__anon2 -login kernel/init/init.c /^void login() {$/;" f -lookup_list libc/phapi/list.c /^type_t lookup_list(uint32_t i, list_t *array)$/;" f -machine kernel/system/system.c /^char machine[30];$/;" v -make_color kernel/drivers/vga.c /^uint8_t make_color(enum vga_color fg, enum vga_color bg)$/;" f -make_vgaentry kernel/drivers/vga.c /^uint16_t make_vgaentry(char c, uint8_t color)$/;" f -max_size libc/include/list.h /^ uint32_t max_size;$/;" m struct:__anon1 -max_size sysroot/usr/include/list.h /^ uint32_t max_size;$/;" m struct:__anon2 -mem_lower kernel/include/multiboot.h /^ uint32_t mem_lower;$/;" m struct:multiboot -mem_lower sysroot/usr/include/multiboot.h /^ uint32_t mem_lower;$/;" m struct:multiboot -mem_upper kernel/include/multiboot.h /^ uint32_t mem_upper;$/;" m struct:multiboot -mem_upper sysroot/usr/include/multiboot.h /^ uint32_t mem_upper;$/;" m struct:multiboot -memcmp libc/string/memcmp.c /^int memcmp(const void* aptr, const void* bptr, size_t size)$/;" f -memcpy libc/string/memcpy.c /^void* memcpy(void* dstptr, const void* srcptr, size_t size)$/;" f -memmove libc/string/memmove.c /^void* memmove(void* dstptr, const void* srcptr, size_t size)$/;" f -memset libc/string/memset.c /^void* memset(void* bufptr, int value, size_t size)$/;" f -memsetw libc/string/memsetw.c /^void *memsetw(void *s, int c, size_t n)$/;" f -minutes kernel/include/time.h /^int minutes;$/;" v -minutes sysroot/usr/include/time.h /^int minutes;$/;" v -mmap_addr kernel/include/multiboot.h /^ uint32_t mmap_addr;$/;" m struct:multiboot -mmap_addr sysroot/usr/include/multiboot.h /^ uint32_t mmap_addr;$/;" m struct:multiboot -mmap_length kernel/include/multiboot.h /^ uint32_t mmap_length;$/;" m struct:multiboot -mmap_length sysroot/usr/include/multiboot.h /^ uint32_t mmap_length;$/;" m struct:multiboot -mods_addr kernel/include/multiboot.h /^ uint32_t mods_addr;$/;" m struct:multiboot -mods_addr sysroot/usr/include/multiboot.h /^ uint32_t mods_addr;$/;" m struct:multiboot -mods_count kernel/include/multiboot.h /^ uint32_t mods_count;$/;" m struct:multiboot -mods_count sysroot/usr/include/multiboot.h /^ uint32_t mods_count;$/;" m struct:multiboot -mseconds kernel/include/time.h /^int mseconds;$/;" v -mseconds sysroot/usr/include/time.h /^int mseconds;$/;" v -multiboot kernel/include/multiboot.h /^typedef struct multiboot$/;" s -multiboot kernel/include/multiboot.h /^} multiboot;$/;" t typeref:struct:multiboot -multiboot sysroot/usr/include/multiboot.h /^typedef struct multiboot$/;" s -multiboot sysroot/usr/include/multiboot.h /^} multiboot;$/;" t typeref:struct:multiboot -next kernel/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header:: -next kernel/include/task.h /^ struct task *next;$/;" m struct:task typeref:struct:task::task -next sysroot/usr/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header:: -next sysroot/usr/include/task.h /^ struct task *next;$/;" m struct:task typeref:struct:task::task -nframes kernel/arch/i386/pmm.c /^uint32_t nframes;$/;" v -num kernel/include/multiboot.h /^ uint32_t num;$/;" m struct:multiboot -num sysroot/usr/include/multiboot.h /^ uint32_t num;$/;" m struct:multiboot -num_syscalls kernel/system/task.c /^int num_syscalls = 1;$/;" v -obj_ptr kernel/include/icxxabi.h /^ void *obj_ptr;$/;" m struct:atexit_func_entry_t -obj_ptr sysroot/usr/include/icxxabi.h /^ void *obj_ptr;$/;" m struct:atexit_func_entry_t -out_crs libc/include/stdio.h /^int out_crs;$/;" v -out_crs sysroot/usr/include/stdio.h /^int out_crs;$/;" v -outb kernel/drivers/io.c /^void outb(uint32_t ad, uint8_t v)$/;" f -outbuffer kernel/include/init.h /^char *outbuffer;$/;" v -outbuffer sysroot/usr/include/init.h /^char *outbuffer;$/;" v -outl kernel/drivers/io.c /^void outl(uint32_t ad, uint32_t v)$/;" f -outw kernel/drivers/io.c /^void outw(uint32_t ad, uint16_t v)$/;" f -paging_enabled kernel/arch/i386/pmm.c /^int paging_enabled = 0;$/;" v -panic kernel/system/system.c /^void panic(const char *msg, int line, char *file)$/;" f -pid kernel/include/task.h /^ uint32_t pid;$/;" m struct:task -pid kernel/include/task.h /^uint32_t pid;$/;" v -pid sysroot/usr/include/task.h /^ uint32_t pid;$/;" m struct:task -pid sysroot/usr/include/task.h /^uint32_t pid;$/;" v -place_list libc/phapi/list.c /^list_t place_list(void *addr, uint32_t max_size, lessthan_pred_t lessthan)$/;" f -placement_addr kernel/arch/i386/pmm.c /^uint32_t placement_addr = (uint32_t) &kernel_end;$/;" v -preempt kernel/system/task.c /^void preempt()$/;" f -prev kernel/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header::header -prev sysroot/usr/include/kheap.h /^ struct header *prev, *next;$/;" m struct:header typeref:struct:header::header -prev_tss kernel/arch/i386/include/gdt.h /^ uint32_t prev_tss; \/\/ The previous TSS - if we used hardware task switching this would form a linked list.$/;" m struct:tss_entry_struct -prev_tss sysroot/usr/include/gdt.h /^ uint32_t prev_tss; \/\/ The previous TSS - if we used hardware task switching this would form a linked list.$/;" m struct:tss_entry_struct -print_regs kernel/drivers/io.c /^void print_regs(registers_t *regs)$/;" f -print_time kernel/system/time.c /^void print_time()$/;" f -printf libc/stdio/printf.c /^int printf(const char* restrict format, ...)$/;" f -printk kernel/drivers/io.c /^int printk(const char* format, ...)$/;" f -printregs kernel/system/cpu.c /^void printregs(int eax, int ebx, int ecx, int edx) {$/;" f -prompt kernel/system/system.c /^void prompt() {$/;" f -putchar libc/stdio/putchar.c /^void putchar(char c)$/;" f -puts libc/stdio/puts.c /^int puts(const char* string)$/;" f -read_cr0 kernel/arch/i386/page.asm /^read_cr0:$/;" l -read_cr3 kernel/arch/i386/page.asm /^read_cr3:$/;" l -read_eip kernel/arch/i386/descriptor_tables.asm /^read_eip:$/;" l -read_kb_buff kernel/drivers/keyboard.c /^void read_kb_buff(uint8_t *buf, uint16_t size) $/;" f -reboot kernel/system/system.c /^void reboot()$/;" f -register_interrupt_handler kernel/arch/i386/handlers.c /^void register_interrupt_handler(uint8_t n, isr_t handler)$/;" f -registers kernel/include/system.h /^typedef struct registers$/;" s -registers sysroot/usr/include/system.h /^typedef struct registers$/;" s -registers_t kernel/include/system.h /^} registers_t; \/\/ registers for interrupts$/;" t typeref:struct:registers -registers_t sysroot/usr/include/system.h /^} registers_t; \/\/ registers for interrupts$/;" t typeref:struct:registers -regs kernel/include/task.h /^ t_regs_t regs;$/;" m struct:task -regs sysroot/usr/include/task.h /^ t_regs_t regs;$/;" m struct:task -remove_list libc/phapi/list.c /^void remove_list(uint32_t i, list_t *array)$/;" f -row kernel/drivers/vga.c /^size_t row;$/;" v -seconds kernel/include/time.h /^int seconds;$/;" v -seconds sysroot/usr/include/time.h /^int seconds;$/;" v -section kernel/arch/i386/boot/boot.asm /^section .bootstrap_stack$/;" l -section kernel/arch/i386/boot/boot.asm /^section .multiboot$/;" l -section kernel/arch/i386/boot/boot.asm /^section .text$/;" l -sel kernel/arch/i386/include/idt.h /^ uint16_t sel; $/;" m struct:idt_entry_struct -sel sysroot/usr/include/idt.h /^ uint16_t sel; $/;" m struct:idt_entry_struct -setID kernel/init/kernel_class.cpp /^void KernelClass::setID(const int ID)$/;" f class:KernelClass -setVersion kernel/init/kernel_class.cpp /^void KernelClass::setVersion(const char *version)$/;" f class:KernelClass -set_kernel_stack kernel/arch/i386/gdt.c /^void set_kernel_stack(uint32_t stack)$/;" f -shell kernel/system/system.c /^void shell(char *str) {$/;" f -shift kernel/include/keyboard.h /^int shift;$/;" v -shift sysroot/usr/include/keyboard.h /^int shift;$/;" v -shndx kernel/include/multiboot.h /^ uint32_t shndx;$/;" m struct:multiboot -shndx sysroot/usr/include/multiboot.h /^ uint32_t shndx;$/;" m struct:multiboot -size kernel/include/multiboot.h /^ uint32_t size;$/;" m struct:multiboot -size libc/include/list.h /^ uint32_t size;$/;" m struct:__anon1 -size sysroot/usr/include/list.h /^ uint32_t size;$/;" m struct:__anon2 -size sysroot/usr/include/multiboot.h /^ uint32_t size;$/;" m struct:multiboot -ss kernel/arch/i386/include/gdt.h /^ uint32_t ss; \/\/ The value to load into SS when we change to kernel mode.$/;" m struct:tss_entry_struct -ss kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -ss sysroot/usr/include/gdt.h /^ uint32_t ss; \/\/ The value to load into SS when we change to kernel mode.$/;" m struct:tss_entry_struct -ss sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -ss0 kernel/arch/i386/include/gdt.h /^ uint32_t ss0; \/\/ The stack segment to load when we change to kernel mode.$/;" m struct:tss_entry_struct -ss0 sysroot/usr/include/gdt.h /^ uint32_t ss0; \/\/ The stack segment to load when we change to kernel mode.$/;" m struct:tss_entry_struct -ss1 kernel/arch/i386/include/gdt.h /^ uint32_t ss1;$/;" m struct:tss_entry_struct -ss1 sysroot/usr/include/gdt.h /^ uint32_t ss1;$/;" m struct:tss_entry_struct -ss2 kernel/arch/i386/include/gdt.h /^ uint32_t ss2;$/;" m struct:tss_entry_struct -ss2 sysroot/usr/include/gdt.h /^ uint32_t ss2;$/;" m struct:tss_entry_struct -stack_bottom kernel/arch/i386/boot/boot.asm /^stack_bottom:$/;" l -stack_top kernel/arch/i386/boot/boot.asm /^stack_top:$/;" l -start_task kernel/include/task.h /^task_t *start_task;$/;" v -start_task sysroot/usr/include/task.h /^task_t *start_task;$/;" v -std_lessthan_pred libc/phapi/list.c /^int8_t std_lessthan_pred(type_t a, type_t b)$/;" f -stdin libc/include/stdio.h /^void* stdin;$/;" v -stdin sysroot/usr/include/stdio.h /^void* stdin;$/;" v -stdout libc/include/stdio.h /^void* stdout;$/;" v -stdout sysroot/usr/include/stdio.h /^void* stdout;$/;" v -sti kernel/include/system.h 14;" d -sti sysroot/usr/include/system.h 14;" d -strcmp libc/string/strcmp.c /^int strcmp(const char *s1, const char *s2)$/;" f -strlen libc/string/strlen.c /^size_t strlen(const char* string)$/;" f -strrev libc/string/strrev.c /^char *strrev(char *str)$/;" f -switch_task kernel/system/task.c /^void switch_task()$/;" f -syscall_handler kernel/system/task.c /^void syscall_handler(registers_t *regs)$/;" f -syscalls kernel/system/task.c /^void *syscalls[] = {$/;" v -t_regs kernel/include/system.h /^typedef struct t_regs {$/;" s -t_regs sysroot/usr/include/system.h /^typedef struct t_regs {$/;" s -t_regs_t kernel/include/system.h /^} t_regs_t; \/\/ task registers$/;" t typeref:struct:t_regs -t_regs_t sysroot/usr/include/system.h /^} t_regs_t; \/\/ task registers$/;" t typeref:struct:t_regs -tabstop kernel/drivers/vga.c /^int tabstop;$/;" v -task kernel/include/task.h /^typedef struct task {$/;" s -task sysroot/usr/include/task.h /^typedef struct task {$/;" s -task_t kernel/include/task.h /^} task_t;$/;" t typeref:struct:task -task_t sysroot/usr/include/task.h /^} task_t;$/;" t typeref:struct:task -testing_shell kernel/system/system.c /^static void testing_shell(char *str) $/;" f file: -tick kernel/arch/i386/pit.c /^int tick;$/;" v -timer_callback kernel/arch/i386/pit.c /^void timer_callback(__attribute__ ((unused)) registers_t *regs)$/;" f -trap kernel/arch/i386/include/gdt.h /^ uint16_t trap;$/;" m struct:tss_entry_struct -trap sysroot/usr/include/gdt.h /^ uint16_t trap;$/;" m struct:tss_entry_struct -tss_entry kernel/arch/i386/include/gdt.h /^tss_entry_t tss_entry;$/;" v -tss_entry sysroot/usr/include/gdt.h /^tss_entry_t tss_entry;$/;" v -tss_entry_struct kernel/arch/i386/include/gdt.h /^struct tss_entry_struct$/;" s -tss_entry_struct sysroot/usr/include/gdt.h /^struct tss_entry_struct$/;" s -tss_entry_t kernel/arch/i386/include/gdt.h /^typedef struct tss_entry_struct tss_entry_t; $/;" t typeref:struct:tss_entry_struct -tss_entry_t sysroot/usr/include/gdt.h /^typedef struct tss_entry_struct tss_entry_t; $/;" t typeref:struct:tss_entry_struct -tss_flush kernel/arch/i386/descriptor_tables.asm /^tss_flush:$/;" l -type_t kernel/include/system.h /^typedef void* type_t;$/;" t -type_t sysroot/usr/include/system.h /^typedef void* type_t;$/;" t -uarch_t kernel/include/icxxabi.h /^typedef unsigned uarch_t;$/;" t -uarch_t sysroot/usr/include/icxxabi.h /^typedef unsigned uarch_t;$/;" t -unhandled_interrupt kernel/arch/i386/idt.c /^static void unhandled_interrupt(__attribute__((unused)) registers_t *regs)$/;" f file: -update_time kernel/system/time.c /^void update_time()$/;" f -use_frame kernel/arch/i386/pmm.c /^void use_frame(uint32_t addr)$/;" f -user kernel/system/system.c /^char user[20];$/;" v -useresp kernel/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -useresp sysroot/usr/include/system.h /^ uint32_t eip, cs, eflags, useresp, ss; \/\/ Pushed by the processor automatically.$/;" m struct:registers -vbe_control_info kernel/include/multiboot.h /^ uint32_t vbe_control_info;$/;" m struct:multiboot -vbe_control_info sysroot/usr/include/multiboot.h /^ uint32_t vbe_control_info;$/;" m struct:multiboot -vbe_interface_len kernel/include/multiboot.h /^ uint32_t vbe_interface_len;$/;" m struct:multiboot -vbe_interface_len sysroot/usr/include/multiboot.h /^ uint32_t vbe_interface_len;$/;" m struct:multiboot -vbe_interface_off kernel/include/multiboot.h /^ uint32_t vbe_interface_off;$/;" m struct:multiboot -vbe_interface_off sysroot/usr/include/multiboot.h /^ uint32_t vbe_interface_off;$/;" m struct:multiboot -vbe_interface_seg kernel/include/multiboot.h /^ uint32_t vbe_interface_seg;$/;" m struct:multiboot -vbe_interface_seg sysroot/usr/include/multiboot.h /^ uint32_t vbe_interface_seg;$/;" m struct:multiboot -vbe_mode kernel/include/multiboot.h /^ uint32_t vbe_mode;$/;" m struct:multiboot -vbe_mode sysroot/usr/include/multiboot.h /^ uint32_t vbe_mode;$/;" m struct:multiboot -vbe_mode_info kernel/include/multiboot.h /^ uint32_t vbe_mode_info;$/;" m struct:multiboot -vbe_mode_info sysroot/usr/include/multiboot.h /^ uint32_t vbe_mode_info;$/;" m struct:multiboot -version kernel/include/kernel_class.h /^ char version[30];$/;" m class:KernelClass -version sysroot/usr/include/kernel_class.h /^ char version[30];$/;" m class:KernelClass -version_name kernel/include/kernel_class.h /^ char version_name[50];$/;" m class:KernelClass -version_name sysroot/usr/include/kernel_class.h /^ char version_name[50];$/;" m class:KernelClass -vga_color kernel/include/vga.h /^enum vga_color$/;" g -vga_color sysroot/usr/include/vga.h /^enum vga_color$/;" g -vga_memory kernel/drivers/vga.c /^uint16_t *vga_memory;$/;" v -vga_move_cursor kernel/drivers/vga.c /^void vga_move_cursor(int row, int column)$/;" f -vga_putchar kernel/drivers/vga.c /^void vga_putchar(char c)$/;" f -vga_putchar_color kernel/drivers/vga.c /^void vga_putchar_color(char c, enum vga_color fg)$/;" f -vga_putentryat kernel/drivers/vga.c /^void vga_putentryat(char c, uint8_t color, size_t x, size_t y)$/;" f -vga_scroll kernel/drivers/vga.c /^int vga_scroll(size_t *row)$/;" f -vga_set_tab kernel/drivers/vga.c /^void vga_set_tab(int size)$/;" f -vga_setcolor kernel/drivers/vga.c /^void vga_setcolor(enum vga_color fg, enum vga_color bg)$/;" f -vga_writestring kernel/drivers/vga.c /^void vga_writestring(const char* data)$/;" f -welcome kernel/init/init.c /^void welcome() {$/;" f -write kernel/drivers/io.c /^int write(const char *buf, size_t len)$/;" f -write_char kernel/drivers/io.c /^int write_char(const char c)$/;" f -write_cr0 kernel/arch/i386/page.asm /^write_cr0:$/;" l -write_cr3 kernel/arch/i386/page.asm /^write_cr3:$/;" l -write_tss kernel/arch/i386/gdt.c /^void write_tss(int32_t num, uint16_t ss0, uint32_t esp0)$/;" f -wstr_color kernel/drivers/vga.c /^void wstr_color(const char* data, enum vga_color fg)$/;" f -zero_division_handler kernel/arch/i386/handlers.c /^static void zero_division_handler(__attribute__((unused)) registers_t *regs)$/;" f file: -~KernelClass kernel/init/kernel_class.cpp /^KernelClass::~KernelClass()$/;" f class:KernelClass From 5cd5d3b5e9c6cb0b2fdc30a53d8ec6ed2a15fc76 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Tue, 29 Sep 2015 20:40:45 +0300 Subject: [PATCH 15/17] Implemented a simple shell system and stack protector. --- src/kernel/Makefile | 5 +- src/kernel/include/shell.h | 17 ++ src/kernel/include/system.h | 6 +- src/kernel/include/ui.h | 14 ++ src/kernel/init/main.cpp | 4 - src/kernel/system/shell.c | 63 ++++++++ src/kernel/system/stack_protector.c | 23 +++ src/kernel/system/system.c | 237 ---------------------------- src/kernel/system/time.c | 1 + src/kernel/system/ui.c | 74 +++++++++ src/libc/stdlib/abort.c | 4 +- 11 files changed, 199 insertions(+), 249 deletions(-) create mode 100644 src/kernel/include/shell.h create mode 100644 src/kernel/include/ui.h create mode 100644 src/kernel/system/shell.c create mode 100644 src/kernel/system/stack_protector.c create mode 100644 src/kernel/system/ui.c diff --git a/src/kernel/Makefile b/src/kernel/Makefile index ce3a3a7..4e30b83 100644 --- a/src/kernel/Makefile +++ b/src/kernel/Makefile @@ -12,7 +12,7 @@ EXEC_PREFIX?=$(PREFIX) BOOTDIR?=$(EXEC_PREFIX)/boot INCLUDEDIR?=$(PREFIX)/include -CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra +CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra -fstack-protector-all CPPFLAGS:=$(CPPFLAGS) -DBITMAP_FRAME_ALLOCATOR -D__is_photon_kernel -D_TEXTMODE -Iinclude -Iarch/i386/include -I../libc/include LDFLAGS:=$(LDFLAGS) LIBS:=$(LIBS) -nostdlib -lk -lgcc @@ -39,6 +39,9 @@ system/system.o \ system/time.o \ system/task.o \ system/heap.o \ +system/ui.o \ +system/shell.o \ +system/stack_protector.o \ CRTI_OBJ:=$(ARCHDIR)/crti.o CRTBEGIN_OBJ:=$(shell $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtbegin.o) diff --git a/src/kernel/include/shell.h b/src/kernel/include/shell.h new file mode 100644 index 0000000..a8f4c80 --- /dev/null +++ b/src/kernel/include/shell.h @@ -0,0 +1,17 @@ +#ifndef _shell_h +#define _shell_h + +#include +#include +#include +#include +#include + +typedef struct shell_cmd { + char *name; + void (*func)(void); +} shell_cmd_t; + +int shell(char *cmd); + +#endif diff --git a/src/kernel/include/system.h b/src/kernel/include/system.h index 4bd18e9..02496e1 100644 --- a/src/kernel/include/system.h +++ b/src/kernel/include/system.h @@ -59,6 +59,8 @@ typedef void* type_t; #include #include #include +#include +#include /* Kernel defines */ #define OS_Name "PhotonOS" @@ -88,9 +90,5 @@ extern uint32_t read_cr0(); /* Kernel system functions */ void panic(const char *msg, int line, char *file); void reboot(); -void shell(char *str); -void prompt(); -void welcome(); -void login(); #endif diff --git a/src/kernel/include/ui.h b/src/kernel/include/ui.h new file mode 100644 index 0000000..f784d07 --- /dev/null +++ b/src/kernel/include/ui.h @@ -0,0 +1,14 @@ +#ifndef _ui_h +#define _ui_h + +#include +#include +#include +#include +#include + +void prompt(); +void welcome(); +void login(); + +#endif diff --git a/src/kernel/init/main.cpp b/src/kernel/init/main.cpp index 8816315..44b1760 100644 --- a/src/kernel/init/main.cpp +++ b/src/kernel/init/main.cpp @@ -134,10 +134,6 @@ void kernel_init(multiboot *mboot_ptr, uint32_t init_stack) void kernel_main() { - sti(); - printk("\nPress any key to continue..."); - getch(); - welcome(); login(); prompt(); diff --git a/src/kernel/system/shell.c b/src/kernel/system/shell.c new file mode 100644 index 0000000..7b8a024 --- /dev/null +++ b/src/kernel/system/shell.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include + +void cmd_help() +{ + printk("""Help:\n \ +-> hw - print hardware info\n \ +-> color - change color of the screen\n \ +-> time - display the time\n \ +-> free - display info about memory\n \ +-> clear - clear screen\n \ +"""); +} + +void cmd_hw() +{ + +} + +void cmd_color() +{ + +} + +void cmd_time() +{ + print_time(); +} + +void cmd_free() +{ + +} + +void cmd_clear() +{ + clear_vga(); +} + +int cmd_limit = 6; + +shell_cmd_t cmd_table[] = { + {"help", cmd_help}, + {"hw", cmd_hw}, + {"color", cmd_color}, + {"time", cmd_time}, + {"free", cmd_free}, + {"clear", cmd_clear} +}; + +int shell(char *cmd) +{ + for (int i = 0; i < cmd_limit; i++) { + if (!strcmp(cmd, cmd_table[i].name)) { + cmd_table[i].func(); + return 0; + } + } + return 1; +} diff --git a/src/kernel/system/stack_protector.c b/src/kernel/system/stack_protector.c new file mode 100644 index 0000000..aa97798 --- /dev/null +++ b/src/kernel/system/stack_protector.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +#if UINT32_MAX == UINTPTR_MAX +#define STACK_CHK_GUARD 0xe2dee396 +#else +#define STACK_CHK_GUARD 0x595e9fbd94fda766 +#endif + +uintptr_t __stack_chk_guard = STACK_CHK_GUARD; + +__attribute__((noreturn)) +void __stack_chk_fail(void) +{ +#if __STDC_HOSTED__ + abort(); +#elif __is_photon_kernel + panic("Stack smashing detected", __LINE__, __FILE__); +#endif +} diff --git a/src/kernel/system/system.c b/src/kernel/system/system.c index 43df9ca..09b75eb 100644 --- a/src/kernel/system/system.c +++ b/src/kernel/system/system.c @@ -13,110 +13,6 @@ #include #include -char user[20]; -char machine[30]; - -extern mem_heap_t *kernel_heap; -extern int mseconds; -extern int seconds; -extern int minutes; -extern int hours; -extern void *stdin; - -static void testing_shell(char *str) -{ - - while (true) { - printk("\nEnter test name> "); - gets(str); - - if (!strcmp(str, "exit")) { - break; - } else if (!strcmp(str, "print-stdin")) { - printk("%s\n", (uint8_t*)stdin); - } else if (!strcmp(str, "size")) { - printk("Sizes:\n"); - printk("Char: %d\nInt: %d\nFloat: %d\nSize_t: %d\n", sizeof(char), sizeof(int), sizeof(float), sizeof(size_t)); - printk("Kernel:\n"); - printk("Start: %x\nEnd: %x\n", (size_t)&kernel_start, (size_t)&kernel_end); - //printk("RAM: %d MB\n", mem_size_mb); - } else if (!strcmp(str, "page-fault")) { - printk("Test fault...\n"); - uint32_t *ptr = (uint32_t*)0xA123142300; - *ptr = 432; - printk("%d\n", *ptr); - } else if (!strcmp(str, "address")) { - printk("This is a test of memory manager. Warning! You are in kernel mode!\n"); - printk("Kernel:\n"); - printk("Start: %x\nEnd: %x\n", (size_t)&kernel_start, (size_t)&kernel_end); - getch(); - printk("stack_top: %x\n", stack_top); - printk("&stack_top: %x\n", &stack_top); - getch(); - - int *num = (int*) kmalloc(sizeof(int), 0, 0); - *num = 0x123ABC; - printk("num: %x\n", num); - printk("&num: %x\n", &num); - printk("*num: %x\n", *num); - - int snum = 0xABC123; - printk("snum: %x\n", snum); - printk("&snum: %x\n", &snum); - getch(); - - printk("Kernel:\n"); - printk("Start: %x\nEnd: %x\n", (size_t)&kernel_start, (size_t)&kernel_end); - getch(); - printk("stack_top: %x\n", stack_top); - printk("&stack_top: %x\n", &stack_top); - getch(); - - kfree(num); - } else if (!strcmp(str, "alloc")) { - printk("SIZE OF INT: %d\n", sizeof(int)); - int *a = (int *)kmalloc(sizeof(int), 0, 0); - *a = 6; - printk("a: %x\n", a); - printk("a: %x\n", *a); - - int *b = (int *)kmalloc(sizeof(int), 0, 0); - *b = 5; - printk("b: %x\n", b); - printk("b: %x\n", *b); - kfree(b); - - int *c = (int *)kmalloc(sizeof(int), 0, 0); - *c = 8; - printk("c: %x\n", c); - printk("c: %x\n", *c); - - kfree(a); - kfree(b); - kfree(c); - //------------------------------------------------------- - char *stmp = (char *)kmalloc(sizeof(char) * 11, 0, 0); - memcpy(stmp, "This is.\0", 9); - printk(stmp); - printk("\n&stmp[0]: %x &stmp[9]: %x\n", stmp, stmp + sizeof(char) * 11); - - kfree(stmp); - - char *tmp = (char *)kmalloc(sizeof(char) * 10, 0, 0); - memcpy(tmp, "THIS WAS.\0", 10); - printk(tmp); - printk("\n&tmp[0]: %x &tmp[9]: %x\n", tmp, tmp + sizeof(char) * 11); - - kfree(tmp); - } else if (!strcmp(str, "vga")) { - printk("Ab_C\b\b\nNew\tLineWasWritten NUM%x%s%c%c\n", 0x123ABC, "test", 'f', 55); - printk("Expected:\nAb\nNew LineWasWritten NUM0x123abctestf7\n"); - } else { - printk("Command not found!\n"); - } - } -} - void panic(const char *msg, int line, char *file) { cli(); @@ -133,136 +29,3 @@ void reboot() outb(0x64, 0xFE); hlt(); } - -void shell(char *str) { - if (!strcmp(str, "exit")) { - panic("Exit.", __LINE__, __FILE__); - } else if (!strcmp(str, "test")) { - testing_shell(str); - - } else if (!strcmp(str, "time")) { - print_time(); - printk("\n"); - - } else if (!strcmp(str, "tick")) { - printk("Tick: %d\n", get_tick()); - - } else if (!strcmp(str, "clock")) { - printk("WARN: no clock yet\n"); - } else if (!strcmp(str, "clear")) { - clear_vga(); - - } else if (!strcmp(str, "reset-clock")) { - hours = 0; - minutes = 0; - seconds = 0; - - } else if (!strcmp(str, "write")) { - char *to_write = (char*) kmalloc(sizeof(char) * 30, 0, 0); - size_t len = strlen("Let's write this...\n"); - - memcpy(to_write, "Let's write this...\n", len); - call(1, (uint32_t) to_write, (uint32_t) len, 0, 0, 0); - kfree(to_write); - - } else if (!strcmp(str, "reboot")) { - reboot(); - - } else if (!strcmp(str, "huge-alloc")) { - int *i = (void *) kmalloc(sizeof(int), 0, 0); - kfree(i); - - } else if (!strcmp(str, "usermode")) { - printk("CPU will jump to usermode, this will stop shell, because it is running only in kernel mode.\n"); - init_usermode(); - char s[] = "Welcome in usermode!\n"; - call(1, (uint32_t) s, (uint32_t) strlen(s), 0, 0, 0); - } else if (!strcmp(str, "sys-info")) { - printk("%s %s (%s) by %s.\nCopyright C 2015 %s.\nAll rights reserved.\n", OS_Name, Version, Relase_Date, Author, Author); - - } else if (!strcmp(str, "help")) { - printk("After kernel boots up, user must enter user name and machine name. Now, a shell has started. Here user can use some commands:\n"); - printk(" -> help -> display this page\n"); - printk(" -> time -> display current time\n"); - printk(" -> tick -> display current tick\n"); - printk(" -> clock -> start a clock that can be stoped when ESC is pressed\n"); - printk(" -> clear -> clear the screen\n"); - printk(" -> reset-clock -> set clock to 0\n"); - printk(" -> sys->info -> prints info about system\n"); - printk(" -> test -> enter into testing shell that allows testing kernel functions\n"); - printk(" -> exit -> close shell\n\n"); - - printk("Testing shell:\n"); - printk(" Tests avabile in testing shell:\n"); - printk(" -> exit -> close testing shell\n"); - printk(" -> print-stdin -> print all data from standard input\n"); - printk(" -> size -> print sizes of types, of kernel and RAM\n"); - printk(" -> page-fault -> generate page fault\n"); - printk(" -> address -> print addresses of all kernel variables and of some temporary\n"); - printk(" -> alloc -> test kmalloc and kfree\n"); - - } else { - printk("\"%s\" not recognized as internal command or program. Please try again.\n", str); - } -} - -void prompt() { - char cmd[1024]; - while (true) { - printk("%s@%s:$ ", user, machine); - gets(cmd); - shell(cmd); - } -} - -void welcome() { - clear_vga(); - - wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); - wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); - wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); - wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); - wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); - wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); - wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); - - wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); - wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | | | |\n", COLOR_YELLOW); - wstr_color(" | | | (___) |\n", COLOR_YELLOW); - wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); - - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk(" by Feraru Mihail"); - - getch(); - clear_vga(); -} - -void login() { - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - - printk("Log in please.\n"); - printk("Username: "); - gets(user); - printk("Machine: "); - gets(machine); - printk("Loged in!\n"); -} diff --git a/src/kernel/system/time.c b/src/kernel/system/time.c index 84bf032..6ab7855 100644 --- a/src/kernel/system/time.c +++ b/src/kernel/system/time.c @@ -55,4 +55,5 @@ void print_time() } else { printk("pm"); } + printk("\n"); } diff --git a/src/kernel/system/ui.c b/src/kernel/system/ui.c new file mode 100644 index 0000000..533e0d4 --- /dev/null +++ b/src/kernel/system/ui.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include + +char user[20]; +char machine[30]; + +void prompt() { + char cmd[1024]; + while (true) { + memset(cmd, 0, 1023); + printk("%s@%s:$ ", user, machine); + gets(cmd); + if (cmd[0] != 0) { + if(shell(cmd)) { + printk("Command '%s' not found.\n", cmd); + } + } + } +} + +void welcome() { + clear_vga(); + + wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); + wstr_color(" | ) ( || ( \\/| ( | ( \\/| ( ) || () () || ( \\/\n", COLOR_RED); + wstr_color(" | | _ | || (__ | | | | | | | || || || || (\\\n", COLOR_RED); + wstr_color(" | |( )| || __) | | | | | | | || |(_)| || __)\\\n", COLOR_RED); + wstr_color(" | || || || ( | | | | | | | || | | || (\\\n", COLOR_RED); + wstr_color(" | () () || (____/\\| (____/\\| (____/\\| (___) || ) ( || (____/\\\n", COLOR_RED); + wstr_color(" (_______)(_______/(_______/(_______/(_______)|/ \\|(_______/\n\n", COLOR_RED); + + wstr_color(" \\__ __/( ___ )\n", COLOR_YELLOW); + wstr_color(" ) ( | ( ) |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | | | |\n", COLOR_YELLOW); + wstr_color(" | | | (___) |\n", COLOR_YELLOW); + wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); + + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk(" by Feraru Mihail"); + + getch(); + clear_vga(); +} + +void login() { + wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); + + printk("Log in please.\n"); + printk("Username: "); + gets(user); + printk("Machine: "); + gets(machine); + printk("Loged in!\n"); +} diff --git a/src/libc/stdlib/abort.c b/src/libc/stdlib/abort.c index 6d5531e..20c03c8 100644 --- a/src/libc/stdlib/abort.c +++ b/src/libc/stdlib/abort.c @@ -11,9 +11,7 @@ void abort(void) // TODO: Properly implement abort(). exit(1); #elif defined(__is_photon_kernel) - // TODO: Add proper kernel panic. - printf("Kernel Panic: abort()\n"); - while ( 1 ) { } + panic("Kernel aborted!\n", __LINE__, __FILE__); #else #error "You need to implement abort() in this freestanding environment." #endif From 5ada762a1499777ba26575c9e5ed2a49a680d4e6 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Fri, 2 Oct 2015 15:09:58 +0300 Subject: [PATCH 16/17] Changed UI and finished 0.0.1 CORE version. --- src/kernel/arch/i386/pmm.c | 4 +++ src/kernel/arch/i386/vmm.c | 5 ++++ src/kernel/drivers/vga.c | 5 ++++ src/kernel/include/system.h | 4 +-- src/kernel/system/shell.c | 52 ++++++++++++++++++++++++++++++------- 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/kernel/arch/i386/pmm.c b/src/kernel/arch/i386/pmm.c index 4560aa8..205844c 100644 --- a/src/kernel/arch/i386/pmm.c +++ b/src/kernel/arch/i386/pmm.c @@ -26,6 +26,7 @@ int paging_enabled = 0; uint32_t nframes; uint32_t *frames; +uint32_t free_frames; void init_pmm(uint32_t mem_size) { @@ -34,6 +35,7 @@ void init_pmm(uint32_t mem_size) sizeof(uint32_t) * nframes % 8, 0, 0); + free_frames = nframes; for (uint32_t i = 0; i < nframes; i++) { free_bit(frames, i); @@ -55,6 +57,7 @@ uint32_t alloc_frame() int frame_index = find_frame(); if (frame_index != -1) { use_bit(frames, frame_index); + free_frames--; return frame_index * FRAME_SIZE; } @@ -66,6 +69,7 @@ void free_frame(uint32_t address) { uint32_t frame_index = address / FRAME_SIZE; free_bit(frames, frame_index); + free_frames++; } #endif diff --git a/src/kernel/arch/i386/vmm.c b/src/kernel/arch/i386/vmm.c index 54827f6..71cead8 100644 --- a/src/kernel/arch/i386/vmm.c +++ b/src/kernel/arch/i386/vmm.c @@ -12,6 +12,7 @@ page_directory_t *current_directory; multiboot *kernel_mboot; uint32_t kernel_init_stack; uint32_t init_esp; +uint32_t mapped_pages; static void map_area(uint32_t from_va, uint32_t to_va) { @@ -23,6 +24,8 @@ static void map_area(uint32_t from_va, uint32_t to_va) void init_vmm() { + mapped_pages = 0; + register_interrupt_handler(14, page_fault_handler); kernel_directory = kmalloc(sizeof(page_directory_t), 1, 0); @@ -70,6 +73,7 @@ void map(uint32_t va, uint32_t pa, uint32_t flags) current_directory->phys_tables[table_num] = phys | PAGE_READ_WRITE | PAGE_PRESENT; } current_directory->virt_tables[table_num]->pages[page_num] = pa | flags; + mapped_pages++; } void unmap(uint32_t va) @@ -80,6 +84,7 @@ void unmap(uint32_t va) current_directory->virt_tables[table_num]->pages[page_num] = 0x0; asm volatile ("invlpg (%0)" : : "a" (va)); + mapped_pages--; } void page_fault_handler(registers_t *regs) diff --git a/src/kernel/drivers/vga.c b/src/kernel/drivers/vga.c index 2e03155..76062b1 100644 --- a/src/kernel/drivers/vga.c +++ b/src/kernel/drivers/vga.c @@ -24,6 +24,8 @@ static const size_t VGA_WIDTH = 80; static const size_t VGA_HEIGHT = 25; #endif +extern void cmd_dbg(); + #ifdef _TEXTMODE uint8_t make_color(enum vga_color fg, enum vga_color bg) { @@ -121,6 +123,9 @@ void vga_putchar(char c) printk("[INFO] Halt char printed.\n STOP."); keep_running(); break; + case '`': + cmd_dbg(); + break; case 0: printk("!000!"); break; diff --git a/src/kernel/include/system.h b/src/kernel/include/system.h index 02496e1..361f8c5 100644 --- a/src/kernel/include/system.h +++ b/src/kernel/include/system.h @@ -64,8 +64,8 @@ typedef void* type_t; /* Kernel defines */ #define OS_Name "PhotonOS" -#define Version "v0.0.1cpp" -#define Relase_Date "16 July 2015" +#define Version "v0.0.1core" +#define Relase_Date "2 October 2015" #define Author "Feraru Mihail" #define sti() asm volatile("sti") diff --git a/src/kernel/system/shell.c b/src/kernel/system/shell.c index 7b8a024..150b045 100644 --- a/src/kernel/system/shell.c +++ b/src/kernel/system/shell.c @@ -4,11 +4,27 @@ #include #include +extern int detect_cpu(); + +extern uint32_t free_frames; +extern uint32_t mapped_pages; +extern mem_heap_t *kernel_heap; +extern uint32_t nframes; + +uint32_t get_memory() +{ + return ((nframes * 4) / 1024); +} + +uint32_t get_mapped_mem() +{ + return ((mapped_pages * 4) / 1024); +} + void cmd_help() { printk("""Help:\n \ -> hw - print hardware info\n \ --> color - change color of the screen\n \ -> time - display the time\n \ -> free - display info about memory\n \ -> clear - clear screen\n \ @@ -17,12 +33,7 @@ void cmd_help() void cmd_hw() { - -} - -void cmd_color() -{ - + detect_cpu(); } void cmd_time() @@ -32,7 +43,23 @@ void cmd_time() void cmd_free() { - + printk("Toatal memory: %d MiB (%d pages)\n", get_memory(), nframes); + printk("Mapped memory: %d MiB (%d pages) Free memory: %d MiB\n", + get_mapped_mem(), + mapped_pages, + get_memory() - get_mapped_mem()); + printk("Usable memory (allocated only for kernel): %d MiB = %d Bytes\n", + kernel_heap->mem_size / 1024 / 1024, + kernel_heap->mem_size); + printk("Usable memory (allocated for user-space): %d MiB (%s)\n", + 0, + "User-space isn't available!"); + printk("Allocated memory: %d MiB Free memory: %d MiB\n", + kernel_heap->mem_used / 1024 / 1024, + kernel_heap->mem_free / 1024 / 1024); + printk("Allocated memory: %d Bytes Free memory: %d Bytes\n", + kernel_heap->mem_used, + kernel_heap->mem_free); } void cmd_clear() @@ -40,15 +67,20 @@ void cmd_clear() clear_vga(); } +void cmd_dbg() +{ + printk("WHEN MULTI-TASKING WILL BE AVAILABLE THIS SHOULD GO INTO KERNEL THREAD BASED SHELL AND KILL USER SHELL TASK.\n"); +} + int cmd_limit = 6; shell_cmd_t cmd_table[] = { {"help", cmd_help}, {"hw", cmd_hw}, - {"color", cmd_color}, {"time", cmd_time}, {"free", cmd_free}, - {"clear", cmd_clear} + {"clear", cmd_clear}, + {"dbg", cmd_dbg} }; int shell(char *cmd) From 91cf0c4393e039897c07953e66ae8985e3c79413 Mon Sep 17 00:00:00 2001 From: JustBeYou Date: Fri, 2 Oct 2015 15:26:35 +0300 Subject: [PATCH 17/17] Added logo print to clear screen command. --- src/kernel/drivers/vga.c | 2 +- src/kernel/include/ui.h | 1 + src/kernel/system/shell.c | 1 + src/kernel/system/ui.c | 31 ++++++++++++++++++++----------- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/kernel/drivers/vga.c b/src/kernel/drivers/vga.c index 76062b1..12d5133 100644 --- a/src/kernel/drivers/vga.c +++ b/src/kernel/drivers/vga.c @@ -134,7 +134,7 @@ void vga_putchar(char c) break; } if (++col >= 80) { - col = 0; + col = -1; ++row; } vga_scroll(&row); diff --git a/src/kernel/include/ui.h b/src/kernel/include/ui.h index f784d07..e03c24a 100644 --- a/src/kernel/include/ui.h +++ b/src/kernel/include/ui.h @@ -9,6 +9,7 @@ void prompt(); void welcome(); +void logo(); void login(); #endif diff --git a/src/kernel/system/shell.c b/src/kernel/system/shell.c index 150b045..f2f1276 100644 --- a/src/kernel/system/shell.c +++ b/src/kernel/system/shell.c @@ -65,6 +65,7 @@ void cmd_free() void cmd_clear() { clear_vga(); + logo(); } void cmd_dbg() diff --git a/src/kernel/system/ui.c b/src/kernel/system/ui.c index 533e0d4..2fa38fa 100644 --- a/src/kernel/system/ui.c +++ b/src/kernel/system/ui.c @@ -22,6 +22,7 @@ void prompt() { } void welcome() { + vga_setcolor(COLOR_LIGHT_GREY, COLOR_GREEN); clear_vga(); wstr_color(" |\\ /|( ____ \\( \\ ( ____ \\( ___ )( )( ____ \\\n", COLOR_RED); @@ -41,7 +42,7 @@ void welcome() { wstr_color(" )_( (_______)\n\n", COLOR_YELLOW); wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\n", COLOR_BLUE); wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); @@ -52,19 +53,27 @@ void welcome() { printk(" by Feraru Mihail"); getch(); + vga_setcolor(COLOR_LIGHT_GREY, COLOR_BLACK); clear_vga(); } -void login() { - wstr_color(" _______ _______ _________ _______ _ _______ _______ \n", COLOR_BLUE); - wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\\\\n", COLOR_BLUE); - wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/\n", COLOR_BLUE); - wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ \n", COLOR_BLUE); - wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ )\n", COLOR_BLUE); - wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) |\n", COLOR_BLUE); - wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) |\n", COLOR_BLUE); - wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______)\n", COLOR_BLUE); - +void logo() +{ + vga_setcolor(COLOR_LIGHT_GREY, COLOR_RED); + wstr_color(" _______ _______ _________ _______ _ _______ _______ ", COLOR_BLUE); + wstr_color("( ____ )|\\ /|( ___ )\\__ __/( ___ )( ( /|( ___ )( ____ \\ ", COLOR_BLUE); + wstr_color("| ( )|| ) ( || ( ) | ) ( | ( ) || \\ ( || ( ) || ( \\/ ", COLOR_BLUE); + wstr_color("| (____)|| (___) || | | | | | | | | || \\ | || | | || (_____ ", COLOR_BLUE); + wstr_color("| _____)| ___ || | | | | | | | | || (\\ \\) || | | |(_____ ) ", COLOR_BLUE); + wstr_color("| ( | ( ) || | | | | | | | | || | \\ || | | | ) | ", COLOR_BLUE); + wstr_color("| ) | ) ( || (___) | | | | (___) || ) \\ || (___) |/\\____) | ", COLOR_BLUE); + wstr_color("|/ |/ \\|(_______) )_( (_______)|/ )_)(_______)\\_______) ", COLOR_BLUE); + vga_setcolor(COLOR_LIGHT_GREY, COLOR_BLACK); +} + +void login() +{ + logo(); printk("Log in please.\n"); printk("Username: "); gets(user);