*************************************** *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** CTR0.C #include "lib/my_stddef.h" extern int main(void); extern void __save_stuff(void); extern void __restore_stuff(void); extern void init_glados(void); extern void quit_glados(void); extern uint32_t bbss_ram; extern uint32_t bbss_rom; extern uint32_t bss_size; extern uint32_t bdata_ram; extern uint32_t bdata_rom; extern uint32_t data_size; extern uint32_t bglados_ram; extern uint32_t bglados_rom; extern uint32_t glados_size; __attribute__((section(".pretext.dump"))) int section_dump(void *bsection_ram, void *bsection_rom, int32_t section_size_dump) { uint32_t *ram_section = (uint32_t*)bsection_ram; uint32_t *rom_section = (uint32_t*)bsection_rom; int i; i = -1; while (++i < section_size_dump >> 2) ram_section[i] = rom_section[i]; } __attribute__((section(".pretext.dump"))) void section_reset (void *bsection_start, int32_t section_size) { uint32_t *rom_start; int i; i = -1; rom_start = (uint32_t*)bsection_start; while (++i < section_size >> 2) rom_start[i] = 0; } __attribute__((section(".pretext"))) int bootstrap(void) { int exit; section_reset(&bbss_rom, (int32_t)&bss_size); section_dump(&bdata_ram, &bdata_rom, (int32_t)((uint32_t)&bdata_rom - (uint32_t)&data_size)); section_dump(&bglados_ram, &bglados_rom, (int32_t)((uint32_t)&bglados_rom - (uint32_t)&glados_size)); init_glados(); __save_stuff(); exit = main(); // __restore_stuff(); quit_glados(); return (0); } *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** INTERRUPT.C #include "glados/7705.h" #include "glados/stream.h" #include "glados/syscall.h" #include "glados/screen.h" extern void put_nbr(int x, int y, uint32_t data, int pos); volatile uint32_t interrupt_counter; extern uint32_t glados_vbr; extern glados_t *glados; __attribute__((section(".glados.exept")))void exeption_handler(void) { interrupt_counter++; } __attribute__((section(".glados.tlb")))void tlb_handler(void) { interrupt_counter++; } __attribute__((section(".glados.interupt")))void interrupt_handler(void) { interrupt_counter++; } #ifdef INTERRUPT_DEBUG void show_interrupt_counter(void) { volatile char *irr0 = (void*)__IRR0; volatile char *irr1 = (void*)__IRR1; volatile char *irr2 = (void*)__IRR2; *irr0 = 0; *irr1 = 0; *irr2 = 0; interrupt_counter = 0; //__set_vbr((void*)&glados_vbr); while (1){ __clear_vram(glados->vram); put_nbr(0, 0, interrupt_counter, 0); __display_vram(glados->vram); } } #endif *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** LINKER.LD OUTPUT_ARCH(sh3) ENTRY(_bootstrap) MEMORY { rom : o = 0x00300200, l = 512k ram : o = 0x08100000, l = 8k my_ram : o = 0x8800d000, l = 12k } SECTIONS { .text : ALIGN(4) { *(.pretext) *(.pretext.*) *(.text) *(.text.*) } > rom .rodata : ALIGN(4) { *(.rodata) *(.rodata.*) _erodata = . ; } > rom .bss : ALIGN(4) { *(.bss) *(.bss.*) *(COMMON) _bss_size = SIZEOF(.bss) ; _bbss_rom = LOADADDR(.bss) ; } > ram .data : AT(_erodata + SIZEOF(.bss)) ALIGN (4){ _bdata_ram = . ; *(.data) *(.data.*) . = ALIGN(4) ; _data_size = LOADADDR(.data) + SIZEOF(.data) ; _bdata_rom = LOADADDR(.data) ; } > ram /* * RAM section witch set my interupt handler. * vbr + 0x100 -> exeption interupt. * vbr + 0x400 -> tlb miss. * vbr + 0x600 -> other interupt. */ .glados : AT(_erodata + SIZEOF(.bss) + SIZEOF(.data)) ALIGN(4) { . = ALIGN(0x100) ; _glados_vbr = . ; _bglados_ram = . ; . = _glados_vbr + 0x100 ; *(.glados.exept) . = _glados_vbr + 0x400 ; *(.glados.tlb) . = _glados_vbr + 0x600 ; *(.glados.interupt) . = ALIGN(4) ; _glados_size = LOADADDR(.glados) + SIZEOF(.glados) ; _bglados_rom = LOADADDR(.glados) ; } > my_ram .eh_frame : AT (_erodata + SIZEOF(.bss) + SIZEOF(.data) + SIZEOF(.glados)) ALIGN(4) { *(.eh_frame) *(.eh_frame.*) } > rom } *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** *************************************** MEMORY_MAP.TXT Archive member included to satisfy reference by file (symbol) lib//libmystdlib.a(lib_lmystdlib_my_malloc.o) build/bootstrap_ini_glados.o (_malloc) lib//libmystdlib.a(lib_lmystdlib_my_free.o) build/bootstrap_ini_glados.o (_free) lib//libmystdio.a(lib_lmystdio_my_printf.o) build/flash_save_stream.o (_my_printf) lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) lib//libmystdio.a(lib_lmystdio_my_printf.o) (_my_vfprintf) lib//libmystdio.a(lib_lmystdio_vfprintf_get_option.o) lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) (_vfprintf_get_flags) lib//libmystdio.a(lib_lmystdio_vfprintf_get_arg.o) lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) (_vfprintf_get_arg) lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) (_vfprintf_get_size) lib//libmystdio.a(lib_lmystdio_vfprintf_print_arg.o) lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) (_vfprintf_print_arg) lib//libmyunistd.a(lib_lmyunistd_write.o) build/shell_main.o (_write) /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_sdivsi3.o) lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) (___sdivsi3) /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_udivsi3.o) lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) (___udivsi3) Allocating common symbols Common symbol size file glados 0x4 build/bootstrap_ini_glados.o interrupt_counter 0x4 build/interrupt_handler.o Memory Configuration Name Origin Length Attributes rom 0x0000000000300200 0x0000000000080000 ram 0x0000000008100000 0x0000000000002000 my_ram 0x000000008800d000 0x0000000000003000 *default* 0x0000000000000000 0xffffffffffffffff Linker script and memory map LOAD build/interrupt_handler.o LOAD build/flash_save_stream.o LOAD build/flash_flash.o LOAD build/keyboard_driver.o LOAD build/screen_driver.o LOAD build/stream_display.o LOAD build/stream_update.o LOAD build/bootstrap_crt0.o LOAD build/bootstrap_ini_glados.o LOAD build/bootstrap_stuff.o LOAD build/shell_main.o LOAD build/syscall_syscall.o LOAD lib//libmystdlib.a LOAD lib//libmystdio.a LOAD lib//libmyunistd.a LOAD lib//libmystring.a LOAD /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a .text 0x0000000000300200 0x28f8 *(.pretext) .pretext 0x0000000000300200 0xbc build/bootstrap_crt0.o 0x0000000000300200 _bootstrap .pretext 0x00000000003002bc 0x46 build/bootstrap_stuff.o 0x00000000003002bc ___save_stuff 0x00000000003002e0 ___restore_stuff *(.pretext.*) .pretext.dump 0x0000000000300302 0x100 build/bootstrap_crt0.o 0x0000000000300302 _section_dump 0x0000000000300394 _section_reset *(.text) *fill* 0x0000000000300402 0x2 .text 0x0000000000300404 0x98 build/interrupt_handler.o 0x0000000000300404 _show_interrupt_counter .text 0x000000000030049c 0x180 build/flash_save_stream.o 0x0000000000300514 _save_global_output *fill* 0x000000000030061c 0x4 .text 0x0000000000300620 0x70 build/flash_flash.o 0x0000000000300620 ___Bfile_OpenFile 0x000000000030062c ___Bfile_WriteFile 0x0000000000300638 ___Bfile_ReadFile 0x0000000000300644 ___Bfile_CreateFile 0x0000000000300650 ___Bfile_DeleteFile 0x000000000030065c ___Bfile_CloseFile .text 0x0000000000300690 0xd4 build/keyboard_driver.o 0x0000000000300690 _key_down *fill* 0x0000000000300764 0xc .text 0x0000000000300770 0x90 build/screen_driver.o 0x0000000000300770 ___clear_vram 0x00000000003007b4 ___display_vram .text 0x0000000000300800 0x410 build/stream_display.o 0x0000000000300a18 _put_nbr 0x0000000000300af0 _display_stream .text 0x0000000000300c10 0x19c build/stream_update.o 0x0000000000300ce4 _update_stream .text 0x0000000000300dac 0x0 build/bootstrap_crt0.o .text 0x0000000000300dac 0x170 build/bootstrap_ini_glados.o 0x0000000000300dac _init_glados 0x0000000000300ef4 _quit_glados .text 0x0000000000300f1c 0x0 build/bootstrap_stuff.o .text 0x0000000000300f1c 0x1f0 build/shell_main.o 0x0000000000300f1c _main *fill* 0x000000000030110c 0x4 .text 0x0000000000301110 0x60 build/syscall_syscall.o 0x0000000000301110 ___free 0x000000000030111c ___malloc 0x0000000000301128 ___get_vram 0x0000000000301134 ___get_osinfo 0x0000000000301140 ___get_vbr 0x0000000000301144 ___set_vbr .text 0x0000000000301170 0x30 lib//libmystdlib.a(lib_lmystdlib_my_malloc.o) 0x0000000000301170 _malloc .text 0x00000000003011a0 0x2c lib//libmystdlib.a(lib_lmystdlib_my_free.o) 0x00000000003011a0 _free .text 0x00000000003011cc 0x38 lib//libmystdio.a(lib_lmystdio_my_printf.o) 0x00000000003011cc _my_printf .text 0x0000000000301204 0x2e0 lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) 0x0000000000301430 _my_vfprintf .text 0x00000000003014e4 0x698 lib//libmystdio.a(lib_lmystdio_vfprintf_get_option.o) 0x00000000003014e4 _vfprintf_get_flags 0x0000000000301636 _vfprintf_get_type 0x0000000000301876 _vfprintf_get_precision 0x0000000000301932 _vfprintf_get_base 0x00000000003019e8 _vfprintf_get_ouput_type .text 0x0000000000301b7c 0x31c lib//libmystdio.a(lib_lmystdio_vfprintf_get_arg.o) 0x0000000000301dce _vfprintf_get_arg .text 0x0000000000301e98 0x390 lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) 0x000000000030214c _vfprintf_get_size .text 0x0000000000302228 0x64c lib//libmystdio.a(lib_lmystdio_vfprintf_print_arg.o) 0x00000000003026a2 _vfprintf_print_arg .text 0x0000000000302874 0x178 lib//libmyunistd.a(lib_lmyunistd_write.o) 0x00000000003028e4 _write .text 0x00000000003029ec 0xa0 /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_sdivsi3.o) 0x00000000003029ec ___sdivsi3 .text 0x0000000000302a8c 0x6c /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_udivsi3.o) 0x0000000000302aae ___udivsi3 *(.text.*) .rodata 0x0000000000302af8 0xdde *(.rodata) .rodata 0x0000000000302af8 0x200 build/interrupt_handler.o .rodata 0x0000000000302cf8 0x23f build/flash_save_stream.o *fill* 0x0000000000302f37 0x1 .rodata 0x0000000000302f38 0x200 build/stream_display.o .rodata 0x0000000000303138 0x200 build/stream_update.o .rodata 0x0000000000303338 0x37b build/shell_main.o *fill* 0x00000000003036b3 0x1 .rodata 0x00000000003036b4 0x2 lib//libmystdio.a(lib_lmystdio_vfprintf_get_option.o) .rodata 0x00000000003036b6 0x20 lib//libmystdio.a(lib_lmystdio_vfprintf_print_arg.o) .rodata 0x00000000003036d6 0x200 lib//libmyunistd.a(lib_lmyunistd_write.o) *(.rodata.*) 0x00000000003038d6 _erodata = . .bss 0x0000000008100000 0x8 *(.bss) .bss 0x0000000008100000 0x0 build/interrupt_handler.o .bss 0x0000000008100000 0x0 build/flash_save_stream.o .bss 0x0000000008100000 0x0 build/flash_flash.o .bss 0x0000000008100000 0x0 build/keyboard_driver.o .bss 0x0000000008100000 0x0 build/screen_driver.o .bss 0x0000000008100000 0x0 build/stream_display.o .bss 0x0000000008100000 0x0 build/stream_update.o .bss 0x0000000008100000 0x0 build/bootstrap_crt0.o .bss 0x0000000008100000 0x0 build/bootstrap_ini_glados.o .bss 0x0000000008100000 0x0 build/bootstrap_stuff.o .bss 0x0000000008100000 0x0 build/shell_main.o .bss 0x0000000008100000 0x0 build/syscall_syscall.o .bss 0x0000000008100000 0x0 lib//libmystdlib.a(lib_lmystdlib_my_malloc.o) .bss 0x0000000008100000 0x0 lib//libmystdlib.a(lib_lmystdlib_my_free.o) .bss 0x0000000008100000 0x0 lib//libmystdio.a(lib_lmystdio_my_printf.o) .bss 0x0000000008100000 0x0 lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) .bss 0x0000000008100000 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_get_option.o) .bss 0x0000000008100000 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_get_arg.o) .bss 0x0000000008100000 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) .bss 0x0000000008100000 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_print_arg.o) .bss 0x0000000008100000 0x0 lib//libmyunistd.a(lib_lmyunistd_write.o) .bss 0x0000000008100000 0x0 /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_sdivsi3.o) .bss 0x0000000008100000 0x0 /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_udivsi3.o) *(.bss.*) *(COMMON) COMMON 0x0000000008100000 0x4 build/interrupt_handler.o 0x0000000008100000 _interrupt_counter COMMON 0x0000000008100004 0x4 build/bootstrap_ini_glados.o 0x0000000008100004 _glados 0x0000000000000008 _bss_size = SIZEOF (.bss) 0x0000000008100000 _bbss_rom = LOADADDR (.bss) .data 0x0000000008100008 0x0 load address 0x00000000003038de 0x0000000008100008 _bdata_ram = . *(.data) .data 0x0000000008100008 0x0 build/interrupt_handler.o .data 0x0000000008100008 0x0 build/flash_save_stream.o .data 0x0000000008100008 0x0 build/flash_flash.o .data 0x0000000008100008 0x0 build/keyboard_driver.o .data 0x0000000008100008 0x0 build/screen_driver.o .data 0x0000000008100008 0x0 build/stream_display.o .data 0x0000000008100008 0x0 build/stream_update.o .data 0x0000000008100008 0x0 build/bootstrap_crt0.o .data 0x0000000008100008 0x0 build/bootstrap_ini_glados.o .data 0x0000000008100008 0x0 build/bootstrap_stuff.o .data 0x0000000008100008 0x0 build/shell_main.o .data 0x0000000008100008 0x0 build/syscall_syscall.o .data 0x0000000008100008 0x0 lib//libmystdlib.a(lib_lmystdlib_my_malloc.o) .data 0x0000000008100008 0x0 lib//libmystdlib.a(lib_lmystdlib_my_free.o) .data 0x0000000008100008 0x0 lib//libmystdio.a(lib_lmystdio_my_printf.o) .data 0x0000000008100008 0x0 lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) .data 0x0000000008100008 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_get_option.o) .data 0x0000000008100008 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_get_arg.o) .data 0x0000000008100008 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) .data 0x0000000008100008 0x0 lib//libmystdio.a(lib_lmystdio_vfprintf_print_arg.o) .data 0x0000000008100008 0x0 lib//libmyunistd.a(lib_lmyunistd_write.o) .data 0x0000000008100008 0x0 /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_sdivsi3.o) .data 0x0000000008100008 0x0 /home/paquity/CASIO/sh3eb-elf/lib/gcc/sh3eb-elf/8.2.0/libgcc.a(_udivsi3.o) *(.data.*) 0x0000000008100008 . = ALIGN (0x4) 0x00000000003038de _data_size = (LOADADDR (.data) + SIZEOF (.data)) 0x00000000003038de _bdata_rom = LOADADDR (.data) .glados 0x000000008800d000 0x620 load address 0x00000000003038de 0x000000008800d000 . = ALIGN (0x100) 0x000000008800d000 _glados_vbr = . 0x000000008800d000 _bglados_ram = . 0x000000008800d100 . = (_glados_vbr + 0x100) *fill* 0x000000008800d000 0x100 *(.glados.exept) .glados.exept 0x000000008800d100 0x20 build/interrupt_handler.o 0x000000008800d100 _exeption_handler 0x000000008800d400 . = (_glados_vbr + 0x400) *fill* 0x000000008800d120 0x2e0 *(.glados.tlb) .glados.tlb 0x000000008800d400 0x20 build/interrupt_handler.o 0x000000008800d400 _tlb_handler 0x000000008800d600 . = (_glados_vbr + 0x600) *fill* 0x000000008800d420 0x1e0 *(.glados.interupt) .glados.interupt 0x000000008800d600 0x20 build/interrupt_handler.o 0x000000008800d600 _interrupt_handler 0x000000008800d620 . = ALIGN (0x4) 0x0000000000303efe _glados_size = (LOADADDR (.glados) + SIZEOF (.glados)) 0x00000000003038de _bglados_rom = LOADADDR (.glados) .rela.dyn 0x000000008800d620 0x0 load address 0x0000000000303f00 .rela.text 0x000000008800d620 0x0 build/interrupt_handler.o .rela.glados.exept 0x000000008800d620 0x0 build/interrupt_handler.o .rela.glados.tlb 0x000000008800d620 0x0 build/interrupt_handler.o .rela.glados.interupt 0x000000008800d620 0x0 build/interrupt_handler.o .rela.pretext 0x000000008800d620 0x0 build/interrupt_handler.o .eh_frame *(.eh_frame) *(.eh_frame.*) OUTPUT(glados.elf elf32-sh) .comment 0x0000000000000000 0x11 .comment 0x0000000000000000 0x11 build/interrupt_handler.o 0x12 (size before relaxing) .comment 0x0000000000000011 0x12 build/flash_save_stream.o .comment 0x0000000000000011 0x12 build/keyboard_driver.o .comment 0x0000000000000011 0x12 build/stream_display.o .comment 0x0000000000000011 0x12 build/stream_update.o .comment 0x0000000000000011 0x12 build/bootstrap_crt0.o .comment 0x0000000000000011 0x12 build/bootstrap_ini_glados.o .comment 0x0000000000000011 0x12 build/shell_main.o .comment 0x0000000000000011 0x12 lib//libmystdlib.a(lib_lmystdlib_my_malloc.o) .comment 0x0000000000000011 0x12 lib//libmystdlib.a(lib_lmystdlib_my_free.o) .comment 0x0000000000000011 0x12 lib//libmystdio.a(lib_lmystdio_my_printf.o) .comment 0x0000000000000011 0x12 lib//libmystdio.a(lib_lmystdio_my_vfprintf.o) .comment 0x0000000000000011 0x12 lib//libmystdio.a(lib_lmystdio_vfprintf_get_option.o) .comment 0x0000000000000011 0x12 lib//libmystdio.a(lib_lmystdio_vfprintf_get_arg.o) .comment 0x0000000000000011 0x12 lib//libmystdio.a(lib_lmystdio_vfprintf_get_size.o) .comment 0x0000000000000011 0x12 lib//libmystdio.a(lib_lmystdio_vfprintf_print_arg.o) .comment 0x0000000000000011 0x12 lib//libmyunistd.a(lib_lmyunistd_write.o)