From ff2db385a85c2cabb5b86c753801244ece6f6e4f Mon Sep 17 00:00:00 2001 From: lephe Date: Tue, 16 Jul 2019 18:34:10 -0400 Subject: [PATCH] TODO update and miscellaneous style --- TODO | 28 +++++++++++------------ include/gint/display-cg.h | 2 +- include/gint/display.h | 2 +- src/core/bootlog.c | 2 +- src/core/syscalls.S | 48 +++++++-------------------------------- src/cpg/cpg.c | 2 +- src/keysc/keysc.c | 6 ++--- src/r61524/r61524.c | 2 +- src/render-cg/topti.c | 4 ++-- src/render-fx/topti-asm.s | 1 + src/render-fx/topti.c | 6 ++--- 11 files changed, 35 insertions(+), 68 deletions(-) diff --git a/TODO b/TODO index db412ed..231df69 100644 --- a/TODO +++ b/TODO @@ -1,30 +1,30 @@ -On the bootlog. -* Better review of .pretext to make sure everything fits in 4k -* Move topti to .pretext to use it in the bootlog, also update() and dclear() -* Use topti in the error message for the missing mappings (hurray o/) -* Use a serious formatted printing function - Crucial, missing things. ! core: the four basic memory functions ! core: build an exception handler and a TLB miss handler ! core: gint_switch() (driver contexts on stack; arbitrary code?) +! bopti: fxcg50 version +! syscalls: fxcg50 BFile calls +! gray: the gray engine on fx9860g Tests to run. -* core: run the alignment/size automated tests +* core: run the alignment/size automated tests for memory functions * bopti: more sizes, gray * topti: all charsets, colors Completeness elements on existing code. -* keyboard: finish the interface -* clock: spread spectrum on fxcg50 +* core: use topti in the error message for missing mappings +* core: find the #ifdef FX9860G|FXCG50 that have a cross-platform def +* topti: support Unicode fonts +* hardware: fill in the HWMEM_FITTLB flag +* keyboard: think of extended functions +* cpg: spread spectrum on fxcg50 * bopti: blending modes for monochrome bitmaps (use topti assembler) * display: use more of topti's assembler in drect() * core: use cmp/str for memchr() -* stdio: serious formatted printing function -* timer: try putting the definitions in +* timer: try putting addresses in +* r61524: brightness control and clean the file Keep in mind. -* keyboard: make keysc.c@state static and review globals in the project * prizm: don't hardcode stack address in fxcg50.ld * prizm: detect P1 static RAM (stack) in TLB * core: prove and use qdiv10() instead of __sdivsi3 @@ -35,10 +35,8 @@ Keep in mind. * core: document the SH7305 PFC in Future directions. -* File management -* Gray engine +* A complete file system abstraction * Integrate overclock management -* A library for profiling with manual calls * Audio playback using Martin Poupe's method * Serial communication [SCIF] [SCIFA] * USB communication [USB] diff --git a/include/gint/display-cg.h b/include/gint/display-cg.h index e743a87..c5ca351 100644 --- a/include/gint/display-cg.h +++ b/include/gint/display-cg.h @@ -18,7 +18,7 @@ /* Expose the VRAM variable if GINT_NEED_VRAM is defined. It must always point to a 32-aligned buffer of size 177408. Any function can use it freely to perform rendering or store data when not drawing. Triple buffering is - already implemened in gint, see the dvram() function below. + already implemented in gint, see the dvram() function below. In this module, colors are in the 16-bit R5G6B5 format, as it is the format used by the display controller. */ diff --git a/include/gint/display.h b/include/gint/display.h index 963ab0f..9070163 100644 --- a/include/gint/display.h +++ b/include/gint/display.h @@ -186,7 +186,7 @@ void dsize(const char *str, font_t const * font, int *w, int *h); able to render several characters at once. This is not a printf()-family function so [str] cannot contain formats like - "%d" and you cannot pass aditional arguments. + "%d" and you cannot pass additional arguments. @x @y Coordinates of top-left corner of the rendered string @str String to display diff --git a/src/core/bootlog.c b/src/core/bootlog.c index 8fcd078..301dc98 100644 --- a/src/core/bootlog.c +++ b/src/core/bootlog.c @@ -41,7 +41,7 @@ static void print(int x, int y, const char *format, ...) va_list args; va_start(args, format); - vsprintf(str + 2, format, args); + vsnprintf(str + 2, 43, format, args); #ifdef FX9860G dtext(6 * (x-1) + 1, 8 * (y-1), str + 2, C_BLACK, C_WHITE); diff --git a/src/core/syscalls.S b/src/core/syscalls.S index c0d5d48..8c9f9a0 100644 --- a/src/core/syscalls.S +++ b/src/core/syscalls.S @@ -40,11 +40,7 @@ /* OS version */ ___os_version: - mov.l syscall_table, r2 - mov.l 1f, r0 - jmp @r2 - nop -1: .long 0x02ee + syscall(0x02ee) /* Dynamic allocation */ @@ -61,51 +57,27 @@ _realloc: # int BFile_Remove(const uint16_t *file) _BFile_Remove: - mov.l 1f, r0 - mov.l syscall_table, r1 - jmp @r1 - mov #0, r5 -1: .long 0x0439 + syscall(0x0439) # int BFile_Create(uint16_t *file, enum { file = 1, folder = 5 }, int *size) _BFile_Create: - mov.l 1f, r0 - mov.l syscall_table, r1 - jmp @r1 - nop -1: .long 0x0434 + syscall(0x0434) # int BFile_Open(const uint16_t *file, int mode) _BFile_Open: - mov.l 1f, r0 - mov.l syscall_table, r1 - jmp @r1 - mov #0, r6 -1: .long 0x042c + syscall(0x042c) # int BFile_Close(int handle) _BFile_Close: - mov.l 1f, r0 - mov.l syscall_table, r1 - jmp @r1 - nop -1: .long 0x042d + syscall(0x042d) # int BFile_Write(int handle, const void *ram_buffer, int even_size) _BFile_Write: - mov.l 1f, r0 - mov.l syscall_table, r1 - jmp @r1 - nop -1: .long 0x0435 + syscall(0x0435) # int BFile_Read(int handle, void *ram_buffer, int size, int whence) _BFile_Read: - mov.l 1f, r0 - mov.l syscall_table, r1 - jmp @r1 - nop -1: .long 0x0432 + syscall(0x0432) syscall_table: .long 0x80010070 @@ -117,11 +89,7 @@ syscall_table: /* OS version */ ___os_version: - mov.l syscall_table, r2 - mov.l 1f, r0 - jmp @r2 - nop -1: .long 0x1406 + syscall(0x1406) /* Dynamic allocation */ diff --git a/src/cpg/cpg.c b/src/cpg/cpg.c index 69f22d6..9f700bb 100644 --- a/src/cpg/cpg.c +++ b/src/cpg/cpg.c @@ -127,7 +127,7 @@ static void sh7305_probe(void) static const char *cpg_status(void) { static char status[18]; - sprintf(status, "I%3d B%3d P%3d C%c", + sprintf(status, "I%03d B%03d P%03d C%c", freq.Iphi_f / 1000000, freq.Bphi_f / 1000000, freq.Pphi_f / 1000000, diff --git a/src/keysc/keysc.c b/src/keysc/keysc.c index 2965ea7..094e681 100644 --- a/src/keysc/keysc.c +++ b/src/keysc/keysc.c @@ -24,7 +24,7 @@ get a correct result. As a consequence, if an event cannot be generated (whatever the reason), the driver's internal copy of the keyboard state must not be updated (probably the event will be re-emitted at the next scan). */ -GDATA volatile uint8_t state[12] = { 0 }; +GDATA static volatile uint8_t state[12] = { 0 }; /* A driver event, which is a change in a full row instead of a single key. */ typedef struct @@ -45,7 +45,7 @@ GDATA static int buffer_start = 0; GDATA static int buffer_end = 0; /* Current time, in keyboard-scanning ticks */ -GDATA int time = 0; +GDATA static int time = 0; /* buffer_push() - add an event in the keyboard buffer Returns non-zero if the event cannot be pushed. */ @@ -71,7 +71,7 @@ static int buffer_poll(driver_event_t *ev) } /* keysc_frame() - generate a round of events for the current frame */ -void keysc_frame(void) +static void keysc_frame(void) { GALIGNED(2) uint8_t scan[12] = { 0 }; diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index 4a6af39..b368b89 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -288,7 +288,7 @@ static const char *r61524_status(void) uint16_t dev = read(); static char str[8]; - sprintf(str, "%4xF-b", dev); + sprintf(str, "%04xF-b", dev); return str; } diff --git a/src/render-cg/topti.c b/src/render-cg/topti.c index 5bef618..aa588f0 100644 --- a/src/render-cg/topti.c +++ b/src/render-cg/topti.c @@ -27,8 +27,8 @@ font_t const * topti_font = &gint_font8x9; @dataw Glyph width @fg @bg Foreground and background colors */ GSECTION(".pretext") -void topti_glyph(uint16_t *vram, uint32_t const * data, int left, int top, - int width, int height, int dataw, int fg, int bg) +static void topti_glyph(uint16_t *vram, uint32_t const * data, int left, + int top, int width, int height, int dataw, int fg, int bg) { int index = top * dataw + left; diff --git a/src/render-fx/topti-asm.s b/src/render-fx/topti-asm.s index 11bac42..d590175 100644 --- a/src/render-fx/topti-asm.s +++ b/src/render-fx/topti-asm.s @@ -1,5 +1,6 @@ .global _topti_asm_text +.section .pretext # REGISTER ALLOCATION: # r0: x or ~x diff --git a/src/render-fx/topti.c b/src/render-fx/topti.c index 4ad5ef8..3b8b46c 100644 --- a/src/render-fx/topti.c +++ b/src/render-fx/topti.c @@ -11,7 +11,7 @@ font_t const * gint_default_font = &gint_font5x7; font_t const * topti_font = &gint_font5x7; /* topti_split(): Split glyph data into lines - This function splits the data from [glyph] inyo lines and writes a bit of + This function splits the data from [glyph] into lines and writes a bit of each line in [operators]. This operation is meant to be used multiple times in a row, so [free] represents the number of free low bits in [operators]. @@ -22,11 +22,11 @@ font_t const * topti_font = &gint_font5x7; @operators VRAM operands Returns the number of free bits in [operators] after the operation. If it's - 0, call topti_draw() and reset the operators. If it's neative, call + 0, call topti_draw() and reset the operators. If it's negative, call topti_draw() then do another pass of topti_split() to recover the missing information. */ GSECTION(".pretext") -int topti_split(uint32_t const * glyph, int width, int height, int free, +static int topti_split(uint32_t const * glyph, int width, int height, int free, uint32_t *operators) { /* Extracts [width] bits on the left of [*glyph] */