diff --git a/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/ldscript.ld b/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/ldscript.ld index 3e12d15..d021efe 100644 --- a/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/ldscript.ld +++ b/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/ldscript.ld @@ -5,29 +5,42 @@ ENTRY(arch_startup) SECTIONS { - .code LOAD_ADDR : + .code 0x0 : { kernel_code_addr = .; /* instructions */ *?/boot/startup.asm.o ( .text* ) - + *?/boot/premjesti.o ( .text* ) + } + .instrukcije 0x100000 : AT(0x10000) + { *( .text* ) } - .data : + size_i = SIZEOF(.instrukcije); + xxxx = 0x10000; + + .data 0x500000: AT(0x50000) { kernel_data_addr = .; /* read only data (constants), initialized global variables */ * ( .rodata* .data* ) } - .bss : + size_data = SIZEOF(.data); + + .bss 0x800000: AT(0x80000) { *( .bss* COMMON* ) . = ALIGN (4096); } + .stog_u_slici 0x900000: AT(0x90000) + { + *( .stog ) + . = ALIGN (4096); + } /* * what with other sections generated with gcc (various versions)? * if optimizing for size discard them with: /DISCARD/ : { *(*) } diff --git a/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/premjesti.c b/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/premjesti.c new file mode 100644 index 0000000..ac67957 --- /dev/null +++ b/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/premjesti.c @@ -0,0 +1,24 @@ +#include + +void premjesti() +{ + extern char size_data; + extern size_t size_i; + size_t size_d = (size_t) &size_data; + size_t i; + char *od = (char *) 0x50000; + char *kamo = (char *) 0x500000; + + //for ( i = 0; i< size_d; i++ ) + // kamo[i] = od[i]; + + for ( i = 0; i< size_d; i++ ) + *kamo++ = *od++; + + od = (char *) 0x10000; + kamo = (char *) 0x100000; + size_d = (size_t) &size_i; + + for ( i = 0; i< size_d; i++ ) + *kamo++ = *od++; +} diff --git a/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/startup.S b/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/startup.S index 14828c9..4b7cd53 100644 --- a/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/startup.S +++ b/Chapter_02_Source_tree/04_Debugging/arch/i386/boot/startup.S @@ -5,7 +5,7 @@ #include /* stack, startup function */ -.extern system_stack, k_startup, arch_descriptors_init +.extern system_stack, k_startup, arch_descriptors_init, premjesti .section .text @@ -33,6 +33,7 @@ arch_startup: pushl $0 popf + call premjesti /* set up GDT, IDT */ call arch_descriptors_init diff --git a/Chapter_02_Source_tree/04_Debugging/arch/i386/config.ini b/Chapter_02_Source_tree/04_Debugging/arch/i386/config.ini index b2c3b06..6e9dbd1 100644 --- a/Chapter_02_Source_tree/04_Debugging/arch/i386/config.ini +++ b/Chapter_02_Source_tree/04_Debugging/arch/i386/config.ini @@ -41,7 +41,7 @@ U_STDERR = dev_null STACK_SIZE = 0x1000 # System memory (in Bytes) -SYSTEM_MEMORY = 0x800000 +SYSTEM_MEMORY = 0x8000000 # Library with utility functions (strings, lists, ...) diff --git a/Chapter_02_Source_tree/04_Debugging/arch/i386/drivers/vga_text.c b/Chapter_02_Source_tree/04_Debugging/arch/i386/drivers/vga_text.c index c199b2a..5bca4d2 100644 --- a/Chapter_02_Source_tree/04_Debugging/arch/i386/drivers/vga_text.c +++ b/Chapter_02_Source_tree/04_Debugging/arch/i386/drivers/vga_text.c @@ -19,8 +19,8 @@ volatile static unsigned char *video = (void *) VIDEO; /*! font color */ #define COLOR_WHITE 7 -#define COLOR_RED 4 -#define COLOR_GREEN 2 +#define COLOR_RED 7 +#define COLOR_GREEN 7 #define COLOR_DEFAULT COLOR_WHITE /*! diff --git a/Chapter_02_Source_tree/04_Debugging/kernel/startup.c b/Chapter_02_Source_tree/04_Debugging/kernel/startup.c index b81ec69..2870765 100644 --- a/Chapter_02_Source_tree/04_Debugging/kernel/startup.c +++ b/Chapter_02_Source_tree/04_Debugging/kernel/startup.c @@ -8,7 +8,8 @@ #include /*! kernel stack */ -uint8 system_stack [ STACK_SIZE ]; +uint8 system_stack [ STACK_SIZE ] +__attribute__((section(".stog"))); char system_info[] = OS_NAME ": " NAME_MAJOR ":" NAME_MINOR ", " "Version: " VERSION " (" ARCH ")"; @@ -31,14 +32,14 @@ void k_startup () k_stdout = &K_STDOUT; k_stdout->init (0); - kprintf ( "%s\n", system_info ); + //kprintf ( "%s\n", system_info ); stdio_init (); /* initialize standard output devices */ /* start desired program(s) */ - hello_world (); + //hello_world (); debug (); - kprintf ( "\nSystem halted!\n" ); + //kprintf ( "\nSystem halted!\n" ); halt (); } diff --git a/Chapter_02_Source_tree/04_Debugging/programs/debug/debug.c b/Chapter_02_Source_tree/04_Debugging/programs/debug/debug.c index 2d051ec..0c70cca 100644 --- a/Chapter_02_Source_tree/04_Debugging/programs/debug/debug.c +++ b/Chapter_02_Source_tree/04_Debugging/programs/debug/debug.c @@ -12,12 +12,15 @@ static int inc ( int n ) return n; } +int x = 5; +int y[100]; + int debug () { int a, b, c; - printf ( "Example program: [%s:%s]\n%s\n\n", __FILE__, __FUNCTION__, - debug_PROG_HELP ); + //printf ( "Example program: [%s:%s]\n%s\n\n", __FILE__, __FUNCTION__, +// debug_PROG_HELP ); a = 1; @@ -29,15 +32,23 @@ int debug () b += a + c; c += a + b; - printf ( "a=%d, b=%d, c=%d\n", a, b, c ); + //printf ( "a=%d, b=%d, c=%d\n", a, b, c ); #if 1 /* compile with 'debug=yes' and without */ - LOG ( WARN, "This is log entry with WARN relevance" ); + //LOG ( WARN, "This is log entry with WARN relevance" ); + LOG ( INFO, "Address of 'a' is %x", &a ); + LOG ( INFO, "Address of 'x' is %x", &x ); + LOG ( INFO, "Address of 'y' is %x", y ); + LOG ( INFO, "Address of 'debug' is %x", debug ); + extern int xxxx; + LOG ( INFO, "Address of 'xxxx' is %x", xxxx ); + LOG ( INFO, "Address of 'xxxx' is %x", &xxxx ); + - ASSERT_ERRNO_AND_RETURN ( TRUE, EINVAL ); + //ASSERT_ERRNO_AND_RETURN ( TRUE, EINVAL ); - ASSERT ( TRUE ); + //ASSERT ( TRUE ); //ASSERT ( FALSE ); #endif return 0;