From c55f0e48f8d54936cfb8c5f8f730788c34c4186d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Tue, 17 Dec 2013 14:16:29 +0000 Subject: [PATCH] fixed minor inconsistencies between headers and source files and between asm and C sources --- include/bas_string.h | 6 +++--- include/wait.h | 5 ++--- sources/bas_string.c | 9 +++++---- sources/exceptions.S | 27 --------------------------- sources/sysinit.c | 18 ++++++++++++------ sources/usb_mouse.c | 4 ++-- 6 files changed, 24 insertions(+), 45 deletions(-) diff --git a/include/bas_string.h b/include/bas_string.h index 9aa9e38..a0c3433 100644 --- a/include/bas_string.h +++ b/include/bas_string.h @@ -25,12 +25,12 @@ #include -extern int strncmp(const char *s1, const char *s2, int max); +extern int strncmp(const char *s1, const char *s2, size_t max); extern char *strcpy(char *dst, const char *src); -char *strncpy(char *dst, const char *src, int max); +char *strncpy(char *dst, const char *src, size_t max); extern size_t strlen(const char *str); extern char *strcat(char *dst, const char *src); -extern char *strncat(char *dst, const char *src, int max); +extern char *strncat(char *dst, const char *src, size_t max); extern int atoi(const char *c); extern void *memcpy(void *dst, const void *src, size_t n); extern void *memset(void *s, int c, size_t n); diff --git a/include/wait.h b/include/wait.h index 0f7d9c6..26a2e19 100644 --- a/include/wait.h +++ b/include/wait.h @@ -28,12 +28,11 @@ #define _WAIT_H_ #include + #if MACHINE_FIREBEE #include "firebee.h" #elif MACHINE_M5484LITE #include "m5484l.h" -#else -//#error unknown machine #endif /* MACHINE_FIREBEE */ #include "MCF5475.h" @@ -60,7 +59,7 @@ extern __inline__ void wait(uint32_t us) extern __inline__ bool waitfor(uint32_t us, checker_func condition) { int32_t target = MCF_SLT_SCNT(0) - (us * (SYSCLK / 1000)); - uint32_t res; + bool res; do { diff --git a/sources/bas_string.c b/sources/bas_string.c index a466bc5..d622153 100644 --- a/sources/bas_string.c +++ b/sources/bas_string.c @@ -55,7 +55,7 @@ void *memset(void *s, int c, size_t n) } -int strncmp(const char *s1, const char *s2, int max) +int strncmp(const char *s1, const char *s2, size_t max) { int i; int cmp; @@ -76,13 +76,14 @@ char *strcpy(char *dst, const char *src) return ptr; } -char *strncpy(char *dst, const char *src, int max) +char *strncpy(char *dst, const char *src, size_t max) { char *ptr = dst; while ((*dst++ = *src++) != '\0' && max-- >= 0); return ptr; } + int atoi(const char *c) { int value = 0; @@ -113,9 +114,9 @@ char *strcat(char *dst, const char *src) return ret; } -char *strncat(char *dst, const char *src, int max) +char *strncat(char *dst, const char *src, size_t max) { - int i; + size_t i; char *ret = dst; dst = &dst[strlen(dst)]; diff --git a/sources/exceptions.S b/sources/exceptions.S index 2001be4..3d027c9 100644 --- a/sources/exceptions.S +++ b/sources/exceptions.S @@ -69,7 +69,6 @@ #define MCF_PSC3_PSCTB_8BIT __MBAR+0x890C .global _vec_init - .global _asm_set_ipl // interrupt sources .equ INT_SOURCE_EPORT_EPF1,1 // edge port flag 1 @@ -1165,29 +1164,3 @@ video_chg_end: lea 7 * 4(sp),a7 rte #endif /* MACHINE_FIREBEE */ - -asm_set_ipl: -_asm_set_ipl: - link a6,#-8 // some space for locals - movem.l d6-d7,(sp) // save register - move.w sr,d7 // current sr - - move.l d7,d0 // prepare return value - andi.l #0x0700,d0 // maks out ipl bits - lsr.l #8,d0 // IPL - - move.l 8(a6),d6 // get argument - andi.l #0x07,d6 // least significant three bits - lsl.l #8,d6 // shift to make mask - - andi.l #0x0000f8ff,d7 // zero out current ipl - or.l d6,d7 // place new ipl in sr - move.w d7,sr - - movem.l (sp),d6-d7 // restore registers - lea 8(sp),sp // clear local variables - unlk a6 - - rts - - diff --git a/sources/sysinit.c b/sources/sysinit.c index dd572f1..5934fcb 100644 --- a/sources/sysinit.c +++ b/sources/sysinit.c @@ -203,7 +203,7 @@ void init_gpio(void) MCF_PAD_PAR_TIMER_PAR_TIN2(MCF_PAD_PAR_TIMER_PAR_TIN2_IRQ2) | MCF_PAD_PAR_TIMER_PAR_TOUT2; - // MCF_PAD_PAR_TIMER = 0b00101101; /* TIN3..2=#IRQ3..2;TOUT3..2=NORMAL */ + // MCF_PAD_PAR_TIMER = 0b00101101; TIN3..2=#IRQ3..2;TOUT3..2=NORMAL // ALLE OUTPUTS NORMAL LOW @@ -277,7 +277,9 @@ void init_serial(void) MCF_PSC3_PSCCR = 0x05; #endif /* MACHINE_FIREBEE */ - //MCF_INTC_ICR32 = 0x3F; //MAXIMALE PRIORITY/**********/ +#ifdef _NOT_USED_ + MCF_INTC_ICR32 = 0x3F; //MAXIMALE PRIORITY/**********/ +#endif /* _NOT_USED_ */ xprintf("\r\nserial interfaces initialization: finished\r\n"); } @@ -709,7 +711,10 @@ void dvi_on(void) { if (MCF_I2C_I2SR & MCF_I2C_I2SR_RXAK) /* next try if no acknowledge */ continue; - MCF_I2C_I2CR &= 0xef; //~MCF_I2C_I2CR_MTX; /* switch to receive mode */ +#ifdef _NOT_USED_ + MCH_I2C_I2CR &= ~MCF_I2C_I2CR_MTX; /* FIXME: not clear where this came from ... */ +#endif /* _NOT_USED_ */ + MCF_I2C_I2CR &= 0xef; /* ... this actually disables the I2C module... */ dummyByte = MCF_I2C_I2DR; /* dummy read */ wait_i2c_transfer_finished(); @@ -969,7 +974,6 @@ void initialize_hardware(void) init_serial(); xprintf("\n\n"); -//#ifdef _NOT_USED_ xprintf("%s BASIS system (BaS) v %d.%d (%s, %s)\r\n\r\n", #if MACHINE_FIREBEE "Firebee" @@ -979,7 +983,6 @@ void initialize_hardware(void) "unknown platform" #endif , MAJOR_VERSION, MINOR_VERSION, __DATE__, __TIME__); -//#endif /* _NOT_USED_ */ /* * Determine cause(s) of Reset @@ -1059,8 +1062,11 @@ void initialize_hardware(void) * install (preliminary) exception vectors */ setup_vectors(); + +#ifdef _NOT_USED_ /* make sure the handlers are called */ - // __asm__ __volatile__("dc.w 0xafff"); /* should trigger a line-A exception */ + __asm__ __volatile__("dc.w 0xafff"); /* should trigger a line-A exception */ +#endif /* _NOT_USED_ */ /* diff --git a/sources/usb_mouse.c b/sources/usb_mouse.c index f413d59..1a51952 100644 --- a/sources/usb_mouse.c +++ b/sources/usb_mouse.c @@ -126,7 +126,7 @@ static int usb_mouse_irq(struct usb_device *dev) char wheel = 0, buttons, old_buttons; mse_printf("USB MOUSE len:%d %02X %02X %02X %02X %02X %02X\r\n", dev->irq_act_len, new[0], new[1], new[2], new[3], new[4], new[5]); #ifdef CONFIG_USB_INTERRUPT_POLLING - level = asm_set_ipl(7); /* mask interrupts */ + level = set_ipl(7); /* mask interrupts */ #endif if((dev->irq_act_len >= 6) && (new[0] == 1)) /* report-ID */ { @@ -178,7 +178,7 @@ static int usb_mouse_irq(struct usb_device *dev) //if(mousevec != NULL) //call_mousevec(new, mousevec); #ifdef CONFIG_USB_INTERRUPT_POLLING - asm_set_ipl(level); + set_ipl(level); #endif old[0] = new[0]; old[1] = new[1];