diff options
author | Maximilian Schander <maxschander@googlemail.com> | 2017-10-28 18:33:07 +0200 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-11-03 23:58:08 +0000 |
commit | df5b83fe2bd5752ed895fccd40c665a22525dfaf (patch) | |
tree | ab8fa9bbf4e10adb27bcae40f74ea0554f13eedd | |
parent | 181231164529203baf9fde2b82f6994f4d2c1abc (diff) | |
download | coreboot-df5b83fe2bd5752ed895fccd40c665a22525dfaf.tar.xz |
intelmetool: Do small cosmetic changes
Refining some of the code indentations and cosmetics to
build upon and import some in-review changes.
Change-Id: I0038a146bd899f150518c4832258a42792abaabb
Signed-off-by: Maximilian Schander <maxschander@googlemail.com>
Reviewed-on: https://review.coreboot.org/22216
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
-rw-r--r-- | util/intelmetool/intelmetool.c | 52 | ||||
-rw-r--r-- | util/intelmetool/intelmetool.h | 2 | ||||
-rw-r--r-- | util/intelmetool/me.c | 26 | ||||
-rw-r--r-- | util/intelmetool/me_status.c | 31 | ||||
-rw-r--r-- | util/intelmetool/mmap.c | 59 |
5 files changed, 92 insertions, 78 deletions
diff --git a/util/intelmetool/intelmetool.c b/util/intelmetool/intelmetool.c index b918c3e828..2acfec223e 100644 --- a/util/intelmetool/intelmetool.c +++ b/util/intelmetool/intelmetool.c @@ -63,7 +63,8 @@ static void dumpmemfile(uint8_t *phys, uint32_t size) fclose(fp); } -static void rehide_me() { +static void rehide_me(void) +{ if (fd2 & 0x2) { printf("Re-hiding MEI device..."); fd2 = *(uint32_t *)(rcba + FD2); @@ -78,7 +79,8 @@ static void rehide_me() { * Real ME memory is located around top of memory minus 64MB. (I think) * so we avoid cloning to this part. */ -static void dump_me_memory() { +static void dump_me_memory(void) +{ uintptr_t me_clone = 0x60000000; uint8_t *dump; @@ -107,7 +109,8 @@ static void dump_me_memory() { } } -static int pci_platform_scan() { +static int pci_platform_scan(void) +{ struct pci_access *pacc; struct pci_dev *dev; char namebuf[1024]; @@ -125,7 +128,7 @@ static int pci_platform_scan() { PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id); if (name == NULL) name = "<unknown>"; - if (dev->vendor_id == 0x8086) { + if (dev->vendor_id == PCI_VENDOR_ID_INTEL) { if (PCI_DEV_HAS_ME_DISABLE(dev->device_id)) { printf(CGRN "Good news, you have a `%s` so ME is present but can be disabled, continuing...\n\n" RESET, name); break; @@ -145,10 +148,10 @@ static int pci_platform_scan() { } if (dev != NULL && - !PCI_DEV_HAS_ME_DISABLE(dev->device_id) && - !PCI_DEV_HAS_ME_DIFFICULT(dev->device_id) && - !PCI_DEV_CAN_DISABLE_ME_IF_PRESENT(dev->device_id) && - !PCI_DEV_ME_NOT_SURE(dev->device_id)) { + !PCI_DEV_HAS_ME_DISABLE(dev->device_id) && + !PCI_DEV_HAS_ME_DIFFICULT(dev->device_id) && + !PCI_DEV_CAN_DISABLE_ME_IF_PRESENT(dev->device_id) && + !PCI_DEV_ME_NOT_SURE(dev->device_id)) { printf(CCYN "ME is not present on your board or unkown\n\n" RESET); pci_cleanup(pacc); return 1; @@ -159,7 +162,9 @@ static int pci_platform_scan() { return 0; } -static struct pci_dev *pci_me_interface_scan(const char **name, char *namebuf, int namebuf_size) { +static struct pci_dev *pci_me_interface_scan(const char **name, char *namebuf, + int namebuf_size) +{ struct pci_access *pacc; struct pci_dev *dev; int me = 0; @@ -174,7 +179,7 @@ static struct pci_dev *pci_me_interface_scan(const char **name, char *namebuf, i pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_SIZES | PCI_FILL_CLASS); *name = pci_lookup_name(pacc, namebuf, namebuf_size, PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id); - if (dev->vendor_id == 0x8086) { + if (dev->vendor_id == PCI_VENDOR_ID_INTEL) { if (PCI_DEV_HAS_SUPPORTED_ME(dev->device_id)) { me = 1; break; @@ -193,7 +198,8 @@ static struct pci_dev *pci_me_interface_scan(const char **name, char *namebuf, i return dev; } -static int activate_me() { +static int activate_me(void) +{ struct pci_access *pacc; struct pci_dev *sb; uint32_t rcba_phys; @@ -236,7 +242,8 @@ static int activate_me() { return 0; } -static void dump_me_info() { +static void dump_me_info(void) +{ struct pci_dev *dev; uint32_t stat, stat2; char namebuf[1024]; @@ -257,6 +264,7 @@ static void dump_me_info() { if (name == NULL) name = "<unknown>"; + printf("MEI found: [%x:%x] %s\n\n", dev->vendor_id, dev->device_id, name); stat = pci_read_long(dev, 0x40); printf("ME Status : 0x%x\n", stat); @@ -268,7 +276,7 @@ static void dump_me_info() { intel_me_extend_valid(dev); printf("\n"); - if ((stat & 0xf000) >> 12 != 0) { + if (stat & 0xf000) { printf("ME: has a broken implementation on your board with this BIOS\n"); } @@ -328,8 +336,8 @@ int main(int argc, char *argv[]) }; while ((opt = getopt_long(argc, argv, "vh?sd", - long_options, &option_index)) != EOF) { - switch (opt) { + long_options, &option_index)) != EOF) { + switch (opt) { case 'v': print_version(); exit(0); @@ -346,8 +354,8 @@ int main(int argc, char *argv[]) print_usage(argv[0]); exit(0); break; - } } + } #if defined(__FreeBSD__) if (open("/dev/io", O_RDWR) < 0) { @@ -376,12 +384,12 @@ int main(int argc, char *argv[]) #endif switch(cmd_exec) { - case 1: - dump_me_info(); - break; - default: - print_usage(argv[0]); - break; + case 1: + dump_me_info(); + break; + default: + print_usage(argv[0]); + break; } return 0; diff --git a/util/intelmetool/intelmetool.h b/util/intelmetool/intelmetool.h index a8d04678bb..b5fe35ae1a 100644 --- a/util/intelmetool/intelmetool.h +++ b/util/intelmetool/intelmetool.h @@ -50,6 +50,8 @@ extern int debug; +#define PCI_VENDOR_ID_INTEL 0x8086 + // Definitely has ME and can be disabled #define PCI_DEVICE_ID_INTEL_ICH8ME 0x2811 #define PCI_DEVICE_ID_INTEL_ICH9ME 0x2917 diff --git a/util/intelmetool/me.c b/util/intelmetool/me.c index e9fea6bc1c..ecdba6df36 100644 --- a/util/intelmetool/me.c +++ b/util/intelmetool/me.c @@ -53,7 +53,8 @@ static void mei_dump(void *ptr, int dword, int offset, const char *type) switch (offset) { case MEI_H_CSR: case MEI_ME_CSR_HA: -/* csr = ptr; +/* + csr = ptr; if (!csr) { printf("%-9s[%02x] : ", type, offset); printf("ERROR: 0x%08x\n", dword); @@ -61,11 +62,13 @@ static void mei_dump(void *ptr, int dword, int offset, const char *type) } printf("%-9s[%02x] : ", type, offset); printf("depth=%u read=%02u write=%02u ready=%u " - "reset=%u intgen=%u intstatus=%u intenable=%u\n", csr->buffer_depth, - csr->buffer_read_ptr, csr->buffer_write_ptr, - csr->ready, csr->reset, csr->interrupt_generate, - csr->interrupt_status, csr->interrupt_enable); -*/ break; + "reset=%u intgen=%u intstatus=%u intenable=%u\n", + csr->buffer_depth, csr->buffer_read_ptr, + csr->buffer_write_ptr, csr->ready, csr->reset, + csr->interrupt_generate, csr->interrupt_status, + csr->interrupt_enable); +*/ + break; case MEI_ME_CB_RW: case MEI_H_CB_WW: printf("%-9s[%02x] : ", type, offset); @@ -463,12 +466,10 @@ int mkhi_get_fwcaps(void) print_cap("Small business technology ", fwcaps.cap.caps_sku.small_business); print_cap("Level III manageability ", fwcaps.cap.caps_sku.l3manageability); print_cap("IntelR Anti-Theft (AT) ", fwcaps.cap.caps_sku.intel_at); - print_cap("IntelR Capability Licensing Service (CLS) ", - fwcaps.cap.caps_sku.intel_cls); - print_cap("IntelR Power Sharing Technology (MPC) ", - fwcaps.cap.caps_sku.intel_mpc); + print_cap("IntelR Capability Licensing Service (CLS) ", fwcaps.cap.caps_sku.intel_cls); + print_cap("IntelR Power Sharing Technology (MPC) ", fwcaps.cap.caps_sku.intel_mpc); print_cap("ICC Over Clocking ", fwcaps.cap.caps_sku.icc_over_clocking); - print_cap("Protected Audio Video Path (PAVP) ", fwcaps.cap.caps_sku.pavp); + print_cap("Protected Audio Video Path (PAVP) ", fwcaps.cap.caps_sku.pavp); print_cap("IPV6 ", fwcaps.cap.caps_sku.ipv6); print_cap("KVM Remote Control (KVM) ", fwcaps.cap.caps_sku.kvm); print_cap("Outbreak Containment Heuristic (OCH) ", fwcaps.cap.caps_sku.och); @@ -580,7 +581,8 @@ uint32_t intel_mei_setup(struct pci_dev *dev) mei_base_address = dev->base_addr[0] & ~0xf; pagerounded = mei_base_address & ~0xfff; - mei_mmap = map_physical(pagerounded, 0x2000) + mei_base_address - pagerounded; + mei_mmap = map_physical(pagerounded, 0x2000); + mei_mmap += mei_base_address - pagerounded; if (mei_mmap == NULL) { printf("Could not map ME setup memory\n"); return 1; diff --git a/util/intelmetool/me_status.c b/util/intelmetool/me_status.c index 1de51f4f87..0cc670b19d 100644 --- a/util/intelmetool/me_status.c +++ b/util/intelmetool/me_status.c @@ -142,42 +142,41 @@ void intel_me_status(uint32_t hfs, uint32_t gmes) { /* Check Current States */ printf("ME: FW Partition Table : %s\n", - ((hfs & 0x20) >> 5) ? "BAD" : "OK"); + ((hfs & 0x20) >> 5) ? "BAD" : "OK"); printf("ME: Bringup Loader Failure : %s\n", - ((hfs & 0x400) >> 10) ? "YES" : "NO"); + ((hfs & 0x400) >> 10) ? "YES" : "NO"); printf("ME: Firmware Init Complete : %s\n", - ((hfs & 0x200) >> 9) ? "YES" : "NO"); + ((hfs & 0x200) >> 9) ? "YES" : "NO"); printf("ME: Manufacturing Mode : %s\n", - ((hfs & 0x10) >> 4) ? "YES" : "NO"); + ((hfs & 0x10) >> 4) ? "YES" : "NO"); printf("ME: Boot Options Present : %s\n", - ((hfs & 0x1000000) >> 24) ? "YES" : "NO"); + ((hfs & 0x1000000) >> 24) ? "YES" : "NO"); printf("ME: Update In Progress : %s\n", - ((hfs & 0x800) >> 11) ? "YES" : "NO"); + ((hfs & 0x800) >> 11) ? "YES" : "NO"); printf("ME: Current Working State : %s\n", - me_cws_values[hfs & 0xf]); + me_cws_values[hfs & 0xf]); printf("ME: Current Operation State : %s\n", - me_opstate_values[(hfs & 0x1c0) >> 6]); + me_opstate_values[(hfs & 0x1c0) >> 6]); printf("ME: Current Operation Mode : %s\n", - me_opmode_values[(hfs & 0xf0000) >> 16]); + me_opmode_values[(hfs & 0xf0000) >> 16]); printf("ME: Error Code : %s\n", - me_error_values[(hfs & 0xf000) >> 12]); + me_error_values[(hfs & 0xf000) >> 12]); printf("ME: Progress Phase : %s\n", - me_progress_values[(gmes & 0xf0000000) >> 28]); + me_progress_values[(gmes & 0xf0000000) >> 28]); printf("ME: Power Management Event : %s\n", - me_pmevent_values[(gmes & 0xf000000) >> 24]); + me_pmevent_values[(gmes & 0xf000000) >> 24]); printf("ME: Progress Phase State : "); switch ((gmes & 0xf0000000) >> 28) { case ME_GMES_PHASE_ROM: /* ROM Phase */ - printf("%s", - me_progress_rom_values[(gmes & 0xff0000) >> 16]); + printf("%s", me_progress_rom_values[(gmes & 0xff0000) >> 16]); break; case ME_GMES_PHASE_BUP: /* Bringup Phase */ if ((gmes & 0xff0000) >> 16 < ARRAY_SIZE(me_progress_bup_values) && me_progress_bup_values[(gmes & 0xff0000) >> 16]) printf("%s", - me_progress_bup_values[(gmes & 0xff0000) >> 16]); + me_progress_bup_values[(gmes & 0xff0000) >> 16]); else printf("0x%02x", (gmes & 0xff0000) >> 16); break; @@ -186,7 +185,7 @@ void intel_me_status(uint32_t hfs, uint32_t gmes) if ((gmes & 0xff0000) >> 16 < ARRAY_SIZE(me_progress_policy_values) && me_progress_policy_values[(gmes & 0xff0000) >> 16]) printf("%s", - me_progress_policy_values[(gmes & 0xff0000) >> 16]); + me_progress_policy_values[(gmes & 0xff0000) >> 16]); else printf("0x%02x", (gmes & 0xff0000) >> 16); break; diff --git a/util/intelmetool/mmap.c b/util/intelmetool/mmap.c index 2462b22dac..0b6c9e1871 100644 --- a/util/intelmetool/mmap.c +++ b/util/intelmetool/mmap.c @@ -20,40 +20,43 @@ #ifndef __DARWIN__ int fd_mem; -void *map_physical_exact(off_t phys_addr, void *mapto, size_t len) { - void *virt_addr; - int err; - - virt_addr = mmap(mapto, len, PROT_WRITE | PROT_READ, - MAP_SHARED | MAP_FIXED, fd_mem, phys_addr); - - if (virt_addr == MAP_FAILED) { - err = errno; - printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d %s\n", - (intmax_t)phys_addr, len, err, strerror(err)); - return NULL; - } - - return virt_addr; +void *map_physical_exact(off_t phys_addr, void *mapto, size_t len) +{ + void *virt_addr; + int err; + + virt_addr = mmap(mapto, len, PROT_WRITE | PROT_READ, + MAP_SHARED | MAP_FIXED, fd_mem, phys_addr); + + if (virt_addr == MAP_FAILED) { + err = errno; + printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d %s\n", + (intmax_t)phys_addr, len, err, strerror(err)); + return NULL; + } + + return virt_addr; } -void *map_physical(off_t phys_addr, size_t len) { - void *virt_addr; - int err; +void *map_physical(off_t phys_addr, size_t len) +{ + void *virt_addr; + int err; - virt_addr = mmap(NULL, len, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, phys_addr); + virt_addr = mmap(NULL, len, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, phys_addr); - if (virt_addr == MAP_FAILED) { - err = errno; - printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d %s\n", - (intmax_t)phys_addr, len, err, strerror(err)); - return NULL; - } + if (virt_addr == MAP_FAILED) { + err = errno; + printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d %s\n", + (intmax_t)phys_addr, len, err, strerror(err)); + return NULL; + } - return virt_addr; + return virt_addr; } -void unmap_physical(void *virt_addr, size_t len) { - munmap(virt_addr, len); +void unmap_physical(void *virt_addr, size_t len) +{ + munmap(virt_addr, len); } #endif |