From owner-p4-projects@FreeBSD.ORG Mon Apr 10 18:07:14 2006 Return-Path: <owner-p4-projects@FreeBSD.ORG> X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7CC1016A405; Mon, 10 Apr 2006 18:07:14 +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 58F1E16A409 for <perforce@freebsd.org>; Mon, 10 Apr 2006 18:07:14 +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 6B9F143D6B for <perforce@freebsd.org>; Mon, 10 Apr 2006 18:07:09 +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 k3AI79BR008189 for <perforce@freebsd.org>; Mon, 10 Apr 2006 18:07:09 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3AI79wY008186 for perforce@freebsd.org; Mon, 10 Apr 2006 18:07:09 GMT (envelope-from imp@freebsd.org) Date: Mon, 10 Apr 2006 18:07:09 GMT Message-Id: <200604101807.k3AI79wY008186@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Cc: Subject: PERFORCE change 94926 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes <p4-projects.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/p4-projects>, <mailto:p4-projects-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/p4-projects> List-Post: <mailto:p4-projects@freebsd.org> List-Help: <mailto:p4-projects-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/p4-projects>, <mailto:p4-projects-request@freebsd.org?subject=subscribe> X-List-Received-Date: Mon, 10 Apr 2006 18:07:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=94926 Change 94926 by imp@imp_Speedy on 2006/04/10 18:06:39 Migrate towards using more standard interfaces. Use getc/getchar and putc. This also happens to have a bunch of bytes off the size of this unit. We're now at 1040 bytes. Affected files ... .. //depot/projects/arm/src/sys/arm/conf/KB920X#27 edit .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/Makefile#4 edit .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/at91rm9200_lowlevel.c#4 edit .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/debug_io.c#4 delete .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/debug_io.h#2 delete .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/lib.c#1 add .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/lib.h#1 add .. //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/xmodem.c#3 edit Differences ... ==== //depot/projects/arm/src/sys/arm/conf/KB920X#27 (text+ko) ==== ==== //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/Makefile#4 (text+ko) ==== @@ -1,5 +1,5 @@ PROG=boot0 -SRCS=arm_init.s at91rm9200_lowlevel.c main.c debug_io.c xmodem.c +SRCS=arm_init.s at91rm9200_lowlevel.c lib.c main.c xmodem.c NO_MAN= LDFLAGS=-e 0 -T linker.cfg CFLAGS=-O2 -mcpu=arm9 -ffreestanding ==== //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/at91rm9200_lowlevel.c#4 (text+ko) ==== @@ -22,7 +22,6 @@ #include "AT91RM9200.h" #include "at91rm9200_lowlevel.h" -#include "debug_io.h" #define BAUD 115200 ==== //depot/projects/arm/src/sys/boot/arm/kb920x/boot0/xmodem.c#3 (text+ko) ==== @@ -1,29 +1,28 @@ -/******************************************************************************* +/*- + * Copyright (c) 2006 M. Warner Losh. All rights reserved. * - * Filename: xmodem.c + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * Instantiation of simple x-modem support using debug uart channel. - * - * Revision information: - * - * 22AUG2004 kb_admin initial creation - * 24AUG2004 kb_admin optimize for space, not quite as elegant. . . - * - * 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 - ******************************************************************************/ + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ -#include "at91rm9200_lowlevel.h" - -/* ****************************** GLOBALS *************************************/ - -/* ********************* PRIVATE FUNCTIONS/DATA/DEFINES ***********************/ +#include "lib.h" #define PACKET_SIZE 128 @@ -34,15 +33,6 @@ #define CAN 0x18 /* Cancel */ #define EOT 0x04 /* end of text */ -enum { - INVALID_STATE = 0, - WAITING_START, - WAIT_SOH, - RX_PACKET, - RX_EOT, - SEND_NAK -}; - /* * .KB_C_FN_DEFINITION_START * int GetRecord(char , char *) @@ -54,52 +44,48 @@ GetRecord(char blocknum, char *dest) { int size; - char nextChar; + int ch; unsigned chk, j; chk = 0; - if (!WaitForChar(&nextChar, 1)) + if ((ch = getc(1)) == -1) goto err; - if (nextChar != blocknum) + if (ch != blocknum) goto err; - if (!WaitForChar(&nextChar, 1)) + if ((ch = getc(1)) == -1) goto err; - if ((char)nextChar != (char)~blocknum) + if (ch != ~blocknum & 0xff) goto err; for (size = 0; size < PACKET_SIZE; ++size) { - if (!WaitForChar(&nextChar, 1)) + if ((ch = getc(1)) == -1) goto err; - chk = chk ^(int)nextChar << 8; + chk = chk ^ ch << 8; for (j = 0; j < 8; ++j) { if (chk & 0x8000) chk = chk << 1 ^ 0x1021; else chk = chk << 1; } - *dest++ = nextChar; + *dest++ = ch; } chk &= 0xFFFF; - if ((!WaitForChar(&nextChar, 1)) || (nextChar != ((chk >> 8) & 0xFF))) + if (((ch = getc(1)) == -1) || (ch & 0xff != ((chk >> 8) & 0xFF))) goto err; - if ((!WaitForChar(&nextChar, 1)) || (nextChar != (chk & 0xFF))) + if (((ch = getc(1)) == -1) || (ch & 0xff != (chk & 0xFF))) goto err; - DebugPutc(ACK); + putc(ACK); return (1); err:; - DebugPutc(NAK); + putc(CAN); // We should allow for resend, but we don't. return (0); } - -/* ************************** GLOBAL FUNCTIONS ********************************/ - - /* * .KB_C_FN_DEFINITION_START * int xmodem_rx(char *) @@ -111,20 +97,19 @@ int xmodem_rx(char *dest) { - int starting; - char packetNumber, nextChar, *startAddress = dest; + int starting, ch; + char packetNumber, *startAddress = dest; packetNumber = 1; starting = 1; while (1) { if (starting) - DebugPutc('C'); - if (!WaitForChar(&nextChar, 1) || - (nextChar != SOH && nextChar != EOT)) + putc('C'); + if (((ch = getc(1)) == -1) || (ch != SOH && ch != EOT)) continue; - if (nextChar == EOT) { - DebugPutc(ACK); + if (ch == EOT) { + putc(ACK); return (dest - startAddress); } starting = 0;