/* zentific-poll: statistics collection daemon for Zentific * * Portions copyright (C) 2007, 2008 * Steven Maresca, Justin Demaris, * and Zentific LLC * * All rights reserved. * Use is subject to license terms. * * Please visit http://zentific.com for news and updates * */ /* * DMI Decode * * (C) 2000-2002 Alan Cox * (C) 2002-2007 Jean Delvare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For the avoidance of doubt the "preferred form" of this code is one which * is in an open unpatent encumbered format. Where cryptographic key signing * forms part of the process of creating an executable the information * including keys needed to generate an equivalently functional executable * are deemed to be part of the source code. * * Unless specified otherwise, all references are aimed at the "System * Management BIOS Reference Specification, Version 2.5" document, * available from http://www.dmtf.org/standards/smbios/. * * Note to contributors: * Please reference every value you add or modify, especially if the * information does not come from the above mentioned specification. * * Additional references: * - Intel AP-485 revision 31 * "Intel Processor Identification and the CPUID Instruction" * http://developer.intel.com/design/xeon/applnots/241618.htm * - DMTF Master MIF version 040707 * "DMTF approved standard groups" * http://www.dmtf.org/standards/dmi * - IPMI 2.0 revision 1.0 * "Intelligent Platform Management Interface Specification" * http://developer.intel.com/design/servers/ipmi/spec.htm * - AMD publication #25481 revision 2.18 * "CPUID Specification" * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25481.pdf */ #include #include #include #include #include #include #include #include #include "dmidecode.h" //int get_hw_uuid(char *out); int get_hw_uuid(char *out){ int ret=0; /* Returned value */ //int found=0; size_t fp; u8 *buf; //if all else fails return all zeros char *failsafe = "00000000-0000-0000-0000-000000000000"; /* Set default option values */ char *devmem = DEFAULT_MEM_DEV; //FIXME:insert efi code from original here for efi compatibility /* Fallback to memory scan (x86, x86_64) */ if((buf=mem_chunk(0xF0000, 0x10000, devmem))==NULL) ret=1; for(fp=0; fp<=0xFFF0; fp+=16) { if(memcmp(buf+fp, "_SM_", 4)==0 && fp<=0xFFE0) { //smbios_decode u8 *checkbuf = buf+fp; //const char *devmem = devmem; if(checksum(checkbuf, checkbuf[0x05]) && memcmp(checkbuf+0x10, "_DMI_", 5)==0 && checksum(checkbuf+0x10, 0x0F)){ //dmi_table u32 base = DWORD(checkbuf+0x18); u16 len = WORD(checkbuf+0x16); u16 num = WORD(checkbuf+0x1C); //u16 ver = (checkbuf[0x06]<<8)+checkbuf[0x07]; u8 *tablebuf; u8 *data; int i=0; if((tablebuf=mem_chunk(base, len, devmem))==NULL) { #ifndef USE_MMAP printf("UUID ERROR: Table is unreachable, sorry. Try compiling dmidecode with -DUSE_MMAP.\n"); #endif return -1; } data=tablebuf; while(i * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For the avoidance of doubt the "preferred form" of this code is one which * is in an open unpatent encumbered format. Where cryptographic key signing * forms part of the process of creating an executable the information * including keys needed to generate an equivalently functional executable * are deemed to be part of the source code. */ #ifdef USE_MMAP #include #ifndef MAP_FAILED #define MAP_FAILED ((void *) -1) #endif /* !MAP_FAILED */ #endif /* USE MMAP */ #ifndef USE_MMAP static int myread(int fd, u8 *buf, size_t count, const char *prefix) { ssize_t r=1; size_t r2=0; while(r2!=count && r!=0) { r=read(fd, buf+r2, count-r2); if(r==-1) { if(errno!=EINTR) { close(fd); perror(prefix); return -1; } } else r2+=r; } if(r2!=count) { close(fd); fprintf(stderr, "%s: Unexpected end of file\n", prefix); return -1; } return 0; } #endif int checksum(const u8 *buf, size_t len) { u8 sum=0; size_t a; for(a=0; a