arm/gba/console: Fix warnings and clean up

This commit is contained in:
Joel Sherrill
2014-10-12 15:22:27 -05:00
parent 5ad38eacae
commit ff8922cfa5
2 changed files with 140 additions and 111 deletions

View File

@@ -3,6 +3,7 @@
* *
* This file contains the GBA conio I/O package. * This file contains the GBA conio I/O package.
*/ */
/* /*
* RTEMS GBA BSP * RTEMS GBA BSP
* *
@@ -118,7 +119,7 @@ void gba_gotoxy(int _x, int _y)
* @param y screen y coordinate * @param y screen y coordinate
* @return None * @return None
*/ */
void gba_putchar(char c, int textattr, int x, int y) static void gba_putchar(char c, int textattr, int x, int y)
{ {
int f = textattr & 0x0F; int f = textattr & 0x0F;
int b = textattr >> 4; int b = textattr >> 4;
@@ -127,12 +128,30 @@ void gba_putchar(char c, int textattr, int x, int y)
uint32_t *dest = (uint32_t *)&bg_bitmap4a[((y<<1) + y) << 1][x<<2]; uint32_t *dest = (uint32_t *)&bg_bitmap4a[((y<<1) + y) << 1][x<<2];
const uint32_t *src = (uint32_t *)&(font3x5[(int)c]); const uint32_t *src = (uint32_t *)&(font3x5[(int)c]);
uint32_t s; uint32_t s;
s = *src++; *dest = (fmask&s) | (bmask&~s); dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++; *dest = (fmask&s) | (bmask&~s); dest += GBA_LCD_WIDTH/sizeof(uint32_t); s = *src++;
s = *src++; *dest = (fmask&s) | (bmask&~s); dest += GBA_LCD_WIDTH/sizeof(uint32_t); *dest = (fmask&s) | (bmask&~s);
s = *src++; *dest = (fmask&s) | (bmask&~s); dest += GBA_LCD_WIDTH/sizeof(uint32_t); dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++; *dest = (fmask&s) | (bmask&~s); dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++; *dest = (fmask&s) | (bmask&~s); dest += GBA_LCD_WIDTH/sizeof(uint32_t); s = *src++;
*dest = (fmask&s) | (bmask&~s);
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++;
*dest = (fmask&s) | (bmask&~s);
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++;
*dest = (fmask&s) | (bmask&~s);
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++;
*dest = (fmask&s) | (bmask&~s);
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
s = *src++;
*dest = (fmask&s) | (bmask&~s);
dest += GBA_LCD_WIDTH/sizeof(uint32_t);
} }
@@ -152,7 +171,7 @@ void gba_textattr(int _attr)
* *
* @param _color backround color * @param _color backround color
* @return None * @return None
*
*/ */
void gba_textbackground(int _color) void gba_textbackground(int _color)
{ {
@@ -172,14 +191,14 @@ void gba_textcolor(int _color)
/** /**
* @brief gba_clearline function clear line nro y * @brief gba_clearline function clear line number y
* *
* Line is filled with spaces * Line is filled with spaces
* *
* @param y line number * @param y line number
* @return None * @return None
*/ */
void gba_clearline(int y) static void gba_clearline(int y)
{ {
int x; int x;
@@ -194,7 +213,7 @@ void gba_clearline(int y)
* @param None * @param None
* @return None * @return None
*/ */
void gba_nextline(void) static void gba_nextline(void)
{ {
_wherex = 0; _wherex = 0;
if (++_wherey >= H) { if (++_wherey >= H) {
@@ -226,7 +245,7 @@ void gba_clrscr(void)
* @param _c character code * @param _c character code
* @return None * @return None
*/ */
void gba_put(char _c) static void gba_put(char _c)
{ {
/* We have save some memory with reduced fonts */ /* We have save some memory with reduced fonts */
_c = _c & 0x7F; /* no extened chars */ _c = _c & 0x7F; /* no extened chars */
@@ -335,8 +354,7 @@ void gba_initconio(void)
void gba_textmode(int _mode) void gba_textmode(int _mode)
{ {
switch (_mode) { switch (_mode) {
case CO60: case CO60: {
{
gba_initconio(); gba_initconio();
break; break;
} }
@@ -350,9 +368,10 @@ void gba_textmode(int _mode)
* @param count loop counter * @param count loop counter
* @return None * @return None
*/ */
void delay_loop(unsigned int count) static void delay_loop(unsigned int count)
{ {
int i; int i;
for (i = 0; i<count; i++) i = i; for (i = 0; i<count; i++) i = i;
} }
@@ -360,7 +379,8 @@ static unsigned char inputch = ASCII_CR; /**< input character value */
/** /**
* @brief gba_getch function read char from game pad keys * @brief gba_getch function read char from game pad keys
* *
* Character input is done with GBA buttons, up-down-left-right/A/B/R/L/Select/Start * Character input is done with GBA buttons,
* up-down-left-right/A/B/R/L/Select/Start
* - Select-key accept selected character * - Select-key accept selected character
* - Start-key read CR (Enter) * - Start-key read CR (Enter)
* - A-key select 'A' character * - A-key select 'A' character
@@ -382,8 +402,7 @@ int gba_getch(void)
while(1) { while(1) {
key = GBA_KEY(); key = GBA_KEY();
while ( (keyx=GBA_KEY())==key ); while ( (keyx=GBA_KEY())==key );
switch (key) switch (key) {
{
case GBA_KEY_SELECT: case GBA_KEY_SELECT:
gba_put(inputch); gba_put(inputch);
return inputch; return inputch;
@@ -420,6 +439,7 @@ int gba_getch(void)
default: default:
break; break;
} }
gba_put(inputch); gba_put(inputch);
delay_loop(1000); delay_loop(1000);
} }

View File

@@ -3,6 +3,7 @@
* *
* This file contains the GBA console I/O package. * This file contains the GBA console I/O package.
*/ */
/* /*
* RTEMS GBA BSP * RTEMS GBA BSP
* *
@@ -85,9 +86,11 @@ BSP_polling_getchar_function_type BSP_poll_char = gba_getch;
* @return status code * @return status code
*/ */
rtems_device_driver rtems_device_driver
console_initialize(rtems_device_major_number major, console_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg) void *arg
)
{ {
rtems_status_code status; rtems_status_code status;
@@ -95,7 +98,7 @@ console_initialize(rtems_device_major_number major,
rtems_termios_initialize (); rtems_termios_initialize ();
/* Do device-specific initialization */ /* Do device-specific initialization */
/* Allready done in bspstart.c -> gba_textmode(CO60); */ /* Already done in bspstart.c -> gba_textmode(CO60); */
/* Register the device */ /* Register the device */
status = rtems_io_register_name ("/dev/console", major, 0); status = rtems_io_register_name ("/dev/console", major, 0);
@@ -135,7 +138,6 @@ static int console_last_close(int major, int minor, void *arg)
return 0; return 0;
} }
/** /**
* @brief Console device driver OPEN entry point * @brief Console device driver OPEN entry point
* *
@@ -145,9 +147,11 @@ static int console_last_close(int major, int minor, void *arg)
* @return status code * @return status code
*/ */
rtems_device_driver rtems_device_driver
console_open(rtems_device_major_number major, console_open(
rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg) void *arg
)
{ {
rtems_status_code status; rtems_status_code status;
static rtems_termios_callbacks cb = static rtems_termios_callbacks cb =
@@ -181,9 +185,11 @@ console_open(rtems_device_major_number major,
* @return status code * @return status code
*/ */
rtems_device_driver rtems_device_driver
console_close(rtems_device_major_number major, console_close(
rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg) void *arg
)
{ {
rtems_device_driver res = RTEMS_SUCCESSFUL; rtems_device_driver res = RTEMS_SUCCESSFUL;
@@ -203,13 +209,13 @@ console_close(rtems_device_major_number major,
* @return status code * @return status code
*/ */
rtems_device_driver rtems_device_driver
console_read(rtems_device_major_number major, console_read(
rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg) void *arg
)
{ {
return rtems_termios_read (arg); return rtems_termios_read (arg);
} }
/** /**
@@ -223,9 +229,11 @@ console_read(rtems_device_major_number major,
* @return status code * @return status code
*/ */
rtems_device_driver rtems_device_driver
console_write(rtems_device_major_number major, console_write(
rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg) void *arg
)
{ {
return rtems_termios_write (arg); return rtems_termios_write (arg);
} }
@@ -239,7 +247,8 @@ console_write(rtems_device_major_number major,
* @return status code * @return status code
*/ */
rtems_device_driver rtems_device_driver
console_control(rtems_device_major_number major, console_control(
rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
void *arg void *arg
) )