[osboot] pass mmio of xhci for use of early usb debug driver
Change-Id: Ib0f95070ac77590544be397498e898f4c096b5af
diff --git a/Makefile b/Makefile
index f7d1aec..a4fcf0c 100644
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,8 @@
src/magenta.c \
src/netboot.c \
src/netifc.c \
- src/inet6.c
+ src/inet6.c \
+ src/pci.c
$(call efi_app, osboot, $(OSBOOT_FILES))
$(call efi_app, usbtest, src/usbtest.c)
diff --git a/src/magenta.c b/src/magenta.c
index 2da2d2e..5d7dfa4 100644
--- a/src/magenta.c
+++ b/src/magenta.c
@@ -284,7 +284,7 @@
int boot_kernel(EFI_HANDLE img, EFI_SYSTEM_TABLE* sys,
void* image, size_t sz, void* ramdisk, size_t rsz,
- void* cmdline, size_t csz) {
+ void* cmdline, size_t csz, void* cmdline2, size_t csz2) {
EFI_BOOT_SERVICES* bs = sys->BootServices;
kernel_t kernel;
EFI_STATUS r;
@@ -315,14 +315,24 @@
ZP32(kernel.zeropage, ZP_FB_REGBASE) = 0;
ZP32(kernel.zeropage, ZP_FB_SIZE) = 256 * 1024 * 1024;
+ if ((csz == 0) && (csz2 != 0)) {
+ cmdline = cmdline2;
+ csz = csz2;
+ csz2 = 0;
+ }
if (cmdline) {
// Truncate the cmdline to fit on a page
if (csz >= 4095) {
csz = 4095;
}
memcpy(kernel.cmdline, cmdline, csz);
+ if (cmdline2 && (csz2 < (4095 - csz))) {
+ memcpy(kernel.cmdline + csz, cmdline2, csz2);
+ csz += csz2;
+ }
kernel.cmdline[csz] = '\0';
}
+
if (ramdisk && rsz) {
ZP32(kernel.zeropage, ZP_RAMDISK_BASE) = (uint32_t) (uintptr_t) ramdisk;
ZP32(kernel.zeropage, ZP_RAMDISK_SIZE) = rsz;
diff --git a/src/magenta.h b/src/magenta.h
index 3c2a1b9..c3ae7db 100644
--- a/src/magenta.h
+++ b/src/magenta.h
@@ -13,4 +13,4 @@
int boot_kernel(EFI_HANDLE img, EFI_SYSTEM_TABLE* sys,
void* image, size_t sz, void* ramdisk, size_t rsz,
- void* cmdline, size_t csz);
+ void* cmdline, size_t csz, void* cmdline2, size_t csz2);
diff --git a/src/osboot.c b/src/osboot.c
index 0a4afe9..193c5ee 100644
--- a/src/osboot.c
+++ b/src/osboot.c
@@ -20,6 +20,8 @@
#define KBUFSIZE (32*1024*1024)
#define RBUFSIZE (256*1024*1024)
+static char cmdextra[256];
+
static nbfile nbkernel;
static nbfile nbramdisk;
static nbfile nbcmdline;
@@ -199,7 +201,8 @@
nbramdisk.size = RBUFSIZE;
nbcmdline.data = (void*) cmdline;
- nbcmdline.size = sizeof(cmdline);
+ nbcmdline.size = sizeof(cmdline) - 1;
+ nbcmdline.offset = 0;
cmdline[0] = 0;
printf("\nNetBoot Server Started...\n\n");
@@ -262,6 +265,9 @@
// Restore the TPL before booting the kernel, or failing to netboot
bs->RestoreTPL(prev_tpl);
+ // ensure cmdline is null terminated
+ cmdline[nbcmdline.offset] = 0;
+
// maybe it's a kernel image?
EFI_GRAPHICS_OUTPUT_PROTOCOL* gop;
bs->LocateProtocol(&GraphicsOutputProtocol, NULL, (void**)&gop);
@@ -269,7 +275,7 @@
boot_kernel(img, sys, (void*) nbkernel.data, nbkernel.offset,
(void*) nbramdisk.data, nbramdisk.offset,
- cmdline, sizeof(cmdline));
+ cmdline, strlen(cmdline), cmdextra, strlen(cmdextra));
break;
}
}
@@ -280,6 +286,13 @@
InitializeLib(img, sys);
InitGoodies(img, sys);
+ uint64_t mmio;
+ if (FindPCIMMIO(bs, 0x0C, 0x03, 0x30, &mmio) == EFI_SUCCESS) {
+ sprintf(cmdextra, " xdc.mmio=0x%lx ", mmio);
+ } else {
+ cmdextra[0] = 0;
+ }
+
// Load the cmdline
UINTN csz = 0;
char* cmdline = LoadFile(L"cmdline", &csz);
@@ -328,7 +341,8 @@
case BOOT_DEVICE_LOCAL: {
UINTN rsz = 0;
void* ramdisk = LoadFile(L"ramdisk.bin", &rsz);
- boot_kernel(img, sys, kernel, ksz, ramdisk, rsz, cmdline, csz);
+ boot_kernel(img, sys, kernel, ksz, ramdisk, rsz,
+ cmdline, csz, cmdextra, strlen(cmdextra));
break;
}
default: