From f91988cbc58a9ae5072b372255c6b8f209b34591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Thu, 25 Sep 2014 06:24:55 +0000 Subject: [PATCH] consistantly use bas_types.h instead of standard headers --- BaS_gcc/exe/basflash.c | 303 +++++++++++++------------ BaS_gcc/exe/basflash_start.c | 2 +- BaS_gcc/flash/flash.c | 297 +++++++++++++------------ BaS_gcc/flash/s19reader.c | 11 +- BaS_gcc/fs/ccsbcs.c | 2 +- BaS_gcc/fs/ff.c | 20 +- BaS_gcc/if/driver_vec.c | 3 +- BaS_gcc/include/MCF5475.h | 2 +- BaS_gcc/include/bas_types.h | 1 + BaS_gcc/include/cache.h | 3 +- BaS_gcc/include/diskio.h | 2 +- BaS_gcc/include/exceptions.h | 2 +- BaS_gcc/include/ff.h | 2 +- BaS_gcc/include/net_timer.h | 4 +- BaS_gcc/include/pci.h | 2 +- BaS_gcc/include/sd_card.h | 2 +- BaS_gcc/include/util.h | 32 +-- BaS_gcc/include/video.h | 4 +- BaS_gcc/include/x86debug.h | 4 +- BaS_gcc/kbd/ikbd.c | 416 +++++++++++++++++------------------ BaS_gcc/net/ip.c | 25 +-- BaS_gcc/net/net_timer.c | 43 ++-- BaS_gcc/net/nif.c | 11 +- BaS_gcc/net/tftp.c | 31 ++- BaS_gcc/pci/pci.c | 16 +- BaS_gcc/spi/dspi.c | 1 - BaS_gcc/spi/mmc.c | 3 +- BaS_gcc/sys/BaS.c | 3 +- BaS_gcc/sys/driver_mem.c | 3 +- BaS_gcc/sys/interrupts.c | 3 +- 30 files changed, 616 insertions(+), 637 deletions(-) diff --git a/BaS_gcc/exe/basflash.c b/BaS_gcc/exe/basflash.c index c909594..98c97a1 100644 --- a/BaS_gcc/exe/basflash.c +++ b/BaS_gcc/exe/basflash.c @@ -21,10 +21,9 @@ * Author: Markus Fröschle */ -#include -#include -#include "bas_string.h" +#include #include "bas_printf.h" +#include "bas_string.h" #include "diskio.h" #include "ff.h" #include "s19reader.h" @@ -220,190 +219,190 @@ static const int num_flash_areas = sizeof(flash_areas) / sizeof(struct romram); */ void amd_flash_sector_erase(int n) { - volatile AMD_FLASH_CELL status; + volatile AMD_FLASH_CELL status; - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0x555] = AMD_FLASH_CMD_DATA(0x80); - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); - pFlash[SADDR(n)] = AMD_FLASH_CMD_DATA(0x30); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0x80); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); + pFlash[SADDR(n)] = AMD_FLASH_CMD_DATA(0x30); - do - status = pFlash[SADDR(n)]; - while ((status & AMD_FLASH_CMD_DATA(0x80)) != AMD_FLASH_CMD_DATA(0x80)); + do + status = pFlash[SADDR(n)]; + while ((status & AMD_FLASH_CMD_DATA(0x80)) != AMD_FLASH_CMD_DATA(0x80)); - /* - * Place device in read mode - */ - pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); + /* + * Place device in read mode + */ + pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); } int amd_flash_erase(void *start, int bytes, void (*putchar)(int)) { - int i, ebytes = 0; + int i, ebytes = 0; - if (bytes == 0) - return 0; + if (bytes == 0) + return 0; - for (i = 0; i < AMD_FLASH_SECTORS; i++) - { - if (start >= (void *)((void *) pFlash + SOFFSET(i)) && - start <= (void *)((void *) pFlash + SOFFSET(i) + (SSIZE(i) - 1))) - { - break; - } - } + for (i = 0; i < AMD_FLASH_SECTORS; i++) + { + if (start >= (void *)((void *) pFlash + SOFFSET(i)) && + start <= (void *)((void *) pFlash + SOFFSET(i) + (SSIZE(i) - 1))) + { + break; + } + } - while (ebytes < bytes) - { - if (putchar != NULL) - { - putchar('.'); - } - amd_flash_sector_erase(i); - ebytes += SSIZE(i); - i++; - } + while (ebytes < bytes) + { + if (putchar != NULL) + { + putchar('.'); + } + amd_flash_sector_erase(i); + ebytes += SSIZE(i); + i++; + } - if (putchar != NULL) - { - putchar(10); /* LF */ - putchar(13); /* CR */ - } + if (putchar != NULL) + { + putchar(10); /* LF */ + putchar(13); /* CR */ + } - return ebytes; + return ebytes; } void amd_flash_program_cell(AMD_FLASH_CELL *dst, AMD_FLASH_CELL data) { - volatile AMD_FLASH_CELL status; - int retry; + volatile AMD_FLASH_CELL status; + int retry; - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xA0); - *dst = data; + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xA0); + *dst = data; - /* - * Wait for program operation to finish - * (Data# Polling Algorithm) - */ - retry = 0; - while (1) - { - status = *dst; - if ((status & AMD_FLASH_CMD_DATA(0x80)) == - (data & AMD_FLASH_CMD_DATA(0x80))) - { - break; - } - if (status & AMD_FLASH_CMD_DATA(0x20)) - { - status = *dst; - if ((status & AMD_FLASH_CMD_DATA(0x80)) == - (data & AMD_FLASH_CMD_DATA(0x80))) - { - break; - } - if (++retry > 1024) - { - break; - } - } - } + /* + * Wait for program operation to finish + * (Data# Polling Algorithm) + */ + retry = 0; + while (1) + { + status = *dst; + if ((status & AMD_FLASH_CMD_DATA(0x80)) == + (data & AMD_FLASH_CMD_DATA(0x80))) + { + break; + } + if (status & AMD_FLASH_CMD_DATA(0x20)) + { + status = *dst; + if ((status & AMD_FLASH_CMD_DATA(0x80)) == + (data & AMD_FLASH_CMD_DATA(0x80))) + { + break; + } + if (++retry > 1024) + { + break; + } + } + } } int amd_flash_program(void *dest, void *source, int bytes, int erase, void (*func)(void), void (*putchar)(int)) { - AMD_FLASH_CELL *src, *dst; - int hashi=1,hashj=0; - char hash[5]; + AMD_FLASH_CELL *src, *dst; + int hashi=1,hashj=0; + char hash[5]; - hash[0]=8; /* Backspace */ - hash[1]=124;/* "|" */ - hash[2]=47; /* "/" */ - hash[3]=45; /* "-" */ - hash[4]=92; /* "\" */ + hash[0]=8; /* Backspace */ + hash[1]=124;/* "|" */ + hash[2]=47; /* "/" */ + hash[3]=45; /* "-" */ + hash[4]=92; /* "\" */ - src = (AMD_FLASH_CELL *)source; - dst = (AMD_FLASH_CELL *)dest; + src = (AMD_FLASH_CELL *)source; + dst = (AMD_FLASH_CELL *)dest; - /* - * Place device in read mode - */ - pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); + /* + * Place device in read mode + */ + pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); - /* - * Erase device if necessary - */ - if (erase) - { - amd_flash_erase(dest, bytes, putchar); - } + /* + * Erase device if necessary + */ + if (erase) + { + amd_flash_erase(dest, bytes, putchar); + } - /* - * Program device - */ - while (bytes > 0) - { - amd_flash_program_cell(dst,*src); + /* + * Program device + */ + while (bytes > 0) + { + amd_flash_program_cell(dst,*src); - /* Verify Write */ - if (*dst == *src) - { - bytes -= AMD_FLASH_CELL_BYTES; - *dst++, *src++; + /* Verify Write */ + if (*dst == *src) + { + bytes -= AMD_FLASH_CELL_BYTES; + *dst++, *src++; - if ((putchar != NULL)) - { - /* Hash marks to indicate progress */ - if (hashj == 0x1000) - { - hashj = -1; - putchar(hash[0]); - putchar(hash[hashi]); + if ((putchar != NULL)) + { + /* Hash marks to indicate progress */ + if (hashj == 0x1000) + { + hashj = -1; + putchar(hash[0]); + putchar(hash[hashi]); - hashi++; - if (hashi == 5) - { - hashi=1; - } + hashi++; + if (hashi == 5) + { + hashi=1; + } - } - hashj++; - } - } - else - break; - } + } + hashj++; + } + } + else + break; + } - /* - * Place device in read mode - */ - pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); + /* + * Place device in read mode + */ + pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); - if (putchar != NULL) - { - putchar(hash[0]); - } + if (putchar != NULL) + { + putchar(hash[0]); + } - /* - * If a function was passed in, call it now - */ - if ((func != NULL)) - { - func(); - } + /* + * If a function was passed in, call it now + */ + if ((func != NULL)) + { + func(); + } - return ((int)src - (int)source); + return ((int)src - (int)source); } /* @@ -635,7 +634,7 @@ void basflash(void) if (strlen(fileinfo.fname) >= 4 && strncmp( &fileinfo.fname[strlen(fileinfo.fname) - - 4], srec_ext, 4) == 0) /* we have a .S19 file */ + - 4], srec_ext, 4) == 0) /* we have a .S19 file */ { /* * build path + filename diff --git a/BaS_gcc/exe/basflash_start.c b/BaS_gcc/exe/basflash_start.c index a554e26..621370b 100644 --- a/BaS_gcc/exe/basflash_start.c +++ b/BaS_gcc/exe/basflash_start.c @@ -21,7 +21,7 @@ * Author: Markus Fröschle */ -#include +#include static uint32_t ownstack[4096]; static uint32_t *stackptr = &ownstack[4095]; diff --git a/BaS_gcc/flash/flash.c b/BaS_gcc/flash/flash.c index 8127797..7efe859 100644 --- a/BaS_gcc/flash/flash.c +++ b/BaS_gcc/flash/flash.c @@ -1,4 +1,3 @@ -#include #include #include "bas_types.h" @@ -192,191 +191,191 @@ static const int num_flash_areas = sizeof(flash_areas) / sizeof(struct romram); */ void amd_flash_sector_erase(int n) { - volatile AMD_FLASH_CELL status; + volatile AMD_FLASH_CELL status; - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0x555] = AMD_FLASH_CMD_DATA(0x80); - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); - pFlash[SADDR(n)] = AMD_FLASH_CMD_DATA(0x30); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0x80); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); + pFlash[SADDR(n)] = AMD_FLASH_CMD_DATA(0x30); - do - status = pFlash[SADDR(n)]; - while ((status & AMD_FLASH_CMD_DATA(0x80)) != AMD_FLASH_CMD_DATA(0x80)); + do + status = pFlash[SADDR(n)]; + while ((status & AMD_FLASH_CMD_DATA(0x80)) != AMD_FLASH_CMD_DATA(0x80)); - /* - * Place device in read mode - */ - pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); + /* + * Place device in read mode + */ + pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); } int amd_flash_erase(void *start, int bytes, void (*putchar)(int)) { - int i, ebytes = 0; + int i, ebytes = 0; - if (bytes == 0) - return 0; + if (bytes == 0) + return 0; - for (i = 0; i < AMD_FLASH_SECTORS; i++) - { - if (start >= (void *)((void *) pFlash + SOFFSET(i)) && - start <= (void *)((void *) pFlash + SOFFSET(i) + (SSIZE(i) - 1))) - { - break; - } - } + for (i = 0; i < AMD_FLASH_SECTORS; i++) + { + if (start >= (void *)((void *) pFlash + SOFFSET(i)) && + start <= (void *)((void *) pFlash + SOFFSET(i) + (SSIZE(i) - 1))) + { + break; + } + } - while (ebytes < bytes) - { - if (putchar != NULL) - { - putchar('.'); - } - amd_flash_sector_erase(i); - ebytes += SSIZE(i); - i++; - } + while (ebytes < bytes) + { + if (putchar != NULL) + { + putchar('.'); + } + amd_flash_sector_erase(i); + ebytes += SSIZE(i); + i++; + } - if (putchar != NULL) - { - putchar(10); /* LF */ - putchar(13); /* CR */ - } + if (putchar != NULL) + { + putchar(10); /* LF */ + putchar(13); /* CR */ + } - return ebytes; + return ebytes; } void amd_flash_program_cell(AMD_FLASH_CELL *dst, AMD_FLASH_CELL data) { - volatile AMD_FLASH_CELL status; - int retry; + volatile AMD_FLASH_CELL status; + int retry; - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0x555] = AMD_FLASH_CMD_DATA(0xA0); - *dst = data; + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0x2AA] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0x555] = AMD_FLASH_CMD_DATA(0xA0); + *dst = data; - /* - * Wait for program operation to finish - * (Data# Polling Algorithm) - */ - retry = 0; - while (1) - { - status = *dst; - if ((status & AMD_FLASH_CMD_DATA(0x80)) == - (data & AMD_FLASH_CMD_DATA(0x80))) - { - break; - } - if (status & AMD_FLASH_CMD_DATA(0x20)) - { - status = *dst; - if ((status & AMD_FLASH_CMD_DATA(0x80)) == - (data & AMD_FLASH_CMD_DATA(0x80))) - { - break; - } - if (++retry > 1024) - { - break; - } - } - } + /* + * Wait for program operation to finish + * (Data# Polling Algorithm) + */ + retry = 0; + while (1) + { + status = *dst; + if ((status & AMD_FLASH_CMD_DATA(0x80)) == + (data & AMD_FLASH_CMD_DATA(0x80))) + { + break; + } + if (status & AMD_FLASH_CMD_DATA(0x20)) + { + status = *dst; + if ((status & AMD_FLASH_CMD_DATA(0x80)) == + (data & AMD_FLASH_CMD_DATA(0x80))) + { + break; + } + if (++retry > 1024) + { + break; + } + } + } } int amd_flash_program(void *dest, void *source, int bytes, int erase, void (*func)(void), void (*putchar)(int)) { - AMD_FLASH_CELL *src; + AMD_FLASH_CELL *src; AMD_FLASH_CELL *dst; - int hashi = 1; + int hashi = 1; int hashj = 0; - char hash[5]; + char hash[5]; - hash[0] = 8; /* Backspace */ - hash[1] = 124;/* "|" */ - hash[2] = 47; /* "/" */ - hash[3] = 45; /* "-" */ - hash[4] = 92; /* "\" */ + hash[0] = 8; /* Backspace */ + hash[1] = 124;/* "|" */ + hash[2] = 47; /* "/" */ + hash[3] = 45; /* "-" */ + hash[4] = 92; /* "\" */ - src = (AMD_FLASH_CELL *)source; - dst = (AMD_FLASH_CELL *)dest; + src = (AMD_FLASH_CELL *)source; + dst = (AMD_FLASH_CELL *)dest; - /* - * Place device in read mode - */ - pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); + /* + * Place device in read mode + */ + pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); - /* - * Erase device if necessary - */ - if (erase) - { - amd_flash_erase(dest, bytes, putchar); - } + /* + * Erase device if necessary + */ + if (erase) + { + amd_flash_erase(dest, bytes, putchar); + } - /* - * Program device - */ - while (bytes > 0) - { - amd_flash_program_cell(dst, *src); + /* + * Program device + */ + while (bytes > 0) + { + amd_flash_program_cell(dst, *src); - /* Verify Write */ - if (*dst == *src) - { - bytes -= AMD_FLASH_CELL_BYTES; - *dst++, *src++; + /* Verify Write */ + if (*dst == *src) + { + bytes -= AMD_FLASH_CELL_BYTES; + *dst++, *src++; - if ((putchar != NULL)) - { - /* Hash marks to indicate progress */ - if (hashj == 0x1000) - { - hashj = -1; - putchar(hash[0]); - putchar(hash[hashi]); + if ((putchar != NULL)) + { + /* Hash marks to indicate progress */ + if (hashj == 0x1000) + { + hashj = -1; + putchar(hash[0]); + putchar(hash[hashi]); - hashi++; - if (hashi == 5) - { - hashi = 1; - } + hashi++; + if (hashi == 5) + { + hashi = 1; + } - } - hashj++; - } - } - else - break; - } + } + hashj++; + } + } + else + break; + } - /* - * Place device in read mode - */ - pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); - pFlash[0] = AMD_FLASH_CMD_DATA(0x55); - pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); + /* + * Place device in read mode + */ + pFlash[0] = AMD_FLASH_CMD_DATA(0xAA); + pFlash[0] = AMD_FLASH_CMD_DATA(0x55); + pFlash[0] = AMD_FLASH_CMD_DATA(0xF0); - if (putchar != NULL) - { - putchar(hash[0]); - } + if (putchar != NULL) + { + putchar(hash[0]); + } - /* - * If a function was passed in, call it now - */ - if ((func != NULL)) - { - func(); - } + /* + * If a function was passed in, call it now + */ + if ((func != NULL)) + { + func(); + } - return ((int)src - (int)source); + return ((int)src - (int)source); } diff --git a/BaS_gcc/flash/s19reader.c b/BaS_gcc/flash/s19reader.c index f723af3..bfea3d2 100644 --- a/BaS_gcc/flash/s19reader.c +++ b/BaS_gcc/flash/s19reader.c @@ -23,8 +23,7 @@ * Copyright 2012 M. Froeschle */ -#include -#include +#include #include "bas_printf.h" #include "bas_string.h" @@ -345,10 +344,10 @@ static err_t verify(uint8_t *dst, uint8_t *src, uint32_t length) */ static inline err_t srec_memcpy(uint8_t *dst, uint8_t *src, size_t n) { - err_t e = OK; + err_t e = OK; - memcpy((void *) dst, (void *) src, n); - return e; + memcpy((void *) dst, (void *) src, n); + return e; } void srec_execute(char *flasher_filename) @@ -383,7 +382,7 @@ void srec_execute(char *flasher_filename) { /* next pass: copy data to destination */ xprintf("OK.\r\ncopy/flash data: "); - err = read_srecords(flasher_filename, &start_address, &length, srec_memcpy); + err = read_srecords(flasher_filename, &start_address, &length, srec_memcpy); if (err == OK) { /* next pass: verify data */ diff --git a/BaS_gcc/fs/ccsbcs.c b/BaS_gcc/fs/ccsbcs.c index 85a15c1..f7ee379 100644 --- a/BaS_gcc/fs/ccsbcs.c +++ b/BaS_gcc/fs/ccsbcs.c @@ -26,7 +26,7 @@ */ #include -#include +#include #if _CODE_PAGE == 437 #define _TBLDEF 1 diff --git a/BaS_gcc/fs/ff.c b/BaS_gcc/fs/ff.c index b23a093..2699aae 100644 --- a/BaS_gcc/fs/ff.c +++ b/BaS_gcc/fs/ff.c @@ -95,7 +95,7 @@ / Changed option name _FS_SHARE to _FS_LOCK. /---------------------------------------------------------------------------*/ -#include +#include #include /* FatFs configurations and declarations */ #include /* Declarations of low level disk I/O functions */ @@ -356,11 +356,11 @@ typedef struct { uint32_t get_fattime (void) { return ((uint32_t)(2012 - 1980) << 25) /* Year = 2012 */ - | ((uint32_t)1 << 21) /* Month = 1 */ - | ((uint32_t)1 << 16) /* Day_m = 1*/ - | ((uint32_t)0 << 11) /* Hour = 0 */ - | ((uint32_t)0 << 5) /* Min = 0 */ - | ((uint32_t)0 >> 1); /* Sec = 0 */ + | ((uint32_t)1 << 21) /* Month = 1 */ + | ((uint32_t)1 << 16) /* Day_m = 1*/ + | ((uint32_t)0 << 11) /* Hour = 0 */ + | ((uint32_t)0 << 5) /* Min = 0 */ + | ((uint32_t)0 >> 1); /* Sec = 0 */ } /* Character code support macros */ @@ -970,7 +970,7 @@ FRESULT remove_chain ( #if _USE_ERASE if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ ecl = nxt; - } else { /* End of contiguous clusters */ + } else { /* End of contiguous clusters */ rt[0] = clust2sect(fs, scl); /* Start sector */ rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ disk_ioctl(fs->drv, CTRL_ERASE_SECTOR, rt); /* Erase the block */ @@ -2190,7 +2190,7 @@ FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */ /* Get fsinfo if available */ if (fmt == FS_FAT32) { - fs->fsi_flag = 0; + fs->fsi_flag = 0; fs->fsi_sector = bsect + LD_WORD(fs->win+BPB_FSInfo); if (disk_read(fs->drv, fs->win, fs->fsi_sector, 1) == RES_OK && LD_WORD(fs->win+BS_55AA) == 0xAA55 && @@ -2721,7 +2721,7 @@ FRESULT f_close ( FATFS *fs = fp->fs;; res = validate(fp); if (res == FR_OK) { - res = dec_lock(fp->lockid); + res = dec_lock(fp->lockid); unlock_fs(fs, FR_OK); } #else @@ -2820,7 +2820,7 @@ FRESULT f_getcwd ( res = dir_read(&dj); if (res != FR_OK) break; if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); + res = dir_next(&dj, 0); } while (res == FR_OK); if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ if (res != FR_OK) break; diff --git a/BaS_gcc/if/driver_vec.c b/BaS_gcc/if/driver_vec.c index 2d8f496..5b93a51 100644 --- a/BaS_gcc/if/driver_vec.c +++ b/BaS_gcc/if/driver_vec.c @@ -23,8 +23,7 @@ * Author: Markus Fröschle */ -#include -#include +#include #include "version.h" #include "xhdi_sd.h" #include "dma.h" diff --git a/BaS_gcc/include/MCF5475.h b/BaS_gcc/include/MCF5475.h index 5ab1750..332d343 100644 --- a/BaS_gcc/include/MCF5475.h +++ b/BaS_gcc/include/MCF5475.h @@ -16,7 +16,7 @@ #ifndef __MCF5475_H__ #define __MCF5475_H__ -#include +#include /*** * MCF5475 Derivative Memory map definitions from linker command files: * __MBAR, __MMUBAR, __RAMBAR0, __RAMBAR0_SIZE, __RAMBAR1, __RAMBAR1_SIZE diff --git a/BaS_gcc/include/bas_types.h b/BaS_gcc/include/bas_types.h index c7e219c..4f692a1 100644 --- a/BaS_gcc/include/bas_types.h +++ b/BaS_gcc/include/bas_types.h @@ -30,5 +30,6 @@ #include #include +#include /* for sizeof() etc. */ #endif /* BAS_TYPES_H_ */ diff --git a/BaS_gcc/include/cache.h b/BaS_gcc/include/cache.h index 615c624..0136163 100644 --- a/BaS_gcc/include/cache.h +++ b/BaS_gcc/include/cache.h @@ -25,8 +25,7 @@ * */ -#include -#include +#include /* * CACR Cache Control Register diff --git a/BaS_gcc/include/diskio.h b/BaS_gcc/include/diskio.h index 55d4646..7f2217c 100644 --- a/BaS_gcc/include/diskio.h +++ b/BaS_gcc/include/diskio.h @@ -12,7 +12,7 @@ extern "C" { #define _USE_WRITE 1 /* 1: Enable disk_write function */ #define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ -#include +#include /* Status of Disk Functions */ diff --git a/BaS_gcc/include/exceptions.h b/BaS_gcc/include/exceptions.h index 832af03..06b7047 100644 --- a/BaS_gcc/include/exceptions.h +++ b/BaS_gcc/include/exceptions.h @@ -1,7 +1,7 @@ #ifndef _EXCEPTIONS_H_ #define _EXCEPTIONS_H_ -#include +#include static inline uint32_t set_ipl(uint32_t ipl) { diff --git a/BaS_gcc/include/ff.h b/BaS_gcc/include/ff.h index 544e5df..a4eb4a1 100644 --- a/BaS_gcc/include/ff.h +++ b/BaS_gcc/include/ff.h @@ -21,7 +21,7 @@ extern "C" { #endif -#include +#include #include /* FatFs configuration options */ #if _FATFS != _FFCONF diff --git a/BaS_gcc/include/net_timer.h b/BaS_gcc/include/net_timer.h index 26824fb..0fd571a 100644 --- a/BaS_gcc/include/net_timer.h +++ b/BaS_gcc/include/net_timer.h @@ -8,9 +8,7 @@ #ifndef _TIMER_H_ #define _TIMER_H_ -#include -#include -#include +#include typedef struct { diff --git a/BaS_gcc/include/pci.h b/BaS_gcc/include/pci.h index b00f9a7..2e5587d 100644 --- a/BaS_gcc/include/pci.h +++ b/BaS_gcc/include/pci.h @@ -21,7 +21,7 @@ * Author: Markus Fröschle */ -#include +#include #include "util.h" /* for swpX() */ #define PCI_MEMORY_OFFSET (0x80000000) diff --git a/BaS_gcc/include/sd_card.h b/BaS_gcc/include/sd_card.h index c3ac7b8..e8bba09 100644 --- a/BaS_gcc/include/sd_card.h +++ b/BaS_gcc/include/sd_card.h @@ -31,7 +31,7 @@ #define _SD_CARD_H_ #include -#include +#include extern void sd_card_init(void); diff --git a/BaS_gcc/include/util.h b/BaS_gcc/include/util.h index 5fb1a0d..004c4c4 100644 --- a/BaS_gcc/include/util.h +++ b/BaS_gcc/include/util.h @@ -25,7 +25,7 @@ #ifndef UTIL_H_ #define UTIL_H_ -#include +#include #define NOP() __asm__ __volatile__("nop\n\t" : : : "memory") @@ -59,7 +59,7 @@ static inline uint32_t swpl(uint32_t l) register uint32_t result asm("d0"); __asm__ __volatile__ - ( + ( "lea %[input],a0\n\t" \ "mvz.b 3(a0),%[output]\n\t" \ "lsl.l #8,%[output]\n\t" \ @@ -74,7 +74,7 @@ static inline uint32_t swpl(uint32_t l) ); return result; } - + /* * WORD swpw2(ULONG val); @@ -85,17 +85,17 @@ static inline uint32_t swpl(uint32_t l) #define swpw2(a) \ __extension__ \ ({unsigned long _tmp; \ - __asm__ __volatile__ \ - ("move.b (%1),%0\n\t" \ - "move.b 1(%1),(%1)\n\t" \ - "move.b %0,1(%1)\n\t" \ - "move.b 2(%1),%0\n\t" \ - "move.b 3(%1),2(%1)\n\t" \ - "move.b %0,3(%1)" \ - : "=d"(_tmp) /* outputs */ \ - : "a"(&a) /* inputs */ \ - : "cc", "memory" /* clobbered */ \ - ); \ + __asm__ __volatile__ \ + ("move.b (%1),%0\n\t" \ + "move.b 1(%1),(%1)\n\t" \ + "move.b %0,1(%1)\n\t" \ + "move.b 2(%1),%0\n\t" \ + "move.b 3(%1),2(%1)\n\t" \ + "move.b %0,3(%1)" \ + : "=d"(_tmp) /* outputs */ \ + : "a"(&a) /* inputs */ \ + : "cc", "memory" /* clobbered */ \ + ); \ }) /* @@ -144,10 +144,10 @@ __extension__ \ #define regsafe_call(addr) \ __extension__ \ ({__asm__ volatile ("lea -60(sp),sp\n\t" \ - "movem.l d0-d7/a0-a6,(sp)"); \ + "movem.l d0-d7/a0-a6,(sp)"); \ ((void (*) (void)) addr)(); \ __asm__ volatile ("movem.l (sp),d0-d7/a0-a6\n\t" \ - "lea 60(sp),sp"); \ + "lea 60(sp),sp"); \ }) diff --git a/BaS_gcc/include/video.h b/BaS_gcc/include/video.h index 8e81e3b..636a225 100644 --- a/BaS_gcc/include/video.h +++ b/BaS_gcc/include/video.h @@ -1,9 +1,7 @@ #ifndef _VIDEO_H_ #define _VIDEO_H_ -#include -#include -#include +#include #include "bas_printf.h" extern void video_init(void); diff --git a/BaS_gcc/include/x86debug.h b/BaS_gcc/include/x86debug.h index 9087cb6..f2fbea1 100644 --- a/BaS_gcc/include/x86debug.h +++ b/BaS_gcc/include/x86debug.h @@ -37,7 +37,7 @@ ****************************************************************************/ /* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/debug.h,v 1.4 2000/11/21 23:10:27 tsi Exp $ */ -#include +#include #include "bas_printf.h" /* @@ -135,7 +135,7 @@ #define SAVE_IP_CS(x,y) \ if (DEBUG_DECODE() | DEBUG_TRACECALL() | DEBUG_BREAK() \ - | DEBUG_IO_TRACE() | DEBUG_SAVE_IP_CS()) { \ + | DEBUG_IO_TRACE() | DEBUG_SAVE_IP_CS()) { \ M.x86.saved_cs = x; \ M.x86.saved_ip = y; \ } diff --git a/BaS_gcc/kbd/ikbd.c b/BaS_gcc/kbd/ikbd.c index 8ef42ab..e49146f 100644 --- a/BaS_gcc/kbd/ikbd.c +++ b/BaS_gcc/kbd/ikbd.c @@ -18,7 +18,7 @@ */ -#include +#include #include "bas_printf.h" #include "bas_string.h" @@ -42,298 +42,298 @@ static unsigned char wptr = 0, rptr = 0; // structure to keep track of ikbd state static struct { - unsigned char cmd; - unsigned char state; - unsigned char expect; + unsigned char cmd; + unsigned char state; + unsigned char expect; - // joystick state - unsigned char joystick[2]; + // joystick state + unsigned char joystick[2]; - // mouse state - unsigned short mouse_pos_x, mouse_pos_y; - unsigned char mouse_buttons; + // mouse state + unsigned short mouse_pos_x, mouse_pos_y; + unsigned char mouse_buttons; } ikbd; // #define IKBD_DEBUG void ikbd_init() { - // reset ikbd state - memset(&ikbd, 0, sizeof(ikbd)); - ikbd.state = IKBD_DEFAULT; + // reset ikbd state + memset(&ikbd, 0, sizeof(ikbd)); + ikbd.state = IKBD_DEFAULT; } static void enqueue(unsigned char b) { - if (((wptr + 1)&(QUEUE_LEN-1)) == rptr) - { - xprintf("IKBD: !!!!!!! tx queue overflow !!!!!!!!!\n"); - return; - } + if (((wptr + 1)&(QUEUE_LEN-1)) == rptr) + { + xprintf("IKBD: !!!!!!! tx queue overflow !!!!!!!!!\n"); + return; + } - tx_queue[wptr] = b; - wptr = (wptr + 1) & (QUEUE_LEN - 1); + tx_queue[wptr] = b; + wptr = (wptr + 1) & (QUEUE_LEN - 1); } // convert internal joystick format into atari ikbd format static unsigned char joystick_map2ikbd(unsigned in) { - unsigned char out = 0; + unsigned char out = 0; - if (in & JOY_UP) out |= 0x01; - if (in & JOY_DOWN) out |= 0x02; - if (in & JOY_LEFT) out |= 0x04; - if (in & JOY_RIGHT) out |= 0x08; - if (in & JOY_BTN1) out |= 0x80; + if (in & JOY_UP) out |= 0x01; + if (in & JOY_DOWN) out |= 0x02; + if (in & JOY_LEFT) out |= 0x04; + if (in & JOY_RIGHT) out |= 0x08; + if (in & JOY_BTN1) out |= 0x80; - return out; + return out; } // process inout from atari core into ikbd void ikbd_handle_input(unsigned char cmd) { - // expecting a second byte for command - if (ikbd.expect) - { - ikbd.expect--; + // expecting a second byte for command + if (ikbd.expect) + { + ikbd.expect--; - // last byte of command received - if (!ikbd.expect) - { - switch(ikbd.cmd) - { - case 0x07: // set mouse button action - xprintf("IKBD: mouse button action = %x\n", cmd); + // last byte of command received + if (!ikbd.expect) + { + switch(ikbd.cmd) + { + case 0x07: // set mouse button action + xprintf("IKBD: mouse button action = %x\n", cmd); - // bit 2: Mouse buttons act like keys (LEFT=0x74 & RIGHT=0x75) - if(cmd & 0x04) ikbd.state |= IKBD_STATE_MOUSE_BUTTON_AS_KEY; - else ikbd.state &= ~IKBD_STATE_MOUSE_BUTTON_AS_KEY; + // bit 2: Mouse buttons act like keys (LEFT=0x74 & RIGHT=0x75) + if(cmd & 0x04) ikbd.state |= IKBD_STATE_MOUSE_BUTTON_AS_KEY; + else ikbd.state &= ~IKBD_STATE_MOUSE_BUTTON_AS_KEY; - break; + break; - case 0x80: // ibkd reset - // reply "everything is ok" - enqueue(0xf0); - break; + case 0x80: // ibkd reset + // reply "everything is ok" + enqueue(0xf0); + break; - default: - break; - } - } + default: + break; + } + } - return; - } + return; + } - ikbd.cmd = cmd; + ikbd.cmd = cmd; - switch(cmd) - { - case 0x07: - xprintf("IKBD: Set mouse button action"); - ikbd.expect = 1; - break; + switch(cmd) + { + case 0x07: + xprintf("IKBD: Set mouse button action"); + ikbd.expect = 1; + break; - case 0x08: - xprintf("IKBD: Set relative mouse positioning"); - ikbd.state &= ~IKBD_STATE_MOUSE_DISABLED; - ikbd.state &= ~IKBD_STATE_MOUSE_ABSOLUTE; - break; + case 0x08: + xprintf("IKBD: Set relative mouse positioning"); + ikbd.state &= ~IKBD_STATE_MOUSE_DISABLED; + ikbd.state &= ~IKBD_STATE_MOUSE_ABSOLUTE; + break; - case 0x09: - xprintf("IKBD: Set absolute mouse positioning"); - ikbd.state &= ~IKBD_STATE_MOUSE_DISABLED; - ikbd.state |= IKBD_STATE_MOUSE_ABSOLUTE; - ikbd.expect = 4; - break; + case 0x09: + xprintf("IKBD: Set absolute mouse positioning"); + ikbd.state &= ~IKBD_STATE_MOUSE_DISABLED; + ikbd.state |= IKBD_STATE_MOUSE_ABSOLUTE; + ikbd.expect = 4; + break; - case 0x0b: - xprintf("IKBD: Set Mouse threshold"); - ikbd.expect = 2; - break; + case 0x0b: + xprintf("IKBD: Set Mouse threshold"); + ikbd.expect = 2; + break; - case 0x0f: - xprintf("IKBD: Set Y at bottom"); - ikbd.state |= IKBD_STATE_MOUSE_Y_BOTTOM; - break; + case 0x0f: + xprintf("IKBD: Set Y at bottom"); + ikbd.state |= IKBD_STATE_MOUSE_Y_BOTTOM; + break; - case 0x10: - xprintf("IKBD: Set Y at top"); - ikbd.state &= ~IKBD_STATE_MOUSE_Y_BOTTOM; - break; + case 0x10: + xprintf("IKBD: Set Y at top"); + ikbd.state &= ~IKBD_STATE_MOUSE_Y_BOTTOM; + break; - case 0x12: - xprintf("IKBD: Disable mouse"); - ikbd.state |= IKBD_STATE_MOUSE_DISABLED; - break; + case 0x12: + xprintf("IKBD: Disable mouse"); + ikbd.state |= IKBD_STATE_MOUSE_DISABLED; + break; - case 0x14: - xprintf("IKBD: Set Joystick event reporting"); - ikbd.state |= IKBD_STATE_JOYSTICK_EVENT_REPORTING; - break; + case 0x14: + xprintf("IKBD: Set Joystick event reporting"); + ikbd.state |= IKBD_STATE_JOYSTICK_EVENT_REPORTING; + break; - case 0x15: - xprintf("IKBD: Set Joystick interrogation mode"); - ikbd.state &= ~IKBD_STATE_JOYSTICK_EVENT_REPORTING; - break; + case 0x15: + xprintf("IKBD: Set Joystick interrogation mode"); + ikbd.state &= ~IKBD_STATE_JOYSTICK_EVENT_REPORTING; + break; - case 0x16: // interrogate joystick - // send reply - enqueue(0xfd); - enqueue(joystick_map2ikbd(ikbd.joystick[0])); - enqueue(joystick_map2ikbd(ikbd.joystick[1])); - break; + case 0x16: // interrogate joystick + // send reply + enqueue(0xfd); + enqueue(joystick_map2ikbd(ikbd.joystick[0])); + enqueue(joystick_map2ikbd(ikbd.joystick[1])); + break; - case 0x1a: - xprintf("IKBD: Disable joysticks"); - ikbd.state &= ~IKBD_STATE_JOYSTICK_EVENT_REPORTING; - break; + case 0x1a: + xprintf("IKBD: Disable joysticks"); + ikbd.state &= ~IKBD_STATE_JOYSTICK_EVENT_REPORTING; + break; - case 0x1c: - xprintf("IKBD: Interrogate time of day"); + case 0x1c: + xprintf("IKBD: Interrogate time of day"); - enqueue(0xfc); - enqueue(0x13); // year bcd - enqueue(0x03); // month bcd - enqueue(0x07); // day bcd - enqueue(0x20); // hour bcd - enqueue(0x58); // minute bcd - enqueue(0x00); // second bcd - break; + enqueue(0xfc); + enqueue(0x13); // year bcd + enqueue(0x03); // month bcd + enqueue(0x07); // day bcd + enqueue(0x20); // hour bcd + enqueue(0x58); // minute bcd + enqueue(0x00); // second bcd + break; - case 0x80: - xprintf("IKBD: Reset"); - ikbd.expect = 1; - ikbd.state = IKBD_DEFAULT; - break; + case 0x80: + xprintf("IKBD: Reset"); + ikbd.expect = 1; + ikbd.state = IKBD_DEFAULT; + break; - default: - xprintf("IKBD: unknown command: %x\n", cmd); - break; - } + default: + xprintf("IKBD: unknown command: %x\n", cmd); + break; + } } void ikbd_poll(void) { - static int mtimer = 0; - if (CheckTimer(mtimer)) - { - mtimer = GetTimer(10); + static int mtimer = 0; + if (CheckTimer(mtimer)) + { + mtimer = GetTimer(10); - // check for incoming ikbd data - EnableIO(); - SPI(UIO_IKBD_IN); + // check for incoming ikbd data + EnableIO(); + SPI(UIO_IKBD_IN); - while(SPI(0)) - ikbd_handle_input(SPI(0)); + while(SPI(0)) + ikbd_handle_input(SPI(0)); - DisableIO(); - } + DisableIO(); + } - // send data from queue if present - if(rptr == wptr) return; + // send data from queue if present + if(rptr == wptr) return; - // transmit data from queue - EnableIO(); - SPI(UIO_IKBD_OUT); - SPI(tx_queue[rptr]); - DisableIO(); + // transmit data from queue + EnableIO(); + SPI(UIO_IKBD_OUT); + SPI(tx_queue[rptr]); + DisableIO(); - rptr = (rptr + 1) & (QUEUE_LEN - 1); + rptr = (rptr + 1) & (QUEUE_LEN - 1); } void ikbd_joystick(unsigned char joystick, unsigned char map) { - // todo: suppress events for joystick 0 as long as mouse - // is enabled? + // todo: suppress events for joystick 0 as long as mouse + // is enabled? - if (ikbd.state & IKBD_STATE_JOYSTICK_EVENT_REPORTING) - { + if (ikbd.state & IKBD_STATE_JOYSTICK_EVENT_REPORTING) + { #ifdef IKBD_DEBUG - xprintf("IKBD: joy %d %x\n", joystick, map); + xprintf("IKBD: joy %d %x\n", joystick, map); #endif - // only report joystick data for joystick 0 if the mouse is disabled - if ((ikbd.state & IKBD_STATE_MOUSE_DISABLED) || (joystick == 1)) - { - enqueue(0xfe + joystick); - enqueue(joystick_map2ikbd(map)); - } + // only report joystick data for joystick 0 if the mouse is disabled + if ((ikbd.state & IKBD_STATE_MOUSE_DISABLED) || (joystick == 1)) + { + enqueue(0xfe + joystick); + enqueue(joystick_map2ikbd(map)); + } - if (!(ikbd.state & IKBD_STATE_MOUSE_DISABLED)) - { - // the fire button also generates a mouse event if - // mouse reporting is enabled - if ((map & JOY_BTN1) != (ikbd.joystick[joystick] & JOY_BTN1)) - { - // generate mouse event (ikbd_joystick_buttons is evaluated inside - // user_io_mouse) - ikbd.joystick[joystick] = map; - ikbd_mouse(0, 0, 0); - } - } - } + if (!(ikbd.state & IKBD_STATE_MOUSE_DISABLED)) + { + // the fire button also generates a mouse event if + // mouse reporting is enabled + if ((map & JOY_BTN1) != (ikbd.joystick[joystick] & JOY_BTN1)) + { + // generate mouse event (ikbd_joystick_buttons is evaluated inside + // user_io_mouse) + ikbd.joystick[joystick] = map; + ikbd_mouse(0, 0, 0); + } + } + } #ifdef IKBD_DEBUG - else - xprintf("IKBD: no monitor, drop joy %d %x\n", joystick, map); + else + xprintf("IKBD: no monitor, drop joy %d %x\n", joystick, map); #endif - // save state of joystick for interrogation mode - ikbd.joystick[joystick] = map; + // save state of joystick for interrogation mode + ikbd.joystick[joystick] = map; } void ikbd_keyboard(unsigned char code) { #ifdef IKBD_DEBUG - xprintf("IKBD: send keycode %x%s\n", code&0x7f, (code&0x80)?" BREAK":""); + xprintf("IKBD: send keycode %x%s\n", code&0x7f, (code&0x80)?" BREAK":""); #endif - enqueue(code); + enqueue(code); } void ikbd_mouse(uint8_t b, int8_t x, int8_t y) { - if (ikbd.state & IKBD_STATE_MOUSE_DISABLED) - return; + if (ikbd.state & IKBD_STATE_MOUSE_DISABLED) + return; - // joystick and mouse buttons are wired together in - // atari st - b |= (ikbd.joystick[0] & JOY_BTN1)?1:0; - b |= (ikbd.joystick[1] & JOY_BTN1)?2:0; + // joystick and mouse buttons are wired together in + // atari st + b |= (ikbd.joystick[0] & JOY_BTN1)?1:0; + b |= (ikbd.joystick[1] & JOY_BTN1)?2:0; - static unsigned char b_old = 0; - // monitor state of two mouse buttons - if (b != b_old) - { - // check if mouse buttons are supposed to be treated like keys - if (ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY) - { - // Mouse buttons act like keys (LEFT=0x74 & RIGHT=0x75) + static unsigned char b_old = 0; + // monitor state of two mouse buttons + if (b != b_old) + { + // check if mouse buttons are supposed to be treated like keys + if (ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY) + { + // Mouse buttons act like keys (LEFT=0x74 & RIGHT=0x75) - // handle left mouse button - if((b ^ b_old) & 1) ikbd_keyboard(0x74 | ((b&1)?0x00:0x80)); - // handle right mouse button - if((b ^ b_old) & 2) ikbd_keyboard(0x75 | ((b&2)?0x00:0x80)); - } - b_old = b; - } + // handle left mouse button + if((b ^ b_old) & 1) ikbd_keyboard(0x74 | ((b&1)?0x00:0x80)); + // handle right mouse button + if((b ^ b_old) & 2) ikbd_keyboard(0x75 | ((b&2)?0x00:0x80)); + } + b_old = b; + } #if 0 - if(ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY) - { - b = 0; - // if mouse position is 0/0 quit here - if(!x && !y) return; - } + if(ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY) + { + b = 0; + // if mouse position is 0/0 quit here + if(!x && !y) return; + } #endif - if (ikbd.state & IKBD_STATE_MOUSE_ABSOLUTE) - { - } - else - { - // atari has mouse button bits swapped - enqueue(0xf8|((b&1)?2:0)|((b&2)?1:0)); - enqueue(x); - enqueue((ikbd.state & IKBD_STATE_MOUSE_Y_BOTTOM)?-y:y); - } + if (ikbd.state & IKBD_STATE_MOUSE_ABSOLUTE) + { + } + else + { + // atari has mouse button bits swapped + enqueue(0xf8|((b&1)?2:0)|((b&2)?1:0)); + enqueue(x); + enqueue((ikbd.state & IKBD_STATE_MOUSE_Y_BOTTOM)?-y:y); + } } diff --git a/BaS_gcc/net/ip.c b/BaS_gcc/net/ip.c index c536908..2a82f96 100644 --- a/BaS_gcc/net/ip.c +++ b/BaS_gcc/net/ip.c @@ -6,11 +6,10 @@ * * Modifications: */ +#include #include "net.h" #include "bas_printf.h" #include "bas_string.h" -#include -#include #define IP_DEBUG @@ -44,7 +43,7 @@ uint8_t *ip_get_myip(IP_INFO *info) { return (uint8_t *) &info->myip[0]; } - dbg("info is NULL!\n\t"); + dbg("info is NULL!\n\t"); return 0; } @@ -74,9 +73,9 @@ uint8_t *ip_resolve_route(NIF *nif, IP_ADDR_P destip) info = nif_get_protocol_info(nif, ETH_FRM_IP); - if (memcmp(destip, bc, 4) == 0) + if (memcmp(destip, bc, 4) == 0) { - dbg("destip is broadcast address, no gateway needed\r\n"); + dbg("destip is broadcast address, no gateway needed\r\n"); return destip; } @@ -170,7 +169,7 @@ int ip_send(NIF *nif, uint8_t *dest, uint8_t *src, uint8_t protocol, NBUF *pNbuf route = ip_resolve_route(nif, dest); if (route == NULL) { - dbg("Unable to locate %d.%d.%d.%d\r\n", + dbg("Unable to locate %d.%d.%d.%d\r\n", dest[0], dest[1], dest[2], dest[3]); return 0; } @@ -178,9 +177,9 @@ int ip_send(NIF *nif, uint8_t *dest, uint8_t *src, uint8_t protocol, NBUF *pNbuf else { route = bc; - dbg("route = broadcast\r\n"); - dbg("nif = %p\r\n", nif); - dbg("nif->send = %p\r\n", nif->send); + dbg("route = broadcast\r\n"); + dbg("nif = %p\r\n", nif); + dbg("nif->send = %p\r\n", nif->send); } return nif->send(nif, route, &nif->hwa[0], ETH_FRM_IP, pNbuf); @@ -282,7 +281,7 @@ void ip_handler(NIF *nif, NBUF *pNbuf) */ ip_frame_hdr *ipframe; - dbg("packet received\r\n"); + dbg("packet received\r\n"); ipframe = (ip_frame_hdr *) &pNbuf->data[pNbuf->offset]; @@ -291,8 +290,8 @@ void ip_handler(NIF *nif, NBUF *pNbuf) */ if (!validate_ip_hdr(nif, ipframe)) { - dbg("not a valid IP packet!\r\n"); - + dbg("not a valid IP packet!\r\n"); + nbuf_free(pNbuf); return; } @@ -312,7 +311,7 @@ void ip_handler(NIF *nif, NBUF *pNbuf) udp_handler(nif,pNbuf); break; default: - dbg("no protocol handler registered for protocol %d\r\n", + dbg("no protocol handler registered for protocol %d\r\n", __FUNCTION__, IP_PROTOCOL(ipframe)); nbuf_free(pNbuf); break; diff --git a/BaS_gcc/net/net_timer.c b/BaS_gcc/net/net_timer.c index 50992c9..f8787a5 100644 --- a/BaS_gcc/net/net_timer.c +++ b/BaS_gcc/net/net_timer.c @@ -5,9 +5,8 @@ * * Notes: */ + #include "net_timer.h" -#include -#include #include "bas_printf.h" #include "MCF5475.h" #include "interrupts.h" @@ -43,12 +42,12 @@ int timer_default_isr(void *not_used, NET_TIMER *t) { (void) not_used; - /* - * Clear the pending event + /* + * Clear the pending event */ MCF_GPT_GMS(t->ch) = 0; - dbg("timer isr called for timer channel %d\r\n"); + dbg("timer isr called for timer channel %d\r\n"); /* * Clear the reference - the desired seconds have expired @@ -90,8 +89,8 @@ bool timer_set_secs(uint8_t ch, uint32_t secs) */ MCF_GPT_GMS(ch) = 0; - /* - * Get the timeout in seconds + /* + * Get the timeout in seconds */ timeout = (uint16_t)(secs * net_timer[ch].cnt); @@ -119,21 +118,21 @@ bool timer_set_secs(uint8_t ch, uint32_t secs) } uint32_t timer_get_reference(uint8_t ch) -{ +{ return (uint32_t) net_timer[ch].reference; } bool timer_init(uint8_t ch, uint8_t lvl, uint8_t pri) { - /* + /* * Initialize the timer to expire after one second - * + * * This routine should only be called by the project (board) specific * initialization code. */ if (!((ch <= 3) && (lvl <= 7) && (lvl >= 1) && (pri <= 7))) { - dbg("illegal parameters (ch=%d, lvl=%d, pri=%d)\r\n", ch, lvl, pri); + dbg("illegal parameters (ch=%d, lvl=%d, pri=%d)\r\n", ch, lvl, pri); return false; } @@ -143,7 +142,7 @@ bool timer_init(uint8_t ch, uint8_t lvl, uint8_t pri) */ MCF_GPT_GMS(ch) = 0; - /* + /* * Save off the channel, and interrupt lvl/pri information */ net_timer[ch].ch = ch; @@ -153,16 +152,16 @@ bool timer_init(uint8_t ch, uint8_t lvl, uint8_t pri) /* * Register the timer interrupt handler */ - if (!isr_register_handler(TIMER_VECTOR(ch), + if (!isr_register_handler(TIMER_VECTOR(ch), (int (*)(void *,void *)) timer_default_isr, - NULL, + NULL, (void *) &net_timer[ch]) ) { - dbg("could not register timer interrupt handler\r\n"); + dbg("could not register timer interrupt handler\r\n"); return false; } - dbg("timer handler registered\r\n", __FUNCTION__); + dbg("timer handler registered\r\n", __FUNCTION__); /* * Calculate the require CNT value to get a 1 second timeout @@ -172,9 +171,9 @@ bool timer_init(uint8_t ch, uint8_t lvl, uint8_t pri) * CNT = Clk Freq / PRE * * The system clock frequency is defined as SYSTEM_CLOCK and - * is given in MHz. We need to multiple it by 1000000 to get the - * true value. If we assume PRE to be the maximum of 0xFFFF, - * then the CNT value needed to achieve a 1 second timeout is + * is given in MHz. We need to multiple it by 1000000 to get the + * true value. If we assume PRE to be the maximum of 0xFFFF, + * then the CNT value needed to achieve a 1 second timeout is * given by: * * CNT = SYSTEM_CLOCK * (1000000/0xFFFF) @@ -182,10 +181,10 @@ bool timer_init(uint8_t ch, uint8_t lvl, uint8_t pri) net_timer[ch].pre = 0xFFFF; net_timer[ch].cnt = (uint16_t) ((SYSCLK / 1000) * (1000000 / 0xFFFF)); - /* - * Save off the appropriate mode select register value + /* + * Save off the appropriate mode select register value */ - net_timer[ch].gms = (0 + net_timer[ch].gms = (0 | MCF_GPT_GMS_TMS_GPIO | MCF_GPT_GMS_IEN | MCF_GPT_GMS_SC diff --git a/BaS_gcc/net/nif.c b/BaS_gcc/net/nif.c index c717d8f..767895c 100644 --- a/BaS_gcc/net/nif.c +++ b/BaS_gcc/net/nif.c @@ -11,9 +11,6 @@ #include "bas_types.h" #include "bas_printf.h" -#include -#include - #define DBG_NIF #ifdef DBG_NIF #define dbg(format, arg...) do { xprintf("DEBUG: %s(): " format, __FUNCTION__, ##arg); } while (0) @@ -56,13 +53,13 @@ void nif_protocol_handler(NIF *nif, uint16_t protocol, NBUF *pNbuf) { if (nif->protocol[index].protocol == protocol) { - dbg("call protocol handler for protocol %d at %p\r\n", protocol, + dbg("call protocol handler for protocol %d at %p\r\n", protocol, nif->protocol[index].handler); nif->protocol[index].handler(nif,pNbuf); return; } } - dbg("no protocol handler found for protocol %d\r\n", protocol); + dbg("no protocol handler found for protocol %d\r\n", protocol); } void *nif_get_protocol_info(NIF *nif, uint16_t protocol) @@ -87,12 +84,12 @@ int nif_bind_protocol(NIF *nif, uint16_t protocol, void (*handler)(NIF *,NBUF *) { /* * This function registers 'protocol' as a supported - * protocol in 'nif'. + * protocol in 'nif'. */ if (nif->num_protocol < (MAX_SUP_PROTO - 1)) { nif->protocol[nif->num_protocol].protocol = protocol; - nif->protocol[nif->num_protocol].handler = (void(*)(NIF *, NBUF *)) handler; + nif->protocol[nif->num_protocol].handler = (void(*)(NIF *, NBUF *)) handler; nif->protocol[nif->num_protocol].info = info; ++nif->num_protocol; diff --git a/BaS_gcc/net/tftp.c b/BaS_gcc/net/tftp.c index 43b85f2..f44d958 100644 --- a/BaS_gcc/net/tftp.c +++ b/BaS_gcc/net/tftp.c @@ -9,10 +9,7 @@ * */ -#include -#include -#include - +#include "bas_types.h" #include "bas_printf.h" #include "bas_string.h" #include "net.h" @@ -103,7 +100,7 @@ static int tftp_ack(uint16_t blocknum) nbuf_free(pNbuf); return result; -} +} static int tftp_error(uint16_t error_code, uint16_t server_port) { @@ -172,7 +169,7 @@ void tftp_handler(NIF *nif, NBUF *pNbuf) cnt = 0; } else - { + { /* Check the server's transfer ID */ if (tcxn.server_port != UDP_SOURCE(udpframe)) { @@ -274,10 +271,10 @@ void tftp_handler(NIF *nif, NBUF *pNbuf) void tftp_end(int success) { - /* - * Following a successful transfer the caller should pass in - * true, there should have been no ERROR packets received, and - * the connection should have been marked as closed by the + /* + * Following a successful transfer the caller should pass in + * true, there should have been no ERROR packets received, and + * the connection should have been marked as closed by the * tftp_in_char() routine. */ if (success && !tcxn.error && (tcxn.open == false)) @@ -411,10 +408,10 @@ int tftp_write(NIF *nif, char *fn, IP_ADDR_P server, uint32_t begin, uint32_t en /* Attempt to send the packet */ for (i = 0; i < 3; ++i) { - result = udp_send(tcxn.nif, - tcxn.server_ip, - tcxn.my_port, - tcxn.server_port, + result = udp_send(tcxn.nif, + tcxn.server_ip, + tcxn.my_port, + tcxn.server_port, pNbuf); if (result == 1) @@ -552,8 +549,8 @@ int tftp_in_char(void) if (tcxn.next_char != NULL) { - /* - * A buffer is already being worked on - grab next + /* + * A buffer is already being worked on - grab next * byte from it */ retval = *tcxn.next_char++; @@ -561,7 +558,7 @@ int tftp_in_char(void) { /* The buffer is depleted; add it back to the free queue */ pNbuf = (NBUF *)queue_remove(&tcxn.queue); - + nbuf_free(pNbuf); tcxn.next_char = NULL; } diff --git a/BaS_gcc/pci/pci.c b/BaS_gcc/pci/pci.c index 5eb8038..82dcaa3 100644 --- a/BaS_gcc/pci/pci.c +++ b/BaS_gcc/pci/pci.c @@ -26,7 +26,7 @@ #include #include "pci.h" -#include "stdint.h" +#include "bas_types.h" #include "bas_printf.h" #include "bas_string.h" #include "util.h" @@ -187,7 +187,7 @@ static int32_t pci_call_interrupt_chain(int32_t handle, int32_t data) void irq5_handler(void) { int32_t handle; - int32_t value = 0; + int32_t value = 0; int32_t newvalue; MCF_EPORT_EPFR |= (1 << 5); /* clear interrupt from edge port */ @@ -209,7 +209,7 @@ void irq5_handler(void) void irq7_handler(void) { int32_t handle; - int32_t value = 0; + int32_t value = 0; int32_t newvalue; MCF_EPORT_EPFR |= (1 << 7); @@ -776,11 +776,11 @@ static void pci_device_config(uint16_t bus, uint16_t device, uint16_t function) static uint32_t io_address = PCI_IO_OFFSET; uint16_t cr; - /* - * should make compiler happy (these are used only in debug builds) - */ - (void) value; - (void) il; + /* + * should make compiler happy (these are used only in debug builds) + */ + (void) value; + (void) il; /* determine pci handle from bus, device + function number */ handle = PCI_HANDLE(bus, device, function); diff --git a/BaS_gcc/spi/dspi.c b/BaS_gcc/spi/dspi.c index 457c5c6..de9cace 100644 --- a/BaS_gcc/spi/dspi.c +++ b/BaS_gcc/spi/dspi.c @@ -25,7 +25,6 @@ * Author: mfro */ -#include #include #include diff --git a/BaS_gcc/spi/mmc.c b/BaS_gcc/spi/mmc.c index f71a4ff..aee4ed9 100644 --- a/BaS_gcc/spi/mmc.c +++ b/BaS_gcc/spi/mmc.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -466,7 +465,7 @@ DSTATUS disk_initialize(uint8_t drv) { uint8_t buff[16]; res = disk_ioctl(0, MMC_GET_CSD, buff); - + if (res == RES_OK) { debug_printf("CSD of card:\r\n"); diff --git a/BaS_gcc/sys/BaS.c b/BaS_gcc/sys/BaS.c index fb6db1a..8e520a3 100644 --- a/BaS_gcc/sys/BaS.c +++ b/BaS_gcc/sys/BaS.c @@ -21,8 +21,7 @@ * Copyright 2012 M. Froeschle */ -#include -#include +#include #include "MCF5475.h" #include "startcf.h" diff --git a/BaS_gcc/sys/driver_mem.c b/BaS_gcc/sys/driver_mem.c index d334010..3163958 100644 --- a/BaS_gcc/sys/driver_mem.c +++ b/BaS_gcc/sys/driver_mem.c @@ -11,8 +11,7 @@ * option any later version. */ -#include -#include +#include #include "bas_string.h" #include "bas_printf.h" #include "usb.h" diff --git a/BaS_gcc/sys/interrupts.c b/BaS_gcc/sys/interrupts.c index f8a1431..3d109fa 100644 --- a/BaS_gcc/sys/interrupts.c +++ b/BaS_gcc/sys/interrupts.c @@ -23,8 +23,7 @@ * Author: Markus Fröschle */ -#include -#include +#include #include "MCF5475.h" #include "bas_utils.h" #include "bas_printf.h"