From: Erik M. <er...@us...> - 2002-01-03 16:07:21
|
Update of /cvsroot/blob/blob/src/diag In directory usw-pr-cvs1:/tmp/cvs-serv2589/src/diag Modified Files: Makefile.am commands.c initcalls.c lcd.c main.c system3.c Added Files: assabet.c badge4.c brutus.c clart.c h3600.c idr.c jornada720.c lart.c nesa.c pleb.c shannon.c Log Message: The serial port driver rewrite, part two. This looks quite intrusive, but it's not that large: - rewrite src/lib/serial.c to use the low level serial driver - change semantics for SerialInputByte() and SerialOutputByte(), so rename them to serial_read() and serial_write(). this makes the patch huge - add new INIT_LEVEL for driver selection (has to be done before hardware initialisation) - add machine specific files for all architectures in diag - clean up odds and ends. --- NEW FILE: assabet.c --- /* * assabet.c: Assabet specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: assabet.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: assabet.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void assabet_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(assabet_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: badge4.c --- /* * badge4.c: Badge4 specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: badge4.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: badge4.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void badge4_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(badge4_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: brutus.c --- /* * brutus.c: Brutus specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: brutus.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: brutus.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void brutus_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(brutus_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: clart.c --- /* * clart.c: CreditLART specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: clart.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: clart.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void clart_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(clart_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: h3600.c --- /* * h3600.c: Ipaq H3600 specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: h3600.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: h3600.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void h3600_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(h3600_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: idr.c --- /* * idr.c: Vercel UD-1 (IDR) specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: idr.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: idr.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void idr_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(idr_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: jornada720.c --- /* * jornada720.c: Jornada 720 specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: jornada720.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: jornada720.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void jornada720_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(jornada720_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: lart.c --- /* * lart.c: LART specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: lart.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: lart.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void lart_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(lart_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: nesa.c --- /* * nesa.c: NESA specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: nesa.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: nesa.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void nesa_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(nesa_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: pleb.c --- /* * pleb.c: PLEB specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: pleb.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: pleb.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void pleb_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(pleb_init_hardware, INIT_LEVEL_DRIVER_SELECTION); --- NEW FILE: shannon.c --- /* * shannon.c: Shannon specific stuff * * Copyright (C) 2002 Erik Mouw <J.A...@it...> * * $Id: shannon.c,v 1.1 2002/01/03 16:07:18 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: shannon.c,v 1.1 2002/01/03 16:07:18 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/init.h> #include <blob/serial.h> static void shannon_init_hardware(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; } __initlist(shannon_init_hardware, INIT_LEVEL_DRIVER_SELECTION); Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/diag/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile.am 2001/10/28 22:14:20 1.5 +++ Makefile.am 2002/01/03 16:07:18 1.6 @@ -44,6 +44,17 @@ EXTRA_diag_elf32_SOURCES = \ lcd.c \ + assabet.c \ + badge4.c \ + brutus.c \ + clart.c \ + h3600.c \ + idr.c \ + jornada720.c \ + lart.c \ + nesa.c \ + pleb.c \ + shannon.c \ system3.c diag_elf32_DEPENDENCIES = \ Index: commands.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/commands.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- commands.c 2001/12/19 20:00:15 1.4 +++ commands.c 2002/01/03 16:07:18 1.5 @@ -30,6 +30,7 @@ #include <blob/command.h> #include <blob/command_hist.h> +#include <blob/error.h> #include <blob/reboot.h> #include <blob/serial.h> #include <blob/terminal.h> @@ -50,7 +51,7 @@ int GetCommand(char *command, int len, int timeout) { u32 startTime, currentTime; - char c; + int c; int i; int numRead; int maxRead = len - 1; @@ -63,7 +64,7 @@ for(numRead = 0, i = 0; numRead < maxRead;) { /* try to get a byte from the serial port */ - while(!SerialInputByte(&c)) { + while(serial_poll() != 0) { currentTime = TimerGetTime(); /* check timeout value */ @@ -76,11 +77,21 @@ } } + c = serial_read(); + + /* check for errors */ + if(c < 0) { + command[i++] = '\0'; + serial_write('\n'); + printerror(c, "can't read command"); + return c; + } + if((c == '\r') || (c == '\n')) { command[i++] = '\0'; /* print newline */ - SerialOutputByte('\n'); + serial_write('\n'); cmdhist_push( command ); return(numRead); } else if(c == '\b') { /* FIXME: is this backspace? */ @@ -125,7 +136,7 @@ numRead++; /* print character */ - SerialOutputByte(c); + serial_write(c); } } Index: initcalls.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/initcalls.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- initcalls.c 2001/10/15 21:27:05 1.2 +++ initcalls.c 2002/01/03 16:07:18 1.3 @@ -39,7 +39,7 @@ /* default serial initialisation */ static void serial_default_init(void) { - SerialInit(baud9k6); + serial_init(baud_9600); } Index: lcd.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/lcd.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- lcd.c 2001/10/15 15:02:40 1.4 +++ lcd.c 2002/01/03 16:07:18 1.5 @@ -51,7 +51,7 @@ #define OUTHEX( val ) SerialOutputString( #val"=0x" ); \ SerialOutputHex( val ); \ - SerialOutputByte( '\n' ); + serial_write( '\n' ); /********************************************************************** * program globals @@ -104,8 +104,8 @@ LCCR2 = LCD_LCCR2; LCCR1 = LCD_LCCR1; LCCR0 = LCD_LCCR0 & ~LCCR0_LEN; - DBAR1 = (u32 *)LCD_PALETTE_DMA_ADR; - DBAR2 = (u32 *)LCD_VIDEORAM_DMA_ADR; + DBAR1 = (u32)LCD_PALETTE_DMA_ADR; + DBAR2 = (u32)LCD_VIDEORAM_DMA_ADR; return 0; } @@ -164,7 +164,7 @@ { int ret = 0; int x,y; - char c; + int c; #if LCD_DEBUG OUTHEX( LCD_LCCR0 ); @@ -230,8 +230,7 @@ SerialOutputString( "done\n" ); SerialOutputString( "LCD: press any key to proceed\n" ); - while ( !SerialInputByte( &c ) ) - ; + c = serial_read(); SerialOutputString( "LCD: backlight off ..." ); ret = lcd_backlight_off(); Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/main.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- main.c 2001/11/04 23:20:16 1.3 +++ main.c 2002/01/03 16:07:18 1.4 @@ -45,7 +45,7 @@ init_subsystems(); #ifdef H3600 - SerialInit(baud115k2); /* DEBUG */ + serial_init(baud_115200); /* DEBUG */ #endif SerialOutputString("\ndiag version " VERSION " for " BOARD_NAME "\n" Index: system3.c =================================================================== RCS file: /cvsroot/blob/blob/src/diag/system3.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- system3.c 2001/11/13 13:20:31 1.5 +++ system3.c 2002/01/03 16:07:18 1.6 @@ -96,7 +96,7 @@ /********************************************************************** * prototypes */ -void sa1111_init(); +static void sa1111_init(); /*********************************************************************/ /*********************************************************************/ @@ -106,7 +106,7 @@ __initlist(sa1111_init, INIT_LEVEL_INITIAL_HARDWARE); -void sa1111_init() +static void sa1111_init() { /* switch on clock for sa1111 */ GAFR |= GPIO_32_768kHz; @@ -145,6 +145,18 @@ ((FExtr(MDCNFG, MDCNFG_SA1110_TDL0)==3) ? SMCR_CLAT : 0)); } + + + +static void system3_init_hardware(void) +{ + /* select serial driver */ + serial_driver = &sa11x0_serial_driver; +} + +__initlist(system3_init_hardware, INIT_LEVEL_DRIVER_SELECTION); + + /********************************************************************** * Overwrite LCD functions special for this platform */ @@ -281,7 +293,7 @@ SerialOutputString( registers[i].name ); SerialOutputString( "= 0x" ); SerialOutputHex( MEM( registers[i].adr ) ); - SerialOutputByte( '\n' ); + serial_write( '\n' ); i++; } |