aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/async.c474
-rw-r--r--src/core/btext.c4
-rw-r--r--src/core/debug.c1
-rw-r--r--src/core/dev.c7
-rw-r--r--src/core/disk.c4
-rw-r--r--src/core/misc.c5
-rw-r--r--src/core/pcmcia.c15
-rw-r--r--src/core/random.c1
-rw-r--r--src/core/serial.c2
9 files changed, 26 insertions, 487 deletions
diff --git a/src/core/async.c b/src/core/async.c
deleted file mode 100644
index d1ae077..0000000
--- a/src/core/async.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-#include <gpxe/process.h>
-#include <gpxe/async.h>
-
-/** @file
- *
- * Asynchronous operations
- *
- */
-
-/**
- * Name signal
- *
- * @v signal Signal number
- * @ret name Name of signal
- */
-static inline __attribute__ (( always_inline )) const char *
-signal_name ( enum signal signal ) {
- switch ( signal ) {
- case SIGCHLD: return "SIGCHLD";
- case SIGKILL: return "SIGKILL";
- case SIGUPDATE: return "SIGUPDATE";
- default: return "SIG<UNKNOWN>";
- }
-}
-
-/**
- * Initialise an asynchronous operation
- *
- * @v async Asynchronous operation
- * @v aop Asynchronous operation operations to use
- * @v parent Parent asynchronous operation, or NULL
- * @ret aid Asynchronous operation ID
- *
- * It is valid to create an asynchronous operation with no parent
- * operation; see async_init_orphan().
- */
-aid_t async_init ( struct async *async, struct async_operations *aop,
- struct async *parent ) {
- static aid_t aid = 1;
-
- /* Assign identifier. Negative IDs are used to indicate
- * errors, so avoid assigning them.
- */
- ++aid;
- aid &= ( ( ~( ( aid_t ) 0 ) ) >> 1 );
-
- DBGC ( async, "ASYNC %p (type %p) initialising as", async, aop );
- if ( parent ) {
- DBGC ( async, " child of ASYNC %p", parent );
- } else {
- DBGC ( async, " orphan" );
- }
- DBGC ( async, " with ID %ld\n", aid );
-
- assert ( async != NULL );
- assert ( aop != NULL );
-
- /* Add to hierarchy */
- if ( parent ) {
- async->parent = parent;
- list_add ( &async->siblings, &parent->children );
- }
- INIT_LIST_HEAD ( &async->children );
-
- /* Initialise fields */
- async->rc = -EINPROGRESS;
- async->completed = 0;
- async->total = 0;
- async->aop = aop;
- async->aid = aid;
-
- return async->aid;
-}
-
-/**
- * Uninitialise an asynchronous operation
- *
- * @v async Asynchronous operation
- *
- * Abandon an asynchronous operation without signalling the parent.
- * You may do this only during the period between calling async_init()
- * and returning to the parent for the first time. It is designed to
- * simplify the error paths of asynchronous operations that themselves
- * spawn further asynchronous operations.
- *
- * An example may help:
- *
- * int start_something ( ..., struct async *parent ) {
- * struct my_data_structure *myself;
- *
- * ... allocate memory for myself ...
- *
- * async_init ( &myself->async, &my_async_operations, parent );
- * if ( ( rc = start_child_operation ( ..., &myself->async ) ) != 0 ) {
- * async_uninit ( &myself->async );
- * return rc;
- * }
- *
- * return 0;
- * }
- *
- * It is valid to call async_uninit() on an asynchronous operation
- * that has not yet been initialised (i.e. a zeroed-out @c struct @c
- * async).
- */
-void async_uninit ( struct async *async ) {
-
- assert ( async != NULL );
-
- if ( async->parent ) {
- assert ( list_empty ( &async->children ) );
-
- DBGC ( async, "ASYNC %p uninitialising\n", async );
- list_del ( &async->siblings );
- }
-}
-
-/**
- * SIGCHLD 'ignore' handler
- *
- * @v async Asynchronous operation
- * @v signal Signal received
- */
-static void async_ignore_sigchld ( struct async *async, enum signal signal ) {
- aid_t waited_aid;
-
- assert ( async != NULL );
- assert ( signal == SIGCHLD );
-
- /* Reap the child */
- waited_aid = async_wait ( async, NULL, 0 );
- assert ( waited_aid >= 0 );
-}
-
-/**
- * SIGUPDATE 'ignore' handler
- *
- * @v async Asynchronous operation
- * @v signal Signal received
- */
-static void async_ignore_sigupdate ( struct async *async,
- enum signal signal ) {
- struct async *child;
-
- assert ( async != NULL );
- assert ( signal == SIGUPDATE );
-
- async_signal_children ( async, signal );
- async->completed = 0;
- async->total = 0;
- list_for_each_entry ( child, &async->children, siblings ) {
- async->completed += child->completed;
- async->total += child->total;
- }
-}
-
-/**
- * 'Ignore' signal handler
- *
- * @v async Asynchronous operation
- * @v signal Signal received
- */
-void async_ignore_signal ( struct async *async, enum signal signal ) {
-
- DBGC ( async, "ASYNC %p using ignore handler for %s\n",
- async, signal_name ( signal ) );
-
- assert ( async != NULL );
-
- switch ( signal ) {
- case SIGCHLD:
- async_ignore_sigchld ( async, signal );
- break;
- case SIGUPDATE:
- async_ignore_sigupdate ( async, signal );
- break;
- case SIGKILL:
- default:
- /* Nothing to do */
- break;
- }
-}
-
-/**
- * Default signal handler
- *
- * @v async Asynchronous operation
- * @v signal Signal received
- */
-static void async_default_signal ( struct async *async, enum signal signal ) {
-
- DBGC ( async, "ASYNC %p using default handler for %s\n",
- async, signal_name ( signal ) );
-
- assert ( async != NULL );
-
- switch ( signal ) {
- case SIGCHLD:
- case SIGKILL:
- case SIGUPDATE:
- default:
- /* Nothing to do */
- break;
- }
-}
-
-/**
- * Send signal to asynchronous operation
- *
- * @v async Asynchronous operation
- * @v signal Signal to send
- */
-void async_signal ( struct async *async, enum signal signal ) {
- signal_handler_t handler;
-
- DBGC ( async, "ASYNC %p receiving %s\n",
- async, signal_name ( signal ) );
-
- assert ( async != NULL );
- assert ( async->aop != NULL );
- assert ( signal < SIGMAX );
-
- handler = async->aop->signal[signal];
- if ( handler ) {
- /* Use the asynchronous operation's signal handler */
- handler ( async, signal );
- } else {
- /* Use the default handler */
- async_default_signal ( async, signal );
- }
-}
-
-/**
- * Send signal to all child asynchronous operations
- *
- * @v async Asynchronous operation
- * @v signal Signal to send
- */
-void async_signal_children ( struct async *async, enum signal signal ) {
- struct async *child;
- struct async *tmp;
-
- assert ( async != NULL );
-
- list_for_each_entry_safe ( child, tmp, &async->children, siblings ) {
- async_signal ( child, signal );
- }
-}
-
-/**
- * Reap default handler
- *
- * @v async Asynchronous operation
- */
-static void async_reap_default ( struct async *async ) {
-
- DBGC ( async, "ASYNC %p ignoring REAP\n", async );
-
- assert ( async != NULL );
-
- /* Nothing to do */
-}
-
-/**
- * Reap asynchronous operation
- *
- * @v async Asynchronous operation
- *
- * Note that the asynchronous operation should have been freed by
- * calling this function; you may not dereference @c async after this
- * call.
- */
-static void async_reap ( struct async *async ) {
-
- DBGC ( async, "ASYNC %p being reaped, exit status %d (%s)\n",
- async, async->rc, strerror ( async->rc ) );
-
- assert ( async != NULL );
- assert ( async->aop != NULL );
- assert ( list_empty ( &async->children ) );
-
- /* Unlink from hierarchy */
- if ( async->parent )
- list_del ( &async->siblings );
- async->parent = NULL;
-
- /* Release all resources */
- if ( async->aop->reap ) {
- async->aop->reap ( async );
- } else {
- async_reap_default ( async );
- }
-}
-
-/**
- * Mark asynchronous operation as complete
- *
- * @v async Asynchronous operation
- * @v rc Return status code
- *
- * An asynchronous operation should call this once it has completed.
- * After calling async_done(), it must be prepared to be reaped by
- * having its reap() method called.
- */
-void async_done ( struct async *async, int rc ) {
- struct async *child;
- struct async *tmp;
-
- DBGC ( async, "ASYNC %p completing with status %d (%s)\n",
- async, rc, strerror ( rc ) );
-
- assert ( async != NULL );
- assert ( async->parent != NULL );
- assert ( rc != -EINPROGRESS );
-
- /* Store return status code */
- async->rc = rc;
-
- /* Disown all of our children */
- list_for_each_entry_safe ( child, tmp, &async->children, siblings ) {
- DBGC ( async, "ASYNC %p disowning child ASYNC %p\n",
- async, child );
- list_del ( &child->siblings );
- child->parent = NULL;
- }
-
- /* Send SIGCHLD to parent. If we don't have a parent then we
- * have to take care of our own funeral arrangements.
- */
- if ( async->parent ) {
- async_signal ( async->parent, SIGCHLD );
- } else {
- async_reap ( async );
- }
-}
-
-/**
- * Wait for any child asynchronous operation to complete
- *
- * @v child Child asynchronous operation
- * @v rc Child exit status to fill in, or NULL
- * @v block Block waiting for child operation to complete
- * @ret aid Asynchronous operation ID, or -1 on error
- */
-aid_t async_wait ( struct async *async, int *rc, int block ) {
- struct async *child;
- aid_t child_aid;
- int dummy_rc;
-
- DBGC ( async, "ASYNC %p performing %sblocking wait%s\n", async,
- ( block ? "" : "non-" ), ( rc ? "" : " (ignoring status)" ) );
-
- assert ( async != NULL );
-
- /* Avoid multiple tests for "if ( rc )" */
- if ( ! rc )
- rc = &dummy_rc;
-
- while ( 1 ) {
-
- /* Return immediately if we have no children */
- if ( list_empty ( &async->children ) ) {
- DBGC ( async, "ASYNC %p has no more children\n",
- async );
- *rc = -ECHILD;
- return -1;
- }
-
- /* Look for a completed child */
- list_for_each_entry ( child, &async->children, siblings ) {
- if ( child->rc == -EINPROGRESS )
- continue;
-
- /* Found a completed child */
- *rc = child->rc;
- child_aid = child->aid;
-
- DBGC ( async, "ASYNC %p reaping child ASYNC %p "
- "(ID %ld)\n", async, child, child_aid );
-
- /* Reap the child and return */
- async_reap ( child );
- return child_aid;
- }
-
- /* Return immediately if non-blocking */
- if ( ! block ) {
- *rc = -EINPROGRESS;
- return -1;
- }
-
- /* Allow processes to run */
- step();
- }
-}
-
-/**
- * Wait for any child asynchronous operation to complete, with progress bar
- *
- * @v child Child asynchronous operation
- * @v rc Child exit status to fill in, or NULL
- * @ret aid Asynchronous operation ID, or -1 on error
- */
-aid_t async_wait_progress ( struct async *async, int *rc ) {
- struct async *child;
- long last_progress = -1;
- long progress;
- aid_t child_aid;
-
- do {
- step();
- async_signal ( async, SIGUPDATE );
- if ( async->total ) {
- progress = ( async->completed / (async->total / 100) );
- if ( progress != last_progress )
- printf ( "\rProgress: %d%%", progress );
- last_progress = progress;
- }
- child_aid = async_wait ( async, rc, 0 );
- } while ( *rc == -EINPROGRESS );
-
- printf ( "\n" );
- return child_aid;
-}
-
-/**
- * Default asynchronous operations
- *
- * The default is to ignore SIGCHLD (i.e. to automatically reap
- * children) and to use the default handler (i.e. do nothing) for all
- * other signals.
- */
-struct async_operations default_async_operations = {
- .signal = {
- [SIGCHLD] = SIG_IGN,
- [SIGUPDATE] = SIG_IGN,
- },
-};
-
-/**
- * Default asynchronous operations for orphan asynchronous operations
- *
- * The default for orphan asynchronous operations is to do nothing for
- * SIGCHLD (i.e. to not automatically reap children), on the
- * assumption that you're probably creating the orphan solely in order
- * to async_wait() on it.
- */
-struct async_operations orphan_async_operations = {
- .signal = {
- [SIGCHLD] = SIG_DFL,
- [SIGUPDATE] = SIG_IGN,
- },
-};
diff --git a/src/core/btext.c b/src/core/btext.c
index 409c429..6e1a29e 100644
--- a/src/core/btext.c
+++ b/src/core/btext.c
@@ -1,3 +1,5 @@
+#if 0
+
/*
* Procedures for drawing on the screen early on in the boot process.
*
@@ -5037,3 +5039,5 @@ static const unsigned char vga_font[cmapsz] BTDATA = {
0x00, /* 00000000 */
#endif
};
+
+#endif
diff --git a/src/core/debug.c b/src/core/debug.c
index 4754bfd..d72b3df 100644
--- a/src/core/debug.c
+++ b/src/core/debug.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <io.h>
diff --git a/src/core/dev.c b/src/core/dev.c
index 541a9eb..582edf8 100644
--- a/src/core/dev.c
+++ b/src/core/dev.c
@@ -1,6 +1,7 @@
-#include "etherboot.h"
-#include "stddef.h"
-#include "dev.h"
+#include <stdio.h>
+#include <etherboot.h>
+#include <stddef.h>
+#include <dev.h>
/*
* Each bus driver defines several methods, which are described in
diff --git a/src/core/disk.c b/src/core/disk.c
index 2ccd5ff..415fdec 100644
--- a/src/core/disk.c
+++ b/src/core/disk.c
@@ -1,5 +1,5 @@
-#include "etherboot.h"
-#include "disk.h"
+#include <etherboot.h>
+#include <disk.h>
#warning "disk.c is currently broken"
#if 0
diff --git a/src/core/misc.c b/src/core/misc.c
index e214a62..5839913 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -2,9 +2,10 @@
MISC Support Routines
**************************************************************************/
-#include "etherboot.h"
-#include "console.h"
+#include <etherboot.h>
+#include <console.h>
#include <stdlib.h>
+#include <stdio.h>
/**************************************************************************
IPCHKSUM - Checksum IP Header
diff --git a/src/core/pcmcia.c b/src/core/pcmcia.c
index c15fe9c..53d4541 100644
--- a/src/core/pcmcia.c
+++ b/src/core/pcmcia.c
@@ -1,3 +1,5 @@
+#if 0
+
/*
* pcmcia.c
*
@@ -23,12 +25,13 @@
* at some point. If there's anything obvious or better, not-so-obvious,
* please contact me by e-mail: anselm (AT) hoffmeister (DOT) be *THANKS*
*/
-#include "pcmcia.h"
-#include "i82365.h"
+#include <stdio.h>
+#include <pcmcia.h>
+#include <i82365.h>
#define CODE_STATUS "alpha"
#define CODE_VERSION "0.1.3"
-#include "pcmcia-opts.h"
-#include "console.h"
+#include <pcmcia-opts.h>
+#include <console.h>
#include <gpxe/init.h>
int sockets; /* AHTODO: Phase this out! */
@@ -118,7 +121,7 @@ static void pcmcia_init_all(void) {
printf ( "]\nHighest config available is %d\n", uc[2*(ui+3)] );
m = uc[2*(ui+2)];
pccsock[i].configoffset = 0;
- for ( j = 0; j <= m & 3; ++j ) {
+ for ( j = 0; j <= (m & 3); ++j ) {
pccsock[i].configoffset += uc[2*(ui+4+j)] << (8*j);
}
pccsock[i].rmask0 = 0;
@@ -262,3 +265,5 @@ static void pcmcia_shutdown_all(void) {
}
INIT_FN ( INIT_PCMCIA, pcmcia_init_all, NULL, pcmcia_shutdown_all );
+
+#endif
diff --git a/src/core/random.c b/src/core/random.c
index c15bb6d..0d914c9 100644
--- a/src/core/random.c
+++ b/src/core/random.c
@@ -5,6 +5,7 @@
*/
#include <stdlib.h>
+#include <etherboot.h>
static int32_t rnd_seed = 0;
diff --git a/src/core/serial.c b/src/core/serial.c
index d082748..6304037 100644
--- a/src/core/serial.c
+++ b/src/core/serial.c
@@ -213,7 +213,7 @@ static void serial_init ( void ) {
/* rx buffer reg
* throw away (unconditionally the first time)
*/
- uart_readb(UART_BASE + UART_RBR);
+ (void) uart_readb(UART_BASE + UART_RBR);
/* line status reg */
status = uart_readb(UART_BASE + UART_LSR);
} while(status & UART_LSR_DR);