Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of rom.etherboot.org:/pub/scm/gpxe
  • Loading branch information
Michael Brown committed Jan 22, 2008
2 parents f3265b4 + f6a8158 commit 122abb5
Show file tree
Hide file tree
Showing 24 changed files with 254 additions and 226 deletions.
110 changes: 56 additions & 54 deletions src/Makefile
@@ -1,3 +1,7 @@
# Location to place generated files
#
BIN := bin

# Initialise variables that get added to throughout the various Makefiles
#
MAKEDEPS := Makefile .toolcheck .echocheck
Expand All @@ -9,34 +13,34 @@ ROMS :=
MEDIA :=
NON_AUTO_MEDIA :=

# Grab the central Config file.
#
MAKEDEPS += Config
include Config

# Location to place generated files
#
BIN := bin

# If no architecture is specified in Config or on the command-line,
# use that of the build machine.
#
ifndef ARCH
ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
endif

# handle x86_64 like i386, but set -m32 option for 32bit code only
ifeq ($(ARCH),x86_64)
ARCH := i386
CFLAGS += -m32
ASFLAGS += --32
LDFLAGS += -m elf_i386
endif

# Drag in architecture-specific Config
# Locations of utilities
#
MAKEDEPS += arch/$(ARCH)/Config
include arch/$(ARCH)/Config
HOST_CC := gcc
RM := rm -f
TOUCH := touch
MKDIR := mkdir
CP := cp
ECHO := echo
PRINTF := printf
PERL := /usr/bin/perl
CC := $(CROSS_COMPILE)gcc
CPP := $(CROSS_COMPILE)gcc -E -Wp,-Wall
AS := $(CROSS_COMPILE)as
LD := $(CROSS_COMPILE)ld
SIZE := $(CROSS_COMPILE)size
AR := $(CROSS_COMPILE)ar
RANLIB := $(CROSS_COMPILE)ranlib
OBJCOPY := $(CROSS_COMPILE)objcopy
NM := $(CROSS_COMPILE)nm
OBJDUMP := $(CROSS_COMPILE)objdump
PARSEROM := $(PERL) ./util/parserom.pl
MAKEROM := $(PERL) ./util/makerom.pl
MKCONFIG := $(PERL) ./util/mkconfig.pl
SYMCHECK := $(PERL) ./util/symcheck.pl
SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
NRV2B := ./util/nrv2b
ZBIN := ./util/zbin
DOXYGEN := doxygen

# If invoked with no build target, print out a helpfully suggestive
# message.
Expand Down Expand Up @@ -64,34 +68,28 @@ noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb
@$(ECHO)
@$(ECHO) '==========================================================='

# Locations of utilities
# Grab the central Config file.
#
MAKEDEPS += Config
include Config

# If no architecture is specified in Config or on the command-line,
# use that of the build machine.
#
ARCH ?= $(shell uname -m | sed -e s,i[3456789]86,i386,)

# handle x86_64 like i386, but set -m32 option for 32bit code only
ifeq ($(ARCH),x86_64)
ARCH := i386
CFLAGS += -m32
ASFLAGS += --32
LDFLAGS += -m elf_i386
endif

# Drag in architecture-specific Config
#
HOST_CC ?= gcc
CPP ?= gcc -E -Wp,-Wall
RM ?= rm -f
TOUCH ?= touch
MKDIR ?= mkdir
CP ?= cp
ECHO ?= echo
PRINTF ?= printf
PERL ?= /usr/bin/perl
CC ?= $(CROSS_COMPILE)gcc
AS ?= $(CROSS_COMPILE)as
LD ?= $(CROSS_COMPILE)ld
SIZE ?= $(CROSS_COMPILE)size
AR ?= $(CROSS_COMPILE)ar
RANLIB ?= $(CROSS_COMPILE)ranlib
OBJCOPY ?= $(CROSS_COMPILE)objcopy
NM ?= $(CROSS_COMPILE)nm
OBJDUMP ?= $(CROSS_COMPILE)objdump
PARSEROM ?= $(PERL) ./util/parserom.pl
MAKEROM ?= $(PERL) ./util/makerom.pl
MKCONFIG ?= $(PERL) ./util/mkconfig.pl
SYMCHECK ?= $(PERL) ./util/symcheck.pl
SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
NRV2B ?= ./util/nrv2b
ZBIN ?= ./util/zbin
DOXYGEN ?= doxygen
MAKEDEPS += arch/$(ARCH)/Config
include arch/$(ARCH)/Config

# Common flags
#
Expand All @@ -103,6 +101,10 @@ CFLAGS += $(EXTRA_CFLAGS)
ASFLAGS += $(EXTRA_ASFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)

# Embedded image, if present
#
EMBEDDED_IMAGE ?= /dev/null

ifneq ($(NO_WERROR),1)
CFLAGS += -Werror
endif
Expand Down
11 changes: 11 additions & 0 deletions src/Makefile.housekeeping
Expand Up @@ -214,6 +214,14 @@ drivers :
roms :
@$(ECHO) $(ROMS)

# Embedded binary
$(BIN)/embedimg.bin: $(EMBEDDED_IMAGE)
$(QM)$(ECHO) " [COPY] $@"
$(Q)$(CP) -f $(EMBEDDED_IMAGE) $@

$(BIN)/embed.o: $(BIN)/embedimg.bin
CFLAGS_embed = -DEMBEDIMG=\"$(BIN)/embedimg.bin\"

# Generate the NIC file from the parsed source files. The NIC file is
# only for rom-o-matic.
#
Expand Down Expand Up @@ -356,6 +364,9 @@ $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
-Map $(BIN)/$*.tmp.map
$(Q)$(OBJDUMP) -ht $@ | $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map

# Keep intermediate object file (useful for debugging)
.SECONDARY : $(BIN)/%.tmp

# Show a linker map for the specified target
#
$(BIN)/%.map : $(BIN)/%.tmp
Expand Down
69 changes: 24 additions & 45 deletions src/core/downloader.c
Expand Up @@ -96,6 +96,9 @@ static int downloader_ensure_size ( struct downloader *downloader,
if ( len <= downloader->image->len )
return 0;

DBGC ( downloader, "Downloader %p extending to %zd bytes\n",
downloader, len );

/* Extend buffer */
new_buffer = urealloc ( downloader->image->data, len );
if ( ! new_buffer ) {
Expand Down Expand Up @@ -141,68 +144,44 @@ static struct job_interface_operations downloader_job_operations = {
*
*/

/**
* Handle seek() event received via data transfer interface
*
* @v xfer Downloader data transfer interface
* @v pos New position
* @ret rc Return status code
*/
static int downloader_xfer_seek ( struct xfer_interface *xfer, off_t offset,
int whence ) {
struct downloader *downloader =
container_of ( xfer, struct downloader, xfer );
off_t new_pos;
int rc;

/* Calculate new buffer position */
switch ( whence ) {
case SEEK_SET:
new_pos = offset;
break;
case SEEK_CUR:
new_pos = ( downloader->pos + offset );
break;
default:
assert ( 0 );
return -EINVAL;
}

/* Ensure that we have enough buffer space for this buffer position */
if ( ( rc = downloader_ensure_size ( downloader, new_pos ) ) != 0 )
return rc;
downloader->pos = new_pos;

return 0;
}

/**
* Handle deliver_raw() event received via data transfer interface
*
* @v xfer Downloader data transfer interface
* @v data Data buffer
* @v len Length of data buffer
* @v iobuf Datagram I/O buffer
* @v meta Data transfer metadata
* @ret rc Return status code
*/
static int downloader_xfer_deliver_raw ( struct xfer_interface *xfer,
const void *data, size_t len ) {
static int downloader_xfer_deliver_iob ( struct xfer_interface *xfer,
struct io_buffer *iobuf,
struct xfer_metadata *meta ) {
struct downloader *downloader =
container_of ( xfer, struct downloader, xfer );
size_t len;
size_t max;
int rc;

/* Calculate new buffer position */
if ( meta->whence != SEEK_CUR )
downloader->pos = 0;
downloader->pos += meta->offset;

/* Ensure that we have enough buffer space for this data */
len = iob_len ( iobuf );
max = ( downloader->pos + len );
if ( ( rc = downloader_ensure_size ( downloader, max ) ) != 0 )
return rc;
goto done;

/* Copy data to buffer */
copy_to_user ( downloader->image->data, downloader->pos, data, len );
copy_to_user ( downloader->image->data, downloader->pos,
iobuf->data, len );

/* Update current buffer position */
downloader->pos += len;

return 0;
done:
free_iob ( iobuf );
return rc;
}

/**
Expand All @@ -227,10 +206,10 @@ static void downloader_xfer_close ( struct xfer_interface *xfer, int rc ) {
static struct xfer_interface_operations downloader_xfer_operations = {
.close = downloader_xfer_close,
.vredirect = xfer_vopen,
.seek = downloader_xfer_seek,
.window = unlimited_xfer_window,
.deliver_iob = xfer_deliver_as_raw,
.deliver_raw = downloader_xfer_deliver_raw,
.alloc_iob = default_xfer_alloc_iob,
.deliver_iob = downloader_xfer_deliver_iob,
.deliver_raw = xfer_deliver_as_iob,
};

/****************************************************************************
Expand Down
6 changes: 0 additions & 6 deletions src/core/filter.c
Expand Up @@ -44,12 +44,6 @@ int filter_vredirect ( struct xfer_interface *xfer, int type,
return xfer_vredirect ( other, type, args );
}

int filter_seek ( struct xfer_interface *xfer, off_t offset, int whence ) {
struct xfer_interface *other = filter_other_half ( xfer );

return xfer_seek ( other, offset, whence );
}

size_t filter_window ( struct xfer_interface *xfer ) {
struct xfer_interface *other = filter_other_half ( xfer );

Expand Down
2 changes: 1 addition & 1 deletion src/core/hw.c
Expand Up @@ -36,8 +36,8 @@ static void hw_xfer_close ( struct xfer_interface *xfer, int rc ) {
static struct xfer_interface_operations hw_xfer_operations = {
.close = hw_xfer_close,
.vredirect = ignore_xfer_vredirect,
.seek = ignore_xfer_seek,
.window = unlimited_xfer_window,
.alloc_iob = default_xfer_alloc_iob,
.deliver_iob = xfer_deliver_as_raw,
.deliver_raw = ignore_xfer_deliver_raw,
};
Expand Down
37 changes: 8 additions & 29 deletions src/core/posix_io.c
Expand Up @@ -103,39 +103,12 @@ static void posix_file_xfer_close ( struct xfer_interface *xfer, int rc ) {
posix_file_finished ( file, rc );
}

/**
* Handle seek() event
*
* @v xfer POSIX file data transfer interface
* @v pos New position
* @ret rc Return status code
*/
static int posix_file_xfer_seek ( struct xfer_interface *xfer, off_t offset,
int whence ) {
struct posix_file *file =
container_of ( xfer, struct posix_file, xfer );

switch ( whence ) {
case SEEK_SET:
file->pos = offset;
break;
case SEEK_CUR:
file->pos += offset;
break;
}

if ( file->filesize < file->pos )
file->filesize = file->pos;

return 0;
}

/**
* Handle deliver_iob() event
*
* @v xfer POSIX file data transfer interface
* @v iobuf I/O buffer
* @v meta Data transfer metadata, or NULL
* @v meta Data transfer metadata
* @ret rc Return status code
*/
static int
Expand All @@ -145,6 +118,13 @@ posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
struct posix_file *file =
container_of ( xfer, struct posix_file, xfer );

/* Keep track of file position solely for the filesize */
if ( meta->whence != SEEK_CUR )
file->pos = 0;
file->pos += meta->offset;
if ( file->filesize < file->pos )
file->filesize = file->pos;

list_add_tail ( &iobuf->list, &file->data );
return 0;
}
Expand All @@ -153,7 +133,6 @@ posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
static struct xfer_interface_operations posix_file_xfer_operations = {
.close = posix_file_xfer_close,
.vredirect = xfer_vopen,
.seek = posix_file_xfer_seek,
.window = unlimited_xfer_window,
.alloc_iob = default_xfer_alloc_iob,
.deliver_iob = posix_file_xfer_deliver_iob,
Expand Down
1 change: 0 additions & 1 deletion src/core/resolv.c
Expand Up @@ -312,7 +312,6 @@ struct named_socket {
static struct xfer_interface_operations named_xfer_ops = {
.close = ignore_xfer_close,
.vredirect = ignore_xfer_vredirect,
.seek = ignore_xfer_seek,
.window = no_xfer_window,
.alloc_iob = default_xfer_alloc_iob,
.deliver_iob = xfer_deliver_as_raw,
Expand Down

0 comments on commit 122abb5

Please sign in to comment.