renamed a __kbd_state to __char_set and added note about gcc bs'ery

This commit is contained in:
shockrah 2019-12-05 01:38:57 -08:00
parent c3238b1dde
commit bfce52a11a

14
stlio.c
View File

@ -37,7 +37,7 @@ u32 write(const char* buffer, const u32 size) {
} }
// this is here to get around gcc's optimizations // this is here to get around gcc's optimizations
static void __kbd_state(u8* dest, u8 desire) { static void __char_set(u8* dest, u8 desire) {
*dest = desire; *dest = desire;
} }
@ -47,13 +47,15 @@ u32 read(char* buffer, u32 size) {
u8 state = 0; u8 state = 0;
while(bytes < size) { while(bytes < size) {
//if(pit_timer_ticks - kbd_time < 0x20) { // All of these calls to __char_set is to avoid gcc from optimizing things away and ruining intended behavior
// Basically gcc will tread all assignments here as one time deals so we have to cram that operation into a routine
__kbd_state(&state, kbd_state); // by itself, that way the compiler won't try to optimize and do the assignment once. instead it does the call
// every iteration
__char_set(&state, kbd_state);
if(pit_timer_ticks - kbd_time < 0x20 && state == KBD_RELEASE) { if(pit_timer_ticks - kbd_time < 0x20 && state == KBD_RELEASE) {
__kbd_state(&buffer[bytes], (u8)kbd_key); __char_set(&(buffer[bytes]), (u8)kbd_key);
bytes++; bytes++;
__kbd_state(&kbd_state, KBD_WAITING); // reset the kbd_state since we've now used it __char_set(&kbd_state, KBD_WAITING); // reset the kbd_state since we've now used it
putch(kbd_key); putch(kbd_key);
} }
pit_timer_wait(1); pit_timer_wait(1);