From owner-p4-projects@FreeBSD.ORG Fri Apr 14 06:30:23 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8F84F16A407; Fri, 14 Apr 2006 06:30:23 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 55D0216A405 for ; Fri, 14 Apr 2006 06:30:23 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D051543D49 for ; Fri, 14 Apr 2006 06:30:22 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3E6UM3Y057826 for ; Fri, 14 Apr 2006 06:30:22 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3E6UM7f057820 for perforce@freebsd.org; Fri, 14 Apr 2006 06:30:22 GMT (envelope-from imp@freebsd.org) Date: Fri, 14 Apr 2006 06:30:22 GMT Message-Id: <200604140630.k3E6UM7f057820@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 95232 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Apr 2006 06:30:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=95232 Change 95232 by imp@imp_hammer on 2006/04/14 06:29:43 Initial integration into the tree. The text + data is now under 8k, but the bss makes it over 12.5k. I believe that we need to initialize this area, since we read the whole 16k eeprom with the loader as it stands. I think that we should be able to do away with the extra 8k read if we get bss working right (otherwise the bss gets junk in it, which is likely why my experiments with the bootloader failed last time). More could be done to better integrate this, as well as chopping it up into smaller bits. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/AT91RM9200.h#2 delete .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/Makefile#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/debug_io.c#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.c#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.h#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/main.c#2 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/Makefile#2 (text+ko) ==== @@ -1,77 +1,24 @@ -#/****************************************************************************** -# * -# * Filename: Makefile -# * -# * Classic makefile intended for use in gnu environment. The entries listed -# * here are intentionally simple to aid the novice user in his/her own -# * development - for easy modification. -# * -# * Revision information: -# * -# * 20AUG2004 kb_admin initial creation -# * 12JAN2005 kb_admin re-org, added emac -# * -# * BEGIN_KBDD_BLOCK -# * No warranty, expressed or implied, is included with this software. It is -# * provided "AS IS" and no warranty of any kind including statutory or aspects -# * relating to merchantability or fitness for any purpose is provided. All -# * intellectual property rights of others is maintained with the respective -# * owners. This software is not copyrighted and is intended for reference -# * only. -# * END_BLOCK -# ****************************************************************************** -# - -SHELL = /bin/sh - -basetoolsdir = /usr/local/arm -bindir = ${basetoolsdir}/bin -libdir = ${basetoolsdir}/lib/gcc/arm-linux-uclibc/3.4.2 - -CC = ${bindir}/arm-linux-gcc -AS = ${bindir}/arm-linux-as -LD = ${bindir}/arm-linux-ld -OBJCOPY = ${bindir}/arm-linux-objcopy - -CFILES = eeprom.o at91rm9200_lowlevel.o main.o env_vars.o debug_io.o loader_prompt.o p_string.o xmodem.o tag_list.o emac.o -ASFILES = arm_init.o - -bootloader: ${CFILES} ${ASFILES} - ${LD} -e 0 -o bootloader.out -T linker.cfg ${ASFILES} ${CFILES} - ${OBJCOPY} -O binary bootloader.out bootloader.bin - -main.o: main.c - ${CC} -c $? - -env_vars.o: env_vars.c - ${CC} -c $? - -debug_io.o: debug_io.c - ${CC} -c $? - -at91rm9200_lowlevel.o: at91rm9200_lowlevel.c - ${CC} -c $? - -loader_prompt.o: loader_prompt.c - ${CC} -c $? - -p_string.o: p_string.c - ${CC} -c $? - -xmodem.o: xmodem.c - ${CC} -c $? - -tag_list.o: tag_list.c - ${CC} -c $? - -eeprom.o: eeprom.c - ${CC} -c $? - -emac.o: emac.c - ${CC} -c $? - -arm_init.o: arm_init.s - ${AS} -o $@ $? - -clean: - rm -f *.o +# $FreeBSD: src/sys/boot/arm/at91/boot0/Makefile,v 1.1 2006/04/12 21:22:44 imp Exp $ + +.PATH: ${.CURDIR}/../boot0 + +PROG=bootiic +SRCS=arm_init.s at91rm9200_lowlevel.c lib.c main.c xmodem.c eeprom.c \ + env_vars.c debug_io.c loader_prompt.c p_string.c emac.c +NO_MAN= +LDFLAGS=-e 0 -T linker.cfg +CFLAGS=-O2 -mcpu=arm9 -ffreestanding -I${.CURDIR}/../inc -I${.CURDIR}/../boot0 +CFLAGS+=-DBOOT0_KB9202 +OBJS+= ${SRCS:N*.h:R:S/$/.o/g} +CLEANFILES=${OBJS} ${PROG} ${PROG}.out + +all: ${PROG} + +${PROG}: ${PROG}.out ${OBJS} + objcopy -S -O binary ${PROG}.out ${PROG} + +${PROG}.out: ${OBJS} + ld ${LDFLAGS} -o ${PROG}.out ${OBJS} + +clean: + rm -f ${CLEANFILES} ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/debug_io.c#2 (text+ko) ==== @@ -23,23 +23,6 @@ /* * .KB_C_FN_DEFINITION_START - * void DebugPutc(char) - * This global function writes a character to the debug uart port as soon - * as it is ready to send another character. - * .KB_C_FN_DEFINITION_END - */ -void DebugPutc(char cValue) { - - AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU; - - while (!(pUSART->US_CSR & AT91C_US_TXRDY)) ; - - pUSART->US_THR = (cValue & 0x1FF); -} - - -/* - * .KB_C_FN_DEFINITION_START * void DebugPrint(char *) * This global function writes a string to the debug uart port. * .KB_C_FN_DEFINITION_END @@ -48,62 +31,10 @@ if (!buffer) return; - while(*buffer != '\0') { - DebugPutc(*buffer++); - } + while(*buffer != '\0') + putc(*buffer++); } - -/* - * .KB_C_FN_DEFINITION_START - * int DebugGetchar(char *) - * This global function return true if a character was received from the - * debug uart port and sets the character in the pointer passed. Otherwise, - * the function returns 0 if not character was available. - * .KB_C_FN_DEFINITION_END - */ -int DebugGetchar(char *retChar) { - - AT91PS_USART pUSART = (AT91PS_USART)AT91C_BASE_DBGU; - - if ((pUSART->US_CSR & AT91C_US_RXRDY)) { - *retChar = (char)((pUSART->US_RHR) & 0x1FF); - return (1); - } - return (0); -} - - -/* - * .KB_C_FN_DEFINITION_START - * int WaitForChar(char *, int) - * This global function waits at least the specified number of seconds for - * a character and returns non-zero if a character was received and stored in - * the pointer. Otherwise, the function returns 0. - * .KB_C_FN_DEFINITION_END - */ -int WaitForChar(char *cPtr, int seconds) { - - unsigned thisSecond; - - ++seconds; - thisSecond = GetSeconds(); - - while (seconds) { - if (DebugGetchar(cPtr)) { - return (1); - } - - if (GetSeconds() != thisSecond) { - --seconds; - thisSecond = GetSeconds(); - } - } - - return (0); -} - - /* * .KB_C_FN_DEFINITION_START * void DebugPrintHex(int, int) ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#2 (text+ko) ==== @@ -23,7 +23,7 @@ #include "p_string.h" #include "debug_io.h" #include "eeprom.h" - +#include "lib.h" /* ****************************** GLOBALS *************************************/ char boot_commands[MAX_BOOT_COMMANDS][MAX_INPUT_SIZE]; @@ -49,17 +49,17 @@ * terminated. Returns 0 to indicate _wait_ condition. * .KB_C_FN_DEFINITION_END */ -static int ReadCharFromEnvironment(char *cPtr) { +static int ReadCharFromEnvironment(int timeout) +{ + int ch; if (currentIndex < MAX_BOOT_COMMANDS) { - - *cPtr = boot_commands[currentIndex][currentOffset++]; - - if ((!*cPtr) || (currentOffset >= MAX_INPUT_SIZE)) { + ch = boot_commands[currentIndex][currentOffset++]; + if (ch == '\0' || (currentOffset >= MAX_INPUT_SIZE)) { currentOffset = 0; ++currentIndex; } - return (1); + return (ch); } return (-1); @@ -143,7 +143,7 @@ DebugPrintHex(2, i); DebugPrint(" : "); for (j = 0; j < MAX_INPUT_SIZE; ++j) { - DebugPutc(boot_commands[i][j]); + putc(boot_commands[i][j]); if (!(boot_commands[i][j])) break; } ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.c#2 (text+ko) ==== @@ -25,9 +25,12 @@ #include "p_string.h" #include "xmodem.h" #include "eeprom.h" +#ifdef SUPPORT_TAG_LIST #include "tag_list.h" +#endif #include "emac.h" #include "loader_prompt.h" +#include "lib.h" /* ****************************** GLOBALS *************************************/ @@ -317,6 +320,7 @@ } break; +#ifdef SUPPORT_TAG_LIST case COMMAND_TAG: { // t
@@ -330,6 +334,7 @@ } break; +#endif case COMMAND_WRITE: // write the command table to non-volatile @@ -379,7 +384,7 @@ inputBuffer[buffCount] = p_char; ++buffCount; - DebugPutc(p_char); + putc(p_char); } } else if (buffCount) { @@ -413,21 +418,20 @@ * the loader will parse. * .KB_C_FN_DEFINITION_END */ -void Bootloader(int(*inputFunction)(char*)) { +void Bootloader(int(*inputFunction)(int)) { - char l_char; - int returnValue = 0; + int ch = 0; p_memset((void*)inputBuffer, 0, sizeof(inputBuffer)); buffCount = 0; if (!inputFunction) { - inputFunction = DebugGetchar; + inputFunction = getc; } DebugPrint("\n\r>"); - while (returnValue >= 0) - if ((returnValue = ((*inputFunction)(&l_char))) > 0) - ServicePrompt(l_char); + while (ch >= 0) + if ((ch = ((*inputFunction)(0))) > 0) + ServicePrompt(ch); } ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/loader_prompt.h#2 (text+ko) ==== @@ -47,6 +47,6 @@ char *c_string; } command_entry_t; -extern void EnterInteractiveBootloader(int(*inputFunction)(char*)); +extern void EnterInteractiveBootloader(int(*inputFunction)(int)); #endif /* _LOADER_PROMPT_H_ */ ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/main.c#2 (text+ko) ==== @@ -47,13 +47,8 @@ DebugPrint("\n\rKB9202(www.kwikbyte.com)\n\r"); DebugPrint("\n\rAuto boot..\n\r"); - /* check for input */ - if (!DebugGetchar(&l_char) && - !DebugGetchar(&l_char) && - !DebugGetchar(&l_char)) { - + if (getc(1) == -1) ExecuteEnvironmentFunctions(); - } Bootloader(0);