netboot: Support gigaboot when not running on UEFI.
These don't support a ramdisk since there isn't yet a good way to allocate
large blocks of memory when not hosted.
Change-Id: Ie4de1a09938e8ef23ebe3a7192b261c27945d8c5
diff --git a/src/debug/netboot.c b/src/debug/netboot.c
index 6094dbf..8953919 100644
--- a/src/debug/netboot.c
+++ b/src/debug/netboot.c
@@ -18,8 +18,10 @@
*/
#include <stdio.h>
+#include <string.h>
#include "drivers/console/display.h"
+#include "net/gigaboot/gigaboot.h"
#include "net/netboot/netboot.h"
#include "net/netboot/params.h"
@@ -28,10 +30,33 @@
* the symbols from stubs.c. They must never be linked into production images!
*/
+GigabootBuffer *gigaboot_get_buffer(const char *name, size_t size)
+{
+ static GigabootBuffer kernel = {
+ .data = (void *)(uintptr_t)CONFIG_KERNEL_START,
+ .size = CONFIG_KERNEL_SIZE,
+ };
+
+ static char cmdline_buf[4096];
+ static GigabootBuffer cmdline = {
+ .data = cmdline_buf,
+ .size = sizeof(cmdline_buf),
+ };
+
+ if (!strcmp(name, gigaboot_buffer_kernel))
+ return &kernel;
+ if (!strcmp(name, gigaboot_buffer_cmdline))
+ return &cmdline;
+ return NULL;
+}
+
void dc_dev_netboot(void)
{
if (CONFIG_DRIVER_CONSOLE_DISPLAY)
display_console_attach();
- netboot(NULL, 0);
+ if (CONFIG_GIGABOOT)
+ gigaboot();
+ else
+ netboot(NULL, 0);
}
diff --git a/src/module/netboot.c b/src/module/netboot.c
index a67ade8..8599c86 100644
--- a/src/module/netboot.c
+++ b/src/module/netboot.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <vboot_nvstorage.h>
#include <vboot_api.h>
@@ -33,10 +34,31 @@
#include "drivers/net/net.h"
#include "drivers/timer/timer.h"
#include "module/module.h"
+#include "net/gigaboot/gigaboot.h"
#include "net/netboot/netboot.h"
#include "net/netboot/params.h"
#include "vboot/vbnv.h"
+GigabootBuffer *gigaboot_get_buffer(const char *name, size_t size)
+{
+ static GigabootBuffer kernel = {
+ .data = (void *)(uintptr_t)CONFIG_KERNEL_START,
+ .size = CONFIG_KERNEL_SIZE,
+ };
+
+ static char cmdline_buf[4096];
+ static GigabootBuffer cmdline = {
+ .data = cmdline_buf,
+ .size = sizeof(cmdline_buf),
+ };
+
+ if (!strcmp(name, gigaboot_buffer_kernel))
+ return &kernel;
+ if (!strcmp(name, gigaboot_buffer_cmdline))
+ return &cmdline;
+ return NULL;
+}
+
static void enable_graphics(void)
{
if (CONFIG_DRIVER_CONSOLE_DISPLAY)
@@ -70,5 +92,8 @@
srand(timer_raw_value());
- netboot(cmd_line, sizeof(cmd_line));
+ if (CONFIG_GIGABOOT)
+ gigaboot();
+ else
+ netboot(cmd_line, sizeof(cmd_line));
}