Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Johnson committed Aug 8, 2011
2 parents c3138c5 + 8a86a84 commit 3d89959
Show file tree
Hide file tree
Showing 49 changed files with 1,395 additions and 541 deletions.
10 changes: 8 additions & 2 deletions src/Makefile.housekeeping
Expand Up @@ -450,14 +450,20 @@ endif

# Enable per-item sections and section garbage collection. Note that
# some older versions of gcc support -fdata-sections but treat it as
# implying -fno-common, which would break our build.
# implying -fno-common, which would break our build. Some other older
# versions issue a spurious and uninhibitable warning if
# -ffunction-sections is used with -g, which would also break our
# build since we use -Werror.
#
ifeq ($(CCTYPE),gcc)
DS_TEST = $(ECHO) 'char x;' | \
$(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \
grep -E '\.comm' > /dev/null
DS_FLAGS := $(shell $(DS_TEST) && $(ECHO) '-fdata-sections')
CFLAGS += -ffunction-sections $(DS_FLAGS)
FS_TEST = $(CC) -ffunction-sections -g -c -x c /dev/null \
-o /dev/null 2>/dev/null
FS_FLAGS := $(shell $(FS_TEST) && $(ECHO) '-ffunction-sections')
CFLAGS += $(FS_FLAGS) $(DS_FLAGS)
endif
LDFLAGS += --gc-sections

Expand Down
18 changes: 14 additions & 4 deletions src/arch/i386/core/cmdline.c
Expand Up @@ -66,7 +66,8 @@ static void cmdline_init ( void ) {
struct image *image = &cmdline_image;
userptr_t cmdline_user;
char *cmdline;
char *tmp;
char *boot_image;
char *boot_image_end;
size_t len;

/* Do nothing if no command line was specified */
Expand All @@ -91,9 +92,18 @@ static void cmdline_init ( void ) {
/* Check for unwanted cruft in the command line */
while ( isspace ( *cmdline ) )
cmdline++;
if ( ( tmp = strstr ( cmdline, "BOOT_IMAGE=" ) ) != NULL ) {
DBGC ( image, "CMDLINE stripping \"%s\"\n", tmp );
*tmp = '\0';
if ( ( boot_image = strstr ( cmdline, "BOOT_IMAGE=" ) ) != NULL ) {
boot_image_end = strchr ( boot_image, ' ' );
if ( boot_image_end ) {
*boot_image_end = '\0';
DBGC ( image, "CMDLINE stripping \"%s\"\n",
boot_image );
strcpy ( boot_image, ( boot_image_end + 1 ) );
} else {
DBGC ( image, "CMDLINE stripping \"%s\"\n",
boot_image );
*boot_image = '\0';
}
}
DBGC ( image, "CMDLINE using \"%s\"\n", cmdline );

Expand Down
3 changes: 2 additions & 1 deletion src/arch/i386/include/efi/ipxe/dhcp_arch.h
Expand Up @@ -33,7 +33,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '6', ':', \
'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0' )

#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_WORD ( 6 )
#define DHCP_ARCH_CLIENT_ARCHITECTURE \
DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_IA32 )

#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ )

Expand Down
3 changes: 2 additions & 1 deletion src/arch/i386/include/pcbios/ipxe/dhcp_arch.h
Expand Up @@ -33,7 +33,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '0', ':', \
'U', 'N', 'D', 'I', ':', '0', '0', '2', '0', '0', '1' )

#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_WORD ( 0 )
#define DHCP_ARCH_CLIENT_ARCHITECTURE \
DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_X86 )

#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 2, 1 /* v2.1 */ )

Expand Down
15 changes: 15 additions & 0 deletions src/arch/i386/interface/pcbios/int13.c
Expand Up @@ -1333,6 +1333,20 @@ static void int13_unhook_vector ( void ) {
&int13_vector );
}

/**
* Check INT13 emulated drive flow control window
*
* @v int13 Emulated drive
*/
static size_t int13_block_window ( struct int13_drive *int13 __unused ) {

/* We are never ready to receive data via this interface.
* This prevents objects that support both block and stream
* interfaces from attempting to send us stream data.
*/
return 0;
}

/**
* Handle INT 13 emulated drive underlying block device closing
*
Expand All @@ -1357,6 +1371,7 @@ static void int13_block_close ( struct int13_drive *int13, int rc ) {

/** INT 13 drive interface operations */
static struct interface_operation int13_block_op[] = {
INTF_OP ( xfer_window, struct int13_drive *, int13_block_window ),
INTF_OP ( intf_close, struct int13_drive *, int13_block_close ),
};

Expand Down
14 changes: 7 additions & 7 deletions src/arch/i386/interface/pxe/pxe_undi.c
Expand Up @@ -652,6 +652,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
const void *ll_dest;
const void *ll_source;
uint16_t net_proto;
unsigned int flags;
size_t ll_hlen;
struct net_protocol *net_protocol;
unsigned int prottype;
Expand Down Expand Up @@ -753,7 +754,8 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
/* Strip link-layer header */
ll_protocol = pxe_netdev->ll_protocol;
if ( ( rc = ll_protocol->pull ( pxe_netdev, iobuf, &ll_dest,
&ll_source, &net_proto )) !=0){
&ll_source, &net_proto,
&flags ) ) != 0 ) {
/* Assume unknown net_proto and no ll_source */
net_proto = 0;
ll_source = NULL;
Expand Down Expand Up @@ -788,14 +790,12 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
undi_isr->Frame.segment = rm_ds;
undi_isr->Frame.offset = __from_data16 ( basemem_packet );
undi_isr->ProtType = prottype;
if ( memcmp ( ll_dest, pxe_netdev->ll_addr,
ll_protocol->ll_addr_len ) == 0 ) {
undi_isr->PktType = P_DIRECTED;
} else if ( memcmp ( ll_dest, pxe_netdev->ll_broadcast,
ll_protocol->ll_addr_len ) == 0 ) {
if ( flags & LL_BROADCAST ) {
undi_isr->PktType = P_BROADCAST;
} else {
} else if ( flags & LL_MULTICAST ) {
undi_isr->PktType = P_MULTICAST;
} else {
undi_isr->PktType = P_DIRECTED;
}
DBGC2 ( &pxenv_undi_isr, " %04x:%04x+%x(%x) %s hlen %d",
undi_isr->Frame.segment, undi_isr->Frame.offset,
Expand Down
2 changes: 1 addition & 1 deletion src/arch/i386/prefix/lkrnprefix.S
Expand Up @@ -160,7 +160,7 @@ relocatable_kernel:
pad2:
.byte 0, 0, 0
cmdline_size:
.long 0
.long 0x7ff
hardware_subarch:
.long 0
hardware_subarch_data:
Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/prefix/romprefix.S
Expand Up @@ -445,7 +445,7 @@ get_pmm:
/* Preserve registers */
pushl %eax
pushw %di
movw $' ', %di
movw $( ' ' ), %di
get_pmm_find:
/* Try to find existing block */
pushl %ebx /* PMM handle */
Expand Down Expand Up @@ -474,7 +474,7 @@ get_pmm_allocate:
pushw %dx
pushw %ax
popl %esi
movw $'+', %di /* Indicate allocation attempt */
movw $( '+' ), %di /* Indicate allocation attempt */
testl %esi, %esi
jnz get_pmm_done
stc
Expand Down
5 changes: 3 additions & 2 deletions src/arch/x86_64/include/efi/ipxe/dhcp_arch.h
Expand Up @@ -30,10 +30,11 @@ FILE_LICENCE ( GPL2_OR_LATER );

#define DHCP_ARCH_VENDOR_CLASS_ID \
DHCP_STRING ( 'P', 'X', 'E', 'C', 'l', 'i', 'e', 'n', 't', ':', \
'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '7', ':', \
'A', 'r', 'c', 'h', ':', '0', '0', '0', '0', '9', ':', \
'U', 'N', 'D', 'I', ':', '0', '0', '3', '0', '1', '0' )

#define DHCP_ARCH_CLIENT_ARCHITECTURE DHCP_WORD ( 7 )
#define DHCP_ARCH_CLIENT_ARCHITECTURE \
DHCP_WORD ( DHCP_CLIENT_ARCHITECTURE_X86_64 )

#define DHCP_ARCH_CLIENT_NDI DHCP_OPTION ( 1 /* UNDI */ , 3, 10 /* v3.10 */ )

Expand Down
23 changes: 13 additions & 10 deletions src/core/hw.c
Expand Up @@ -26,15 +26,7 @@ static void hw_finished ( struct hw *hw, int rc ) {
process_del ( &hw->process );
}

static struct interface_operation hw_xfer_operations[] = {
INTF_OP ( intf_close, struct hw *, hw_finished ),
};

static struct interface_descriptor hw_xfer_desc =
INTF_DESC ( struct hw, xfer, hw_xfer_operations );

static void hw_step ( struct process *process ) {
struct hw *hw = container_of ( process, struct hw, process );
static void hw_step ( struct hw *hw ) {
int rc;

if ( xfer_window ( &hw->xfer ) ) {
Expand All @@ -43,6 +35,17 @@ static void hw_step ( struct process *process ) {
}
}

static struct interface_operation hw_xfer_operations[] = {
INTF_OP ( xfer_window_changed, struct hw *, hw_step ),
INTF_OP ( intf_close, struct hw *, hw_finished ),
};

static struct interface_descriptor hw_xfer_desc =
INTF_DESC ( struct hw, xfer, hw_xfer_operations );

static struct process_descriptor hw_process_desc =
PROC_DESC_ONCE ( struct hw, process, hw_step );

static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
struct hw *hw;

Expand All @@ -52,7 +55,7 @@ static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
return -ENOMEM;
ref_init ( &hw->refcnt, NULL );
intf_init ( &hw->xfer, &hw_xfer_desc, &hw->refcnt );
process_init ( &hw->process, hw_step, &hw->refcnt );
process_init ( &hw->process, &hw_process_desc, &hw->refcnt );

/* Attach parent interface, mortalise self, and return */
intf_plug_plug ( &hw->xfer, xfer );
Expand Down
48 changes: 33 additions & 15 deletions src/core/process.c
Expand Up @@ -33,6 +33,16 @@ FILE_LICENCE ( GPL2_OR_LATER );
/** Process run queue */
static LIST_HEAD ( run_queue );

/**
* Get pointer to object containing process
*
* @v process Process
* @ret object Containing object
*/
void * process_object ( struct process *process ) {
return ( ( ( void * ) process ) - process->desc->offset );
}

/**
* Add process to process list
*
Expand All @@ -43,13 +53,13 @@ static LIST_HEAD ( run_queue );
*/
void process_add ( struct process *process ) {
if ( ! process_running ( process ) ) {
DBGC ( process, "PROCESS %p (%p) starting\n",
process, process->step );
DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
" starting\n", PROC_DBG ( process ) );
ref_get ( process->refcnt );
list_add_tail ( &process->list, &run_queue );
} else {
DBGC ( process, "PROCESS %p (%p) already started\n",
process, process->step );
DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
" already started\n", PROC_DBG ( process ) );
}
}

Expand All @@ -63,14 +73,14 @@ void process_add ( struct process *process ) {
*/
void process_del ( struct process *process ) {
if ( process_running ( process ) ) {
DBGC ( process, "PROCESS %p (%p) stopping\n",
process, process->step );
DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
" stopping\n", PROC_DBG ( process ) );
list_del ( &process->list );
INIT_LIST_HEAD ( &process->list );
ref_put ( process->refcnt );
} else {
DBGC ( process, "PROCESS %p (%p) already stopped\n",
process, process->step );
DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
" already stopped\n", PROC_DBG ( process ) );
}
}

Expand All @@ -82,17 +92,25 @@ void process_del ( struct process *process ) {
*/
void step ( void ) {
struct process *process;
struct process_descriptor *desc;
void *object;

if ( ( process = list_first_entry ( &run_queue, struct process,
list ) ) ) {
list_del ( &process->list );
list_add_tail ( &process->list, &run_queue );
ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
DBGC2 ( process, "PROCESS %p (%p) executing\n",
process, process->step );
process->step ( process );
DBGC2 ( process, "PROCESS %p (%p) finished executing\n",
process, process->step );
desc = process->desc;
object = process_object ( process );
if ( desc->reschedule ) {
list_del ( &process->list );
list_add_tail ( &process->list, &run_queue );
} else {
process_del ( process );
}
DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
" executing\n", PROC_DBG ( process ) );
desc->step ( object );
DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
" finished executing\n", PROC_DBG ( process ) );
ref_put ( process->refcnt ); /* Allow destruction */
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/core/resolv.c
Expand Up @@ -86,16 +86,16 @@ struct numeric_resolv {
int rc;
};

static void numeric_step ( struct process *process ) {
struct numeric_resolv *numeric =
container_of ( process, struct numeric_resolv, process );
static void numeric_step ( struct numeric_resolv *numeric ) {

process_del ( process );
if ( numeric->rc == 0 )
resolv_done ( &numeric->resolv, &numeric->sa );
intf_shutdown ( &numeric->resolv, numeric->rc );
}

static struct process_descriptor numeric_process_desc =
PROC_DESC_ONCE ( struct numeric_resolv, process, numeric_step );

static int numeric_resolv ( struct interface *resolv,
const char *name, struct sockaddr *sa ) {
struct numeric_resolv *numeric;
Expand All @@ -107,7 +107,8 @@ static int numeric_resolv ( struct interface *resolv,
return -ENOMEM;
ref_init ( &numeric->refcnt, NULL );
intf_init ( &numeric->resolv, &null_intf_desc, &numeric->refcnt );
process_init ( &numeric->process, numeric_step, &numeric->refcnt );
process_init ( &numeric->process, &numeric_process_desc,
&numeric->refcnt );
memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );

DBGC ( numeric, "NUMERIC %p attempting to resolve \"%s\"\n",
Expand Down

0 comments on commit 3d89959

Please sign in to comment.