Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ccboot] Changes for CCBoot
  • Loading branch information
Yaoer authored and mcb30 committed Dec 9, 2010
1 parent 53e9fb5 commit e57521d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
17 changes: 16 additions & 1 deletion src/core/main.c
Expand Up @@ -22,26 +22,41 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <gpxe/image.h>
#include <usr/autoboot.h>
#include <config/general.h>
#include <curses.h>
#include <console.h>
#include <unistd.h>

#define NORMAL "\033[0m"
#define BOLD "\033[1m"
#define CYAN "\033[36m"


/**
* Main entry point
*
* @ret rc Return status code
*/
__asmcall int main ( void ) {
#if 0
struct feature *feature;
struct image *image;

/* Some devices take an unreasonably long time to initialise */
printf ( PRODUCT_SHORT_NAME " initialising devices...\n" );
#endif

initialise();
startup();

printf( CYAN BOLD);
printf( "CCBoot");
printf( NORMAL);
printf( " 2010/10/06 http://www.ccboot.com\n");

autoboot();

#if 0

/*
* Print welcome banner
*
Expand Down Expand Up @@ -84,8 +99,8 @@ __asmcall int main ( void ) {
if ( shell_banner() )
shell();
}
#endif

shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );

return 0;
}
36 changes: 19 additions & 17 deletions src/usr/autoboot.c
Expand Up @@ -129,17 +129,21 @@ int boot_root_path ( const char *root_path ) {
* @ret rc Return status code
*/
static int netboot ( struct net_device *netdev ) {

struct setting vendor_class_id_setting
= { .tag = DHCP_VENDOR_CLASS_ID };
struct setting pxe_discovery_control_setting
= { .tag = DHCP_PXE_DISCOVERY_CONTROL };
struct setting pxe_boot_menu_setting
= { .tag = DHCP_PXE_BOOT_MENU };

char buf[256];

struct in_addr next_server;
unsigned int pxe_discovery_control;
int rc;


/* Open device and display device status */
if ( ( rc = ifopen ( netdev ) ) != 0 )
return rc;
Expand All @@ -152,44 +156,43 @@ static int netboot ( struct net_device *netdev ) {

/* Try PXE menu boot, if applicable */
fetch_string_setting ( NULL, &vendor_class_id_setting,
buf, sizeof ( buf ) );
buf, sizeof ( buf ) );
pxe_discovery_control =
fetch_uintz_setting ( NULL, &pxe_discovery_control_setting );
if ( ( strcmp ( buf, "PXEClient" ) == 0 ) && pxe_menu_boot != NULL &&
setting_exists ( NULL, &pxe_boot_menu_setting ) &&
( ! ( ( pxe_discovery_control & PXEBS_SKIP ) &&
setting_exists ( NULL, &filename_setting ) ) ) ) {
printf ( "Booting from PXE menu\n" );
return pxe_menu_boot ( netdev );
setting_exists ( NULL, &pxe_boot_menu_setting ) &&
( ! ( ( pxe_discovery_control & PXEBS_SKIP ) &&
setting_exists ( NULL, &filename_setting ) ) ) ) {
printf ( "Booting from PXE menu\n" );
return pxe_menu_boot ( netdev );
}

/* Try to download and boot whatever we are given as a filename */
fetch_ipv4_setting ( NULL, &next_server_setting, &next_server );
fetch_string_setting ( NULL, &filename_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
printf ( "Booting from filename \"%s\"\n", buf );
if ( buf[0] && strcmp(buf, "gpxe.pxe") && strcmp(buf, "gpxex.pxe")) {
// printf ( "Booting from filename \"%s\"\n", buf );
if ( ( rc = boot_next_server_and_filename ( next_server,
buf ) ) != 0 ) {
printf ( "Could not boot from filename \"%s\": %s\n",
buf, strerror ( rc ) );
return rc;
buf ) ) != 0 ) {
//printf ( "Could not boot from filename \"%s\": %s\n",
// buf, strerror ( rc ) );
return rc;
}
return 0;
}

/* No filename; try the root path */
fetch_string_setting ( NULL, &root_path_setting, buf, sizeof ( buf ) );
if ( buf[0] ) {
printf ( "Booting from root path \"%s\"\n", buf );
// printf ( "Booting from root path \"%s\"\n", buf );
if ( ( rc = boot_root_path ( buf ) ) != 0 ) {
printf ( "Could not boot from root path \"%s\": %s\n",
buf, strerror ( rc ) );
buf, strerror ( rc ) );
return rc;
}
return 0;
}

printf ( "No filename or root path specified\n" );
return -ENOENT;
}

Expand Down Expand Up @@ -228,6 +231,5 @@ void autoboot ( void ) {
close_all_netdevs();
netboot ( netdev );
}

printf ( "No more network devices\n" );
}

0 comments on commit e57521d

Please sign in to comment.