diff options
author | 2013-03-12 16:31:48 +0000 | |
---|---|---|
committer | 2013-03-12 16:31:48 +0000 | |
commit | 6b508265022cda7aa5527640a521dfd41a3a78ce (patch) | |
tree | 687bd08aa975f259b3b9779d040ec4b22bc9ccad | |
parent | Require that the template include at least 6 trailing Xs to match (diff) | |
download | wireguard-openbsd-6b508265022cda7aa5527640a521dfd41a3a78ce.tar.xz wireguard-openbsd-6b508265022cda7aa5527640a521dfd41a3a78ce.zip |
Fake 'SMBIOS detection' for the Soekris boxes, by Matt Dainty
This will make it easier to have device drivers for some oddities these
machines have
ok kettenis, assume jsg is ok with it too
-rw-r--r-- | sys/arch/amd64/amd64/bios.c | 40 | ||||
-rw-r--r-- | sys/arch/i386/i386/bios.c | 39 |
2 files changed, 77 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c index 44e15c36064..6dcb9c4895c 100644 --- a/sys/arch/amd64/amd64/bios.c +++ b/sys/arch/amd64/amd64/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.22 2012/08/10 18:50:04 krw Exp $ */ +/* $OpenBSD: bios.c,v 1.23 2013/03/12 16:31:50 deraadt Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * @@ -95,6 +95,7 @@ bios_attach(struct device *parent, struct device *self, void *aux) vaddr_t va; paddr_t pa, end; u_int8_t *p; + int smbiosrev = 0; /* see if we have SMBIOS extentions */ for (p = ISA_HOLE_VADDR(SMBIOS_START); @@ -137,6 +138,10 @@ bios_attach(struct device *parent, struct device *self, void *aux) printf(": SMBIOS rev. %d.%d @ 0x%lx (%d entries)", hdr->majrev, hdr->minrev, hdr->addr, hdr->count); + smbiosrev = hdr->majrev * 100 + hdr->minrev; + if (hdr->minrev < 10) + smbiosrev = hdr->majrev * 100 + hdr->minrev * 10; + bios.cookie = 0; if (smbios_find_table(SMBIOS_TYPE_BIOS, &bios)) { sb = bios.tblhdr; @@ -159,6 +164,39 @@ bios_attach(struct device *parent, struct device *self, void *aux) } printf("\n"); + /* No SMBIOS extensions, go looking for Soekris comBIOS */ + if (smbiosrev == 0) { + const char *signature = "Soekris Engineering"; + + for (p = ISA_HOLE_VADDR(SMBIOS_START); + p <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - + (strlen(signature) - 1)); p++) + if (!memcmp(p, signature, strlen(signature))) { + hw_vendor = malloc(strlen(signature) + 1, + M_DEVBUF, M_NOWAIT); + if (hw_vendor) + strlcpy(hw_vendor, signature, + strlen(signature) + 1); + p += strlen(signature); + break; + } + + for (; hw_vendor && + p <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - 6); p++) + /* + * Search only for "net6501" in the comBIOS as that's + * the only Soekris platform that can run amd64 + */ + if (!memcmp(p, "net6501", 7)) { + hw_prod = malloc(8, M_DEVBUF, M_NOWAIT); + if (hw_prod) { + memcpy(hw_prod, p, 7); + hw_prod[7] = '\0'; + } + break; + } + } + #if NACPI > 0 { struct bios_attach_args ba; diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c index 4fea285a9e9..4c1fdaf6273 100644 --- a/sys/arch/i386/i386/bios.c +++ b/sys/arch/i386/i386/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.97 2012/10/09 12:58:07 jsing Exp $ */ +/* $OpenBSD: bios.c,v 1.98 2013/03/12 16:31:48 deraadt Exp $ */ /* * Copyright (c) 1997-2001 Michael Shalayeff @@ -335,6 +335,43 @@ biosattach(struct device *parent, struct device *self, void *aux) printf("\n"); + /* No SMBIOS extensions, go looking for Soekris comBIOS */ + if (!(flags & BIOSF_SMBIOS) && smbiosrev == 0) { + const char *signature = "Soekris Engineering"; + + for (va = ISA_HOLE_VADDR(SMBIOS_START); + va <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - + (strlen(signature) - 1)); va++) + if (!memcmp((u_int8_t *)va, signature, + strlen(signature))) { + hw_vendor = malloc(strlen(signature) + 1, + M_DEVBUF, M_NOWAIT); + if (hw_vendor) + strlcpy(hw_vendor, signature, + strlen(signature) + 1); + va += strlen(signature); + break; + } + + for (; hw_vendor && + va <= (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END - 6); va++) + /* + * Search for "net(4(5xx|801)|[56]501)" which matches + * the strings found in the comBIOS images + */ + if (!memcmp((u_int8_t *)va, "net45xx", 7) || + !memcmp((u_int8_t *)va, "net4801", 7) || + !memcmp((u_int8_t *)va, "net5501", 7) || + !memcmp((u_int8_t *)va, "net6501", 7)) { + hw_prod = malloc(8, M_DEVBUF, M_NOWAIT); + if (hw_prod) { + memcpy(hw_prod, (u_int8_t *)va, 7); + hw_prod[7] = '\0'; + } + break; + } + } + #if NAPM > 0 if (apm && ncpu < 2 && smbiosrev < 240) { struct bios_attach_args ba; |