Browse Source

Coreboot scan debug prints

We can probably yank them, but for now you *really* want them.

Coreboot scanning is working.

Change-Id: I3c59150b2d3c5915f871af07678f701c2a149b47
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
37697d6873
3 changed files with 45 additions and 23 deletions
  1. 4 1
      sys/src/9/k10/coreboot.c
  2. 7 0
      sys/src/9/k10/main.c
  3. 34 22
      sys/src/9/port/devcoreboot.c

+ 4 - 1
sys/src/9/k10/coreboot.c

@@ -47,11 +47,14 @@ int get_coreboot_info(struct sysinfo_t *info)
 	 * an invalid value. */
 	/* this may have no use on harvey.*/
 	//info->x86_rom_var_mtrr_index = -1;
+	print("Scan %p\n", KADDR(0));
 
 	ret = cb_parse_header(KADDR(0x00000000), 0x1000, info);
 
-	if (ret != 1)
+	if (ret != 1) {
+		print("Scan %p\n", KADDR(0xf0000);
 		ret = cb_parse_header(KADDR(0x000f0000), 0x1000, info);
+	}
 	print("get_coreboot_info: ret %d\n", ret);
 	return (ret == 1) ? 0 : -1;
 }

+ 7 - 0
sys/src/9/k10/main.c

@@ -17,6 +17,7 @@
 #include "apic.h"
 #include "io.h"
 #include "amd64.h"
+#include "coreboot.h"
 
 #undef DBG
 #define DBG iprint
@@ -55,6 +56,9 @@ static int vflag = 1;
 
 int nosmp = 1;
 
+// TODO: convert naming to Plan 9 style
+struct sysinfo_t cbinfo;
+
 
 /*
  *	this may need improvement, but right now it's just for
@@ -619,6 +623,9 @@ if (0){	acpiinit(); hi("	acpiinit();\n");}
 		testiccs();
 	}
 
+	/* coreboot stuff. Later, this becomes a device. */
+	get_coreboot_info(&cbinfo);
+
 	print("CPU Freq. %dMHz\n", mach->cpumhz);
 
 	print("schedinit...\n");

+ 34 - 22
sys/src/9/port/devcoreboot.c

@@ -43,9 +43,11 @@
 
 /* === Parsing code === */
 /* This is the generic parsing code. */
+#define I_AM_HERE print("Core 0 is in %s() at %s:%d\n", \
+                         __FUNCTION__, __FILE__, __LINE__);
 
 static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_memory *mem = ptr;
 	int count = MEM_RANGE_COUNT(mem);
 	int i;
@@ -76,13 +78,13 @@ static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
 }
 
 static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	info->serial = ((struct cb_serial *)ptr);
 }
 
 #ifdef CONFIG_LP_CHROMEOS
 static void cb_parse_vboot_handoff(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_range *vbho = (struct cb_range *)ptr;
 
 	info->vboot_handoff = (void *)(uintptr_t)vbho->range_start;
@@ -90,7 +92,7 @@ static void cb_parse_vboot_handoff(unsigned char *ptr, struct sysinfo_t *info)
 }
 
 static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_range *vbnv = (struct cb_range *)ptr;
 
 	info->vbnv_start = vbnv->range_start;
@@ -98,7 +100,7 @@ static void cb_parse_vbnv(unsigned char *ptr, struct sysinfo_t *info)
 }
 
 static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	int i;
 	struct cb_gpios *gpios = (struct cb_gpios *)ptr;
 
@@ -110,7 +112,7 @@ static void cb_parse_gpios(unsigned char *ptr, struct sysinfo_t *info)
 }
 
 static void cb_parse_vdat(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_range *vdat = (struct cb_range *) ptr;
 
 	info->vdat_addr = phys_to_virt(vdat->range_start);
@@ -119,38 +121,38 @@ static void cb_parse_vdat(unsigned char *ptr, struct sysinfo_t *info)
 #endif
 
 static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
 	info->tstamp_table = KADDR(cbmem->cbmem_tab);
 }
 
 static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
 	info->cbmem_cons = KADDR(cbmem->cbmem_tab);
 }
 
 static void cb_parse_mrc_cache(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
 	info->mrc_cache = KADDR(cbmem->cbmem_tab);
 }
 
 static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_cbmem_tab *const cbmem = (struct cb_cbmem_tab *)ptr;
 	info->acpi_gnvs = KADDR(cbmem->cbmem_tab);
 }
 
 #ifdef CONFIG_LP_NVRAM
 static void cb_parse_optiontable(void *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	/* ptr points to a coreboot table entry and is already virtual */
 	info->option_table = ptr;
 }
 
 static void cb_parse_checksum(void *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_cmos_checksum *cmos_cksum = ptr;
 	info->cmos_range_start = cmos_cksum->range_start;
 	info->cmos_range_end = cmos_cksum->range_end;
@@ -160,25 +162,25 @@ static void cb_parse_checksum(void *ptr, struct sysinfo_t *info)
 
 #ifdef CONFIG_LP_COREBOOT_VIDEO_CONSOLE
 static void cb_parse_framebuffer(void *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	/* ptr points to a coreboot table entry and is already virtual */
 	info->framebuffer = ptr;
 }
 #endif
 
 static void cb_parse_x86_rom_var_mtrr(void *ptr, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	//struct cb_x86_rom_mtrr *rom_mtrr = ptr;
 	//info->x86_rom_var_mtrr_index = rom_mtrr->index;
 }
 
 static void cb_parse_string(unsigned char *ptr, char **info)
-{
+{ print("%s\n", __func__);
 	*info = (char *)((struct cb_string *)ptr)->string;
 }
 
 int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
-{
+{ print("%s\n", __func__);
 	struct cb_header *header;
 	unsigned char *ptr = addr;
 	void *forward;
@@ -186,37 +188,47 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 
 	for (i = 0; i < len; i += 16, ptr += 16) {
 		header = (struct cb_header *)ptr;
+		if (0)
+		print("Check header %p sig %p val %02x %02x %02x %02x\n", header, header->signature, 
+				header->signature[0], 
+				header->signature[1], 
+				header->signature[2], 
+				header->signature[3]);
 		if (!strncmp((char *)header->signature, "LBIO", 4))
 			break;
 	}
 
+	print("found ? i %d len %d\n", i, len);
 	/* We walked the entire space and didn't find anything. */
 	if (i >= len)
 		return -1;
-
+	I_AM_HERE;
 	if (!header->table_bytes)
 		return 0;
-
+	I_AM_HERE;
 	/* Make sure the checksums match. */
 	if (ipchksum((uint8_t *) header, sizeof(*header)) != 0)
 		return -1;
-
+	I_AM_HERE;
 	if (ipchksum((uint8_t *) (ptr + sizeof(*header)),
 		     header->table_bytes) != header->table_checksum)
 		return -1;
-
+	I_AM_HERE;
 	info->header = header;
 
 	/* Now, walk the tables. */
 	ptr += header->header_bytes;
-
+	I_AM_HERE;
 	for (i = 0; i < header->table_entries; i++) {
 		struct cb_record *rec = (struct cb_record *)ptr;
-
+	I_AM_HERE;
+	print("rec %p tag %p\n", rec, rec->tag);
 		/* We only care about a few tags here (maybe more later). */
 		switch (rec->tag) {
 		case CB_TAG_FORWARD:
 			forward = KADDR((unsigned long)((struct cb_forward *)rec)->forward);
+			print("FORWARD: %p %p\n", (unsigned long)((struct cb_forward *)rec)->forward, 
+					forward);
 			return cb_parse_header(forward, len, info);
 			continue;
 		case CB_TAG_MEMORY: