Commit Graph

298 Commits

Author SHA1 Message Date
Robert Watson
a532cafd5e Enable building string functions as part of libstand on mips; the Makefile
is a bit obfuscated here, as ia64 adds string source files elsewhere, so
simply exclude it here.

Reviewed by:	imp
MFC after:	3 days
Sponsored by:	DARPA, AFRL
2013-04-28 16:35:24 +00:00
Robert Watson
1f05db3e5c Merge @228176 from Perforce to fix a bug introduced in r249553:
Trim two now-unneeded (and likely harmful) lines from the libstand
  setjmp/longjmp for MIPS.

  Spotted by:   jmallett

MFC after:      3 days
Sponsored by:	DARPA, AFRL
2013-04-28 14:40:29 +00:00
Robert Watson
a49ab93ce2 Use a suitable code generation when building libstand for MIPS.
Reviewed by:	imp
Sponsored by:	DARPA, AFRL
MFC after:	3 days
2013-04-16 17:20:52 +00:00
Robert Watson
909735d975 Adapt libstand's setjmp/longjmp MIPS support to be portable across 32-bit
and 64-bit MIPS.  Don't use the floating-point coprocessor in the libstand
context for MIPS.

Reviewed by:	imp
MFC after:	3 days
Sponsored by:	DARPA, AFRL
2013-04-16 17:03:35 +00:00
Andrew Turner
e54c5a4733 Add __clzsi2 and ctzsi2. They are required on ARMv4 and ARMv5 to implement
a number of builtin functions.
2013-03-07 09:18:52 +00:00
Marcel Moolenaar
e4d4e0756a Make this WARNS=9 clean on i386 w/ clang. 2013-03-02 05:28:55 +00:00
Marcel Moolenaar
ecc7e36ccb Fix warnings (control reaches end of non-void function). 2013-03-02 05:07:51 +00:00
Marcel Moolenaar
9b6799ad6b Fix nandfs support by providing the same crc32 function as is used
in newfs_nandfs. In libstand we get crc32 from libz. The polynomial
is not the same as used for nandfs, which is the crc32 used in the
kernel.
2013-03-02 05:03:36 +00:00
Tim Kientzle
4faa1dea0b Fix includes for use in libstand. 2013-02-19 17:09:23 +00:00
Tim Kientzle
341cee15f6 Add strtoul() to libstand by copying from libc and clipping out
locale code.
2013-02-18 01:55:53 +00:00
Andrew Turner
f892543501 * Add the integer div & mod functions and ARM EABI support functions to
libstand.
* Stop linking the ARM U-Boot loader against libgcc now libstand has the
  required symbols.
2013-02-05 20:03:58 +00:00
Gleb Smirnoff
6bf8b93697 Remove unused file. 2013-01-29 21:37:56 +00:00
Rui Paulo
a443a16906 Move the 64-bit _setjmp to lib/libstand. 2012-12-21 15:15:35 +00:00
Grzegorz Bernacki
47ed3abe8e Correct detection of a superblock.
Obtained from:	Smartcom Bulgaria AD
2012-10-03 10:06:48 +00:00
Kevin Lo
b7b6a643aa Revert r240850 and remove redundant NULL check before free(3).
free(3) handles NULL parameter fine.

Reviewed by:	kib, Garrett Cooper
2012-09-24 05:24:10 +00:00
Kevin Lo
6e427123e2 Avoid NULL dereference 2012-09-23 08:38:06 +00:00
Alexander Motin
4b1b92312e Make nfs_readdir() more careful about using response data, cached in global
buffer. For now it fixes bug when following `ls` command will return data
from previous one aborted by pager. Also it should allow to read several
directories same time, for example, for recursive tracerse.
2012-09-21 13:25:50 +00:00
Alexander Motin
e34e909b1f Don't use global nfs_root_node variable as per-file storage. There are
fields that should be file-specific.
2012-09-21 12:19:36 +00:00
Xin LI
a2953f767d MFV: Update zlib to 1.2.7.
(x86 assembler optimization disabled for now because it
requires the new .cfi_* directives that is not supported
by base system binutils).

MFC after:	1 week
2012-06-21 21:47:08 +00:00
David E. O'Brien
8bed40c9fe Consitently use "__LP64__".
[there are 33 __LP64__'s in the kernel (minus cddl/ and contrib/),
and 11 _LP64's]
2012-05-24 21:44:46 +00:00
Grzegorz Bernacki
7f725bcd5c Import work done under project/nand (@235533) into head.
The NAND Flash environment consists of several distinct components:
  - NAND framework (drivers harness for NAND controllers and NAND chips)
  - NAND simulator (NANDsim)
  - NAND file system (NAND FS)
  - Companion tools and utilities
  - Documentation (manual pages)

This work is still experimental. Please use with caution.

Obtained from: Semihalf
Supported by:  FreeBSD Foundation, Juniper Networks
2012-05-17 10:11:18 +00:00
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
2012-01-03 18:51:58 +00:00
Ed Schouten
46632c18bd Merge index() and strchr() together.
As I looked through the C library, I noticed the FreeBSD MIPS port has a
hand-written version of index(). This is nice, if it weren't for the
fact that most applications call strchr() instead.

Also, on the other architectures index() and strchr() are identical,
meaning we have two identical pieces of code in the C library and
statically linked applications.

Solve this by naming the actual file strchr.[cS] and let it use
__strong_reference()/STRONG_ALIAS() to provide the index() routine. Do
the same for rindex()/strrchr().

This seems to make the C libraries and static binaries slightly smaller,
but this reduction in size seems negligible.
2012-01-03 07:14:01 +00:00
Ed Schouten
cb301c1a81 Add placeholder code for prepending pathnames to tftp.
At work we have a single tftp server that provides installation data for
a variety of operating systems. I'd rather place our FreeBSD-related
files in a subdirectory, instead of the root.

It would be nice if this setting could be run-time configurable, but at
least in our specific case, this is not possible, as pxeboot is
chainloaded through pxelinux.

Sponsored by:	Kumina bv
2011-12-22 09:36:37 +00:00
Tai-hwa Liang
f497fbf5e4 - Removing some unneeded definitions of NULL(cruft related to 1970's C).
In C90, NULL is guaranteed to be declared in <stddef.h> and also in
  <string.h>.  Though the correct way to define NULL in FreeBSD is to
  include <sys/_null.h>, other parts of libstand still require <string.h>
  to build; therefore, we keep <string.h> in stand.h and add a note about
  this;
- Removing no longer used 'Prototype' definition.  Quote from bde@:

	'Cruft related to getting incomplete struct declarations within
	prototypes forward-declared before the structs.  It doesn't mean
	"prototype" but only part of a prototype-related hack.  No longer
	used.'

- Replacing iaddr_t with uintptr_t;
- Removing use of long double to determine alignment.  Use a fixed 16 byte
  alignment instead;

Reviewed by:	bde
Obtained from:	DragonFlyBSD (partially)
MFC after:	1 month
2011-07-10 07:25:34 +00:00
Kevin Lo
5f099d0a7d style(9) cleanup 2011-07-10 07:14:32 +00:00
Tai-hwa Liang
728fc2d633 Fixing building bustage on 32 bits platforms when WARNS >= 2. Note that
this fix only applies to zalloc.c, the other part of libstand such like
qdivrem.c still gives compilation warnings on sparc64 tinderbox builds;
therefore, WARNS level isn't changed for now.

Submitted by:	Garrett Cooper <yanegomi@gmail.com>
Reviewed by:	bde
2011-07-08 01:35:33 +00:00
Craig Rodrigues
23a5bce73f Fixes to newer tftp code in libstand:
(1) Coding style changes.
 (2) If the server does not acknowledge any blocksize option,
     revert to the default blocksize of 512 bytes.
 (3) Send ACK if the first packet happens to be the last packet.
 (4) Do not accept blocksize greater than what was requested.
 (5) Drop any unwanted OACK received if a tftp transfer is already
     in progress.
 (6) Terminate incomplete transfers with a special no-error ERROR packet.
     Otherwise we rely on the tftp server to time out, which it does
     eventually, after re-sending the last packet several times and spamming
     the system log about it every time.  This idea is borrowed from the
     PXE client, which does exactly that.

Submitted by:  Alexander Kabaev <kan@FreeBSD.org>
Reviewed and Tested by: Santhanakrishnan Balraj <sbalraj at juniper dot net>
2011-06-24 03:50:54 +00:00
Warner Losh
d996b98bea Setting warnings without make universe considered harmful. Revert to WARNS=0
until such time that the warnings at =2 are fixed for all platforms.
2011-06-16 18:00:27 +00:00
Tai-hwa Liang
c1434464b8 Using the correct format string(%zu) for size_t type. This should fix 64
bits builds.

Submitted by:	Garrett Cooper <yanegomi@gmail.com>
2011-06-16 15:35:12 +00:00
Tai-hwa Liang
72d8b2903f Unbreaking build on sparc64.
Submitted by:	Garrett Cooper <yanegomi@gmail.com>
2011-06-16 07:14:55 +00:00
Craig Rodrigues
32ecdb308f Bring back following change which was undone in previous commit:
------------------------------------------------------------------------
    r172854 | marius | 2007-10-21 10:03:18 -0700 (Sun, 21 Oct 2007) | 16 lines
    Changed paths:
       M /head/lib/libstand/tftp.c

    - Given that we tell the compiler that struct ip is packed and 32-bit
      aligned, GCC 4.2.1 also generates code for sendudp() that assumes
      this alignment. GCC 4.2.1 however doesn't 32-bit align wbuf, causing
      the loader to crash due to an unaligned access of wbuf in sendudp()
      when netbooting sparc64. Solve this by specifying wbuf as packed and
      32-bit aligned, too. As for lastdata and readudp() this currently is
      no issue when compiled with GCC 4.2.1, though give lastdata the same
      treatment as wbuf for consistency and possibility of being affected
      in the future. [1]
    - Sprinkle const on a lookup table.
    ------------------------------------------------------------------------
2011-06-15 23:22:35 +00:00
Craig Rodrigues
3c33617643 Increase WARNS level to 2. 2011-06-15 22:15:28 +00:00
Craig Rodrigues
4c474d5c2f (1) When sending the TFTP RRQ packet to read a file,
send along the "blksize" option specified in RFC2348,
     and the "tsize" option specified in RFC2349.

     Add code to parse the TFTP Option Acknowledgement (OACK) packet as
     specified in RFC2347.

     For TFTP servers which support the "blksize" option, we can
     specify a TFTP Data block size larger than the default 512 bytes
     specified in RFC1350.  This offers greater read performance when
     downloading files.

     We request an initial size of 1428 bytes, which is less than the
     Ethernet MTU of 1500 bytes.  If the TFTP server sends back an OACK
     packet, then use the block size specified in the OACK packet.
     Most times it is usually the same value as what we request.
     If the TFTP server supports RFC2348, we will see performance improvements
     by transferring files over TFTP with larger block sizes.

     If we do not get back an OACK packet, then we most likely we
     are interoperating with a legacy TFTP server that does not
     support TFTP extension options, so default to the block size of
     512 bytes.

(2)  If the "tftp.blksize" environment variable is set, then
     take that value and use it when sending the TFTP RRQ packet,
     instead of 1428.  This allows us to set different values of
     "tftp.blksize" in the loader, so that we can test out different
     TFTP block sizes at run time.

Obtained from: Juniper Networks
Fixed by:  rodrigc
2011-06-15 22:13:22 +00:00
Craig Rodrigues
dc438c8ec8 Currently tftp code in the loader retransmits the previous packet if it receives any
unwanted packet(non-tftp). Change this to retransmit the packet(request or ack) only after
a timeout.

Obtained from:	Juniper Networks
Fixed by: Santhanakrishnan Balraj <sbalraj at juniper dot net>
2011-06-15 22:08:18 +00:00
Craig Rodrigues
6e4c6f18f7 Added sendrecv_tftp function instead of sendrecv for use by tftp.
In sendrecv_tftp:
    * Upon receving an unexpected block of data or error, resend the ACK
      immediately instead of waiting till the expiry of receive data timeout
      to resend the ACK.
    * change the receive timeout value between retries to be 2xMINTMO.

Obtained from: Juniper Networks
Fixed by: Santhanakrishnan Balraj <sbalraj at juniper dot net>
2011-06-15 22:04:14 +00:00
Craig Rodrigues
ee83fc0de0 In sendrecv function, change the receive timeout value between retries
to increase in steps of MINTMO, instead of doubling the timeout for every
retry.

Obtained from: Juniper Networks
Fixed by: Santhanakrishnan Balraj <sbalraj at juniper dot net>
2011-06-15 21:58:01 +00:00
Craig Rodrigues
78315071f5 Obtain bswap64() function implementation from
version 1.3 of src/common/lib/libc/gen/bswap64.c in NetBSD.

Obtained from: NetBSD
2011-06-10 01:13:15 +00:00
Craig Rodrigues
51f95b0a42 Rename DEBUG macro to TFTP_DEBUG, to be more consistent with
debug macros in other files.
2011-05-03 07:46:02 +00:00
Craig Rodrigues
3eb882f031 - Comment out unused variable.
- Add parentheses around expression to eliminate compiler warning.
2011-05-03 07:43:47 +00:00
Craig Rodrigues
a259acefff Add #include <netinet/in_pcb.h> for missing forward declation of
struct inpcb.
2011-05-03 07:39:54 +00:00
Craig Rodrigues
74ff69fe44 Switch to ANSI function prototypes in a few places.
Get rid of some unused parameter warnings.
2011-05-03 04:44:50 +00:00
Rebecca Cran
6bccea7c2b Fix typos - remove duplicate "the".
PR:	bin/154928
Submitted by:	Eitan Adler <lists at eitanadler.com>
MFC after: 	3 days
2011-02-21 09:01:34 +00:00
Dimitry Andric
3ab20ac1f5 On i386 and amd64, consistently use the following options whenever we
want to avoid using any "advanced" CPU features:

  -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
2011-01-05 22:24:33 +00:00
Dimitry Andric
8959d1a543 In lib/libstand, sys/boot/ficl and sys/boot/zfs, -mno-sse3 should also
be used for amd64, not just for i386.
2011-01-05 22:00:37 +00:00
Ulrich Spörlein
0d9deed52c mdoc: drop redundant .Pp and .LP calls
They have no effect when coming in pairs, or before .Bl/.Bd
2010-10-08 12:40:16 +00:00
Ed Maste
f657d618ce Increase maximum network timeout from 20s to 120s. Given that an ETIMEDOUT
return from sendrecv probably means a failure to boot we might as well be
generous in the timeout period.
2010-09-28 01:30:49 +00:00
Rick Macklem
de5f647070 Modify lib/libstand/nfs.c to use NFSv3 instead of NFSv2.
This allows the nfs_getrootfh() function to return the
correct file handle size to pxe.c for pxeboot. It also
results in NFSv2 no longer being used by default anywhere
in FreeBSD. If built with OLD_NFSV2 defined, the old
code that predated this patch will be built and NFSv2
will be used.

Tested by:	danny at cs.huji.ac.il
MFC after:	2 weeks
2010-09-02 01:00:13 +00:00
Warner Losh
25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Jung-uk Kim
4a82f10889 Use type-specific inline function imax() instead of deprecated macro MAX().
Prodded by:	bde
2010-07-12 15:32:45 +00:00