Browse Source

add tftpd

master
root 16 years ago
committed by root
parent
commit
d64434874e
  1. 1
      Targets/Bonito2fdev/conf/Bonito.2fdev.cs5536
  2. 1
      Targets/Bonito2fdev/conf/Bonito.2fdev.via
  3. 91
      Targets/Bonito2fdev/conf/ld.script
  4. 1
      conf/files
  5. 47
      include/crc32.h
  6. 2
      lib/libc/arch/mips/Makefile.inc
  7. 100
      lib/libc/crc32.c
  8. 11
      lib/libc/sprintf.c
  9. 20
      lib/libc/strcpy.c
  10. 1246
      pmon/cmds/tftpd.c
  11. 4
      pmon/fs/ramfile.c

1
Targets/Bonito2fdev/conf/Bonito.2fdev.cs5536

@ -71,6 +71,7 @@ select mod_uart_ns16550 # Standard UART driver
option CONS_BAUD=B115200 option CONS_BAUD=B115200
select ext2 select ext2
select fatfs select fatfs
select ramfiles
#select mod_x86emu # X86 emulation for VGA #select mod_x86emu # X86 emulation for VGA
option MY40IO option MY40IO
#select mod_x86emu_int10 #select mod_x86emu_int10

1
Targets/Bonito2fdev/conf/Bonito.2fdev.via

@ -180,3 +180,4 @@ option DEVBD2F_VIA
select http select http
select tcp select tcp
select inet select inet
select tftpd

91
Targets/Bonito2fdev/conf/ld.script

@ -1,91 +0,0 @@
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
"elf32-littlemips")
OUTPUT_ARCH(mips)
ENTRY(_start)
SECTIONS
{
. = 0xffffffff80010000;
.text :
{
_ftext = . ;
*(.text)
*(.rodata)
*(.rodata1)
*(.reginfo)
*(.init)
*(.stub)
*(.gnu.warning)
} =0
_etext = .;
PROVIDE (etext = .);
.fini : { *(.fini) } =0
.data :
{
_fdata = . ;
*(.data)
CONSTRUCTORS
}
.data1 : { *(.data1) }
.ctors :
{
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
}
.dtors :
{
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
}
_gp = ALIGN(16) + 0x7ff0;
.got :
{
*(.got.plt) *(.got)
}
.sdata : { *(.sdata) }
.lit8 : { *(.lit8) }
.lit4 : { *(.lit4) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
_fbss = .;
.sbss : { *(.sbss) *(.scommon) }
.bss :
{
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.debug 0 : { *(.debug) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.line 0 : { *(.line) }
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
}

1
conf/files

@ -190,6 +190,7 @@ file pmon/cmds/hist.c cmd_hist needs-flag
file pmon/cmds/ifaddr.c (inet & cmd_ifaddr) file pmon/cmds/ifaddr.c (inet & cmd_ifaddr)
file pmon/cmds/oload.c (mod_load | mod_fastload | mod_elfload | mod_s3load) needs-flag file pmon/cmds/oload.c (mod_load | mod_fastload | mod_elfload | mod_s3load) needs-flag
file pmon/cmds/load.c file pmon/cmds/load.c
file pmon/cmds/tftpd.c tftpd
file pmon/cmds/cmd_grub.c file pmon/cmds/cmd_grub.c
file pmon/cmds/memcmds.c cmd_mem file pmon/cmds/memcmds.c cmd_mem
file pmon/cmds/memtst.c cmd_mt file pmon/cmds/memtst.c cmd_mt

47
include/crc32.h

@ -0,0 +1,47 @@
/* $Id: crc32.h,v 1.2 2006/09/09 10:15:05 pefo Exp $ */
/*
* Copyright (c) 2005-2006 Opsycon AB (www.opsycon.se)
*
* 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.
*
* 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.
*
*/
#ifndef __CRC32_H__
#define __CRC32_H__
u_int crc32_generate(void *, size_t);
u_int crc32_generate_seg(void *, size_t, u_int);
u_int crc32_check(void *, size_t);
/* Helper functions, see build options */
#define CRC32_CHECK_CRC 1
#define CRC32_CHECK_SIG 2
#define CRC32_OK 0
#define CRC32_ERR_FILE -1
#define CRC32_ERR_CRC -2
#define CRC32_ERR_SIG -3
int crc32sig_check(const char *, u_int64_t, int);
#endif /* __CRC32_H__ */

2
lib/libc/arch/mips/Makefile.inc

@ -57,6 +57,6 @@ SRCS+= argvize.c atob.c atof.c atoi.c atol.c bzero.c bcmp.c calloc.c \
tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \ tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
tcsendbreak.c tcsetattr.c tcsetpgrp.c cfgetispeed.c \ tcsendbreak.c tcsetattr.c tcsetpgrp.c cfgetispeed.c \
cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \ cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
cfsetspeed.c ulmin.c lmin.c ioctl.c filefs.c parseurl.c cfsetspeed.c ulmin.c lmin.c ioctl.c filefs.c parseurl.c crc32.c
SRCS+= longjmp.S ovbcopy.S poweroff.c reboot.c SRCS+= longjmp.S ovbcopy.S poweroff.c reboot.c

100
lib/libc/crc32.c

@ -0,0 +1,100 @@
/* $Id: crc32.c,v 1.2 2006/09/09 10:15:07 pefo Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*/
/*
* CRC32 support functions.
*/
#include <sys/types.h>
#include <crc32.h>
/*
* CRC generator shortcut table.
*/
static const u_int crctab[] = {
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
};
/*
* Generate CRC32 for data block 'data' with size 'length'.
*
* Returns generated CRC32.
*/
u_int
crc32_generate(void *data, size_t length)
{
return crc32_generate_seg(data, length, 0xffffffff);
}
u_int
crc32_generate_seg(void *data, size_t length, u_int crc)
{
const u_char *p = data;
const u_int *crctabp = crctab;
int i;
if (length < 1)
return -1;
i = length;
while (i-- > 0) {
crc ^= *p++;
crc = (crc >> 4) ^ crctabp[crc & 0xf];
crc = (crc >> 4) ^ crctabp[crc & 0xf];
}
return crc;
}
/*
* Check CRC32 for data block 'data' with size 'length'.
* Last two bytes is the CRC32.
*
* Returns -1 if data out of range.
* Returns 0 if CRC32 is checked OK.
* Returns > 0 if CRC32 is checked BAD.
*/
u_int
crc32_check(void *data, size_t length)
{
const u_char *p = data;
int result;
if (length < 5)
return -1;
result = crc32_generate(data, length - 4);
p += length - 4;
result ^= p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
return result;
}

11
lib/libc/sprintf.c

@ -46,3 +46,14 @@ sprintf (char *buf, const char *fmt, ...)
va_end(ap); va_end(ap);
return (n); return (n);
} }
int
snprintf (char *buf, size_t maxlen, const char *fmt, ...)
{
int n;
va_list ap;
va_start(ap, fmt);
n = vsprintf (buf, fmt, ap);
va_end(ap);
return (n);
}

20
lib/libc/strcpy.c

@ -46,3 +46,23 @@ strcpy (char *dstp, const char *srcp)
while ((*dp++ = *srcp++) != 0); while ((*dp++ = *srcp++) != 0);
return (dstp); return (dstp);
} }
size_t
strlcpy(char *d, const char *s, size_t l)
{
size_t len = l;
if (d == NULL || l == 0)
return 0;
*d = 0;
if (s == NULL)
return 0;
while (--len)
if ((*d++ = *s++) == 0)
break;
if (len == 0)
*d = 0;
len = l - len;
return len;
}

1246
pmon/cmds/tftpd.c

File diff suppressed because it is too large

4
pmon/fs/ramfile.c

@ -117,9 +117,12 @@ static int
} }
if (strsize != NULL) { if (strsize != NULL) {
#if 0
if (!get_rsa ((u_int32_t *)&size, strsize)) { if (!get_rsa ((u_int32_t *)&size, strsize)) {
return (-1); return (-1);
} }
#endif
size=strtoul(strsize,0,0);
} else { } else {
size = -1; size = -1;
} }
@ -317,5 +320,6 @@ static void
#endif #endif
addRamFile("vmlinux", 0xbc000000, 0x800000, RAMFILE_STATIC); addRamFile("vmlinux", 0xbc000000, 0x800000, RAMFILE_STATIC);
addRamFile("vmlinux1", 0xc0200000, 0xa00000, RAMFILE_CPHY); addRamFile("vmlinux1", 0xc0200000, 0xa00000, RAMFILE_CPHY);
addRamFile("usermem", (long)CLIENTPC,0x10000000, RAMFILE_STATIC);
} }

Loading…
Cancel
Save