diff options
author | nima <nima@abc39116-655e-4be6-ad55-d661dc543056> | 2008-07-24 10:48:01 +0000 |
---|---|---|
committer | nima <nima@abc39116-655e-4be6-ad55-d661dc543056> | 2008-07-24 10:48:01 +0000 |
commit | 4289505932068a0c071c7c9fb4655678394cb469 (patch) | |
tree | 91d9489e8b589964976c0145b16ae06bed50e772 | |
parent | 2a92460699aa8a18bc0602d48afed1ebb408c16a (diff) | |
download | python-dmidecode-4289505932068a0c071c7c9fb4655678394cb469.tar.gz python-dmidecode-4289505932068a0c071c7c9fb4655678394cb469.tar.xz python-dmidecode-4289505932068a0c071c7c9fb4655678394cb469.zip |
Now that code has been converted, work has started on "bios", and at the point
of proof-of-concept.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@12 abc39116-655e-4be6-ad55-d661dc543056
-rw-r--r-- | Makefile | 27 | ||||
-rw-r--r-- | catsprintf.c | 4 | ||||
-rw-r--r-- | dmidecode.c | 170 | ||||
-rw-r--r-- | dmidecode.h | 9 | ||||
-rw-r--r-- | dmidecodebin.c | 6 | ||||
-rw-r--r-- | dmidecodemodule.c | 19 | ||||
-rw-r--r-- | dmidecodemodule.h | 8 | ||||
-rw-r--r-- | dmiopt.h | 4 | ||||
-rwxr-xr-x | example.py | 15 | ||||
-rw-r--r-- | setup.py | 6 |
10 files changed, 154 insertions, 114 deletions
@@ -10,17 +10,20 @@ CC = gcc CFLAGS = -W -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \ - -Wcast-align -Wwrite-strings -Wmissing-prototypes -Winline -Wundef + -Wcast-align -Wwrite-strings -Wmissing-prototypes -Winline -Wundef \ + -L/usr/include/python2.4 + #CFLAGS += -DBIGENDIAN #CFLAGS += -DALIGNMENT_WORKAROUND # When debugging, disable -O2 and enable -g. #CFLAGS += -O2 -CFLAGS += -g -lefence +#CFLAGS += -g -lefence -I/usr/include/python2.4 +CFLAGS += -g -I/usr/include/python2.4 # Pass linker flags here -LDFLAGS = +LDFLAGS = -I/usr/include/python2.4 DESTDIR = prefix = /usr/local @@ -43,12 +46,13 @@ PROGRAMS += $(shell test `uname -m 2>/dev/null` != ia64 && echo biosdecode owner PROGRAMS != echo dmidecode ; test `uname -m 2>/dev/null` != ia64 && echo biosdecode ownership vpddecode - -all : $(PROGRAMS) +mod: python setup.py clean python setup.py build - #. FIXME: setup.py should be configured such that the following workaround is no longer required... - $(CC) $(LDFLAGS) -pthread -shared -fPIC build/temp.linux-i686-2.4/dmidecodemodule.o -L. -I/usr/include/python2.4 catsprintf.o dmidecode.o dmiopt.o dmioem.o util.o -o build/lib.linux-i686-2.4/dmidecode.so + python setup.py install + python -c 'import dmidecode' + +all : $(PROGRAMS) sudo python setup.py install python -c 'import dmidecode' @@ -60,9 +64,9 @@ all : $(PROGRAMS) #dmidecode : dmidecode.o dmiopt.o dmioem.o util.o # $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -o $@ dmidecode: dmidecodebin.c catsprintf.o libdmidecode.so dmidecode.o dmiopt.o dmioem.o util.o - $(CC) $(LDFLAGS) $< -L. -I/usr/include/python2.4 -ldmidecode catsprintf.o dmidecode.o dmiopt.o dmioem.o util.o -o $@ -libdmidecode.so: dmidecode.o - $(CC) $(LDFLAGS) -shared $< -o $@ + $(CC) $(LDFLAGS) $< -L. -ldmidecode -lpython2.4 catsprintf.o dmidecode.o dmiopt.o dmioem.o util.o -o $@ +libdmidecode.so: dmidecode.o util.o + $(CC) $(LDFLAGS) -shared -fPIC -lpython2.4 -L. $< -o $@ catsprintf.o: catsprintf.c catsprintf.h $(CC) $(CFLAGS) -c $< -o $@ #. ...NiMA @@ -81,8 +85,7 @@ vpddecode : vpddecode.o vpdopt.o util.o # Objects # -dmidecode.o : dmidecode.c version.h types.h util.h config.h dmidecode.h \ - dmiopt.h dmioem.h +dmidecode.o : dmidecode.c version.h types.h util.h config.h dmidecode.h dmiopt.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ dmiopt.o : dmiopt.c config.h types.h util.h dmidecode.h dmiopt.h diff --git a/catsprintf.c b/catsprintf.c index c7c02e4..f27ce0f 100644 --- a/catsprintf.c +++ b/catsprintf.c @@ -80,7 +80,9 @@ int dmiSetItem(PyObject* dict, const char *key, const char *format, ...) { char buffer[2048]; vsprintf(buffer, format, arg); va_end(arg); - PyDict_SetItem(pydata, key, Py_BuildValue("s", buffer)); + //printf("DEBUG: Setting k:%s, f:%s s:%s...", key, format, buffer); + PyDict_SetItem(dict, Py_BuildValue("s", key), Py_BuildValue("s", buffer)); + //printf("Done.\n"); return 0; } diff --git a/dmidecode.c b/dmidecode.c index 339cdc3..96210f6 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -2590,7 +2590,7 @@ static const char *dmi_power_supply_range_switching(u8 code) { ** Main */ -void dmi_decode(struct dmi_header *h, u16 ver) { +void dmi_decode(struct dmi_header *h, u16 ver, PyObject* pydata) { u8 *data = h->data; @@ -2602,46 +2602,63 @@ void dmi_decode(struct dmi_header *h, u16 ver) { switch(h->type) { case 0: /* 3.3.1 BIOS Information */ + dmiAppendObject(++minor, "BIOS Information", NULL); - if(h->length<0x12) break; - dmiAppendObject(++minor, "Vendor", dmi_string(h, data[0x04])); - dmiAppendObject(++minor, "Version", dmi_string(h, data[0x05])); - dmiAppendObject(++minor, "Release Date", dmi_string(h, data[0x08])); + while(1) { - /* - * On IA-64, the BIOS base address will read 0 because - * there is no BIOS. Skip the base address and the - * runtime size in this case. - */ - - if(WORD(data+0x06)!=0) { - dmiAppendObject(++minor, "Address", "0x%04X0", WORD(data+0x06)); - dmiAppendObject(++minor, "Runtime Size", dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4, _)); - } + if(h->length<0x12) break; - dmiAppendObject(++minor, "ROM Size", "%u kB", (data[0x09]+1)<<6); - dmiAppendObject(++minor, "Characteristics", dmi_bios_characteristics(QWORD(data+0x0A), _)); + dmiAppendObject(++minor, "Vendor", dmi_string(h, data[0x04])); + dmiAppendObject(++minor, "Version", dmi_string(h, data[0x05])); + dmiAppendObject(++minor, "Release Date", dmi_string(h, data[0x08])); - /* - dmi_minor* x = dmiAppendObject(++minor, "XXXXXX", "--"); - while(x) { - printf("%d:<%s, %s> | %ld:[%s => %s]\n", x->major->code, x->major->id, x->major->desc, x->id, x->key, x->value); - x = x->last; + /* + * On IA-64, the BIOS base address will read 0 because + * there is no BIOS. Skip the base address and the + * runtime size in this case. + */ + + if(WORD(data+0x06)!=0) { + dmiAppendObject(++minor, "Address", "0x%04X0", WORD(data+0x06)); + dmiAppendObject(++minor, "Runtime Size", dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4, _)); + } + + dmiAppendObject(++minor, "ROM Size", "%u kB", (data[0x09]+1)<<6); + dmiAppendObject(++minor, "Characteristics", dmi_bios_characteristics(QWORD(data+0x0A), _)); + + if(h->length<0x13) break; + dmiAppendObject(++minor, "Characteristics x1", dmi_bios_characteristics_x1(data[0x12], _)); + + if(h->length<0x14) break; + dmiAppendObject(++minor, "Characteristics x2", dmi_bios_characteristics_x2(data[0x13], _)); + + if(h->length<0x18) break; + if(data[0x14]!=0xFF && data[0x15]!=0xFF) + dmiAppendObject(++minor, "BIOS Revision", "%u.%u", data[0x14], data[0x15]); + if(data[0x16]!=0xFF && data[0x17]!=0xFF) + dmiAppendObject(++minor, "Firmware Revision", "%u.%u", data[0x16], data[0x17]); } - */ - if(h->length<0x13) break; - dmiAppendObject(++minor, "Characteristics x1", dmi_bios_characteristics_x1(data[0x12], _)); - if(h->length<0x14) break; - dmiAppendObject(++minor, "Characteristics x2", dmi_bios_characteristics_x2(data[0x13], _)); - if(h->length<0x18) break; - if(data[0x14]!=0xFF && data[0x15]!=0xFF) - dmiAppendObject(++minor, "BIOS Revision", "%u.%u", data[0x14], data[0x15]); - if(data[0x16]!=0xFF && data[0x17]!=0xFF) - dmiAppendObject(++minor, "Firmware Revision", "%u.%u", data[0x16], data[0x17]); + + dmi_minor* last = dmiAppendObject(++minor, "JUNK", "NODATA"); + + char *id = last->major->id; + PyObject *pymajor = PyDict_New(); + PyDict_SetItem(pymajor, PyString_FromString("code"), PyInt_FromLong((long)last->major->code)); + PyDict_SetItem(pymajor, PyString_FromString("id"), PyString_FromString(last->major->id)); + PyDict_SetItem(pymajor, PyString_FromString("name"), PyString_FromString(last->major->desc)); + + PyObject *pyminor = PyDict_New(); + while((last = last->next)) { + //printf("%d:<%s, %s> | %ld:[%s => %s]\n", last->major->code, last->major->id, last->major->desc, last->id, last->key, last->value); + PyDict_SetItem(pyminor, PyString_FromString(last->key), PyString_FromString(last->value)); + } + PyDict_SetItem(pymajor, PyString_FromString("data"), pyminor); + + PyDict_SetItem(pydata, PyString_FromString(id), pymajor); break; @@ -3219,22 +3236,24 @@ void to_dmi_header(struct dmi_header *h, u8 *data) { h->data=data; } -static char *dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, char *_) { +static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, PyObject *pydata) { u8 *buf; u8 *data; int i=0; - catsprintf(_, NULL); if(!(opt.flags & FLAG_QUIET)) { - if(opt.type==NULL) - catsprintf(_, "%u structures occupying %u bytes. <--> Table at 0x%08X.", num, len, base); + if(opt.type==NULL) { + //catsprintf(_, "%u structures occupying %u bytes. <--> Table at 0x%08X.", num, len, base); + dmiSetItem(pydata, "dmi_table_size", "%u structures occupying %u bytes", num, len); + dmiSetItem(pydata, "dmi_table_base", "Table at 0x%08X", base); + } } if((buf=mem_chunk(base, len, devmem))==NULL) { #ifndef USE_MMAP - catsprintf(_, "Table is unreachable, sorry. Try compiling dmidecode with -DUSE_MMAP."); + fprintf(stderr, "Table is unreachable, sorry. Try compiling dmidecode with -DUSE_MMAP."); #endif - return _; + return; } data=buf; @@ -3255,17 +3274,23 @@ static char *dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, ** table is broken. */ if(h.length<4) { - catsprintf(_, "Invalid entry length (%u). DMI table is broken! Stop.", (unsigned int)h.length); + fprintf(stderr, "Invalid entry length (%u). DMI table is broken! Stop.", (unsigned int)h.length); opt.flags |= FLAG_QUIET; break; } /* In quiet mode, stop decoding at end of table marker */ - if((opt.flags & FLAG_QUIET) && h.type==127) - break; - - if(display && !(opt.flags & FLAG_QUIET)) - catsprintf(_, "Handle 0x%04X, DMI type %d, %d bytes", h.handle, h.type, h.length); + //if((opt.flags & FLAG_QUIET) && h.type==127) + // break; + + //if(display && !(opt.flags & FLAG_QUIET)) { + char hid[7]; + sprintf(hid, "0x%04X", h.handle); + PyObject *hDict = PyDict_New(); + dmiSetItem(hDict, "dmi_type", "%d", h.type); + dmiSetItem(hDict, "dmi_size", "%d", h.length); + //catsprintf(_, "Handle 0x%04X, DMI type %d, %d bytes", h.handle, h.type, h.length); + //} /* assign vendor for vendor-specific decodes later */ if(h.type==0 && h.length>=5) @@ -3281,47 +3306,53 @@ static char *dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, if(display) { if(next-buf<=len) { if(opt.flags & FLAG_DUMP) { - char __[512]; - catsprintf(_, dmi_dump(&h, __)); - } else dmi_decode(&h, ver); - } - else if(!(opt.flags & FLAG_QUIET)) - catsprintf(_, "\t<TRUNCATED>"); + char _[512]; + dmi_dump(&h, _); + dmiSetItem(hDict, "lookup", _); + } else dmi_decode(&h, ver, pydata); + } else if(!(opt.flags & FLAG_QUIET)) + fprintf(stderr, "<TRUNCATED>"); } else if(opt.string!=NULL && opt.string->type==h.type && opt.string->offset<h.length) { if(opt.string->lookup!=NULL) { - char __[512]; - catsprintf(_, "%s", opt.string->lookup(data[opt.string->offset], __)); + char _[512]; + strcpy(_, opt.string->lookup(data[opt.string->offset])); + dmiSetItem(hDict, "lookup", _); } else if(opt.string->print!=NULL) { - opt.string->print(data+opt.string->offset); + char _[512]; + opt.string->print(data+opt.string->offset, _); + dmiSetItem(hDict, "print", _); + } else { + dmiSetItem(hDict, "lookup", dmi_string(&h, data[opt.string->offset])); + //catsprintf(_, "%s\n", dmi_string(&h, data[opt.string->offset])); } - else - catsprintf(_, "%s\n", dmi_string(&h, data[opt.string->offset])); } + PyDict_SetItem(pydata, Py_BuildValue("s", hid), hDict); + data=next; i++; } if(!(opt.flags & FLAG_QUIET)) { if(i!=num) - catsprintf(_, "Wrong DMI structures count: %d announced, only %d decoded.\n", num, i); + fprintf(stderr, "Wrong DMI structures count: %d announced, only %d decoded.\n", num, i); if(data-buf!=len) - catsprintf(_, "Wrong DMI structures length: %d bytes announced, structures occupy %d bytes.\n", + fprintf(stderr, "Wrong DMI structures length: %d bytes announced, structures occupy %d bytes.\n", len, (unsigned int)(data-buf)); } free(buf); - - return _; } int smbios_decode(u8 *buf, const char *devmem, PyObject* pydata) { if(checksum(buf, buf[0x05]) && memcmp(buf+0x10, "_DMI_", 5)==0 && checksum(buf+0x10, 0x0F)) { + if(pydata == NULL) return 1; if(!(opt.flags & FLAG_QUIET)) dmiSetItem(pydata, "detected", "SMBIOS %u.%u present.", buf[0x06], buf[0x07]); - dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C), (buf[0x06]<<8)+buf[0x07], devmem, _); + dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C), (buf[0x06]<<8)+buf[0x07], devmem, pydata); + //. XXX dmiSetItem(pydata, "table", dmi_string(&h, data[opt.string->offset])); return 1; } @@ -3330,9 +3361,10 @@ int smbios_decode(u8 *buf, const char *devmem, PyObject* pydata) { int legacy_decode(u8 *buf, const char *devmem, PyObject* pydata) { if(checksum(buf, 0x0F)) { + if(pydata == NULL) return 1; if(!(opt.flags & FLAG_QUIET)) dmiSetItem(pydata, "detected", "Legacy DMI %u.%u present.", buf[0x0E]>>4, buf[0x0E]&0x0F); - dmi_table(DWORD(buf+0x08), WORD(buf+0x06), WORD(buf+0x0C), ((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem, _); + dmi_table(DWORD(buf+0x08), WORD(buf+0x06), WORD(buf+0x0C), ((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem, pydata); return 1; } @@ -3344,12 +3376,14 @@ int legacy_decode(u8 *buf, const char *devmem, PyObject* pydata) { */ #define EFI_NOT_FOUND (-1) #define EFI_NO_SMBIOS (-2) -int address_from_efi(size_t *address, char *buffer) { +int address_from_efi(size_t *address, char *_) { FILE *efi_systab; const char *filename; char linebuf[64]; int ret; + bzero(_, strlen(_)); + *address = 0; /* Prevent compiler warning */ /* @@ -3368,7 +3402,7 @@ int address_from_efi(size_t *address, char *buffer) { if(strcmp(linebuf, "SMBIOS")==0) { *address=strtoul(addrp, NULL, 0); if(!(opt.flags & FLAG_QUIET)) { - sprintf(buffer, "0x%08lx", (unsigned long)*address); + sprintf(_, "0x%08lx", (unsigned long)*address); //printf("# SMBIOS entry point at 0x%08lx\n", (unsigned long)*address); } ret=0; @@ -3380,7 +3414,7 @@ int address_from_efi(size_t *address, char *buffer) { if(ret==EFI_NO_SMBIOS) { //fprintf(stderr, "%s: SMBIOS entry point missing\n", filename); - sprintf(buffer, "missing"); + sprintf(_, "missing"); } return ret; } @@ -3393,6 +3427,8 @@ int submain(int argc, char * const argv[]) int efi; u8 *buf; + char _[2048]; bzero(_, 2048); + if(sizeof(u8)!=1 || sizeof(u16)!=2 || sizeof(u32)!=4 || '\0'!=0) { fprintf(stderr, "%s: compiler incompatibility\n", argv[0]); @@ -3417,15 +3453,15 @@ int submain(int argc, char * const argv[]) if(opt.flags & FLAG_VERSION) { - catsprintf(buffer, "%s\n", VERSION); + sprintf(_, "%s\n", VERSION); goto exit_free; } if(!(opt.flags & FLAG_QUIET)) - catsprintf(buffer, "# dmidecode %s\n", VERSION); + sprintf(_, "# dmidecode %s\n", VERSION); /* First try EFI (ia64, Intel-based Mac) */ - efi=address_from_efi(&fp); + efi=address_from_efi(&fp, _); switch(efi) { case EFI_NOT_FOUND: diff --git a/dmidecode.h b/dmidecode.h index 9dc343b..7aea58c 100644 --- a/dmidecode.h +++ b/dmidecode.h @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <Python.h> struct dmi_header { u8 type; @@ -26,11 +27,11 @@ struct dmi_header { }; const char *dmi_dump(struct dmi_header *h, char *_); -void dmi_decode(struct dmi_header *h, u16 ver); -int address_from_efi(size_t *address); +void dmi_decode(struct dmi_header *h, u16 ver, PyObject *pydata); +int address_from_efi(size_t *address, char *_); void to_dmi_header(struct dmi_header *h, u8 *data); -int smbios_decode(u8 *buf, const char *devmem, char *_); -int legacy_decode(u8 *buf, const char *devmem, char *_); +int smbios_decode(u8 *buf, const char *devmem, PyObject* pydata); +int legacy_decode(u8 *buf, const char *devmem, PyObject* pydata); const char *dmi_string(struct dmi_header *dm, u8 s); const char *dmi_system_uuid(u8 *p, char *_); diff --git a/dmidecodebin.c b/dmidecodebin.c index 01408c3..8704a36 100644 --- a/dmidecodebin.c +++ b/dmidecodebin.c @@ -23,11 +23,11 @@ extern const char *dmi_dump(struct dmi_header *h, char *_); extern void dmi_decode(struct dmi_header *h, u16 ver); -extern int address_from_efi(size_t *address); +extern int address_from_efi(size_t *address, char *_); extern void to_dmi_header(struct dmi_header *h, u8 *data); extern void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem); -extern int smbios_decode(u8 *buf, const char *devmem, char *_); -extern int legacy_decode(u8 *buf, const char *devmem, char *_); +extern int smbios_decode(u8 *buf, const char *devmem, PyObject* pydata); +extern int legacy_decode(u8 *buf, const char *devmem, PyObject* pydata); extern int submain(int argc, char * const argv[]); int main(int argc, char * const argv[]) { diff --git a/dmidecodemodule.c b/dmidecodemodule.c index 0e77fae..10ee9fc 100644 --- a/dmidecodemodule.c +++ b/dmidecodemodule.c @@ -2,12 +2,9 @@ #include <mcheck.h> static PyObject* dmidecode_get(PyObject *self, char* section) { - mtrace(); + //mtrace(); - bzero(buffer, 50000); - - Py_Initialize(); - if(!Py_IsInitialized()) return NULL; + Py_SetProgramName("dmidecode"); /* int argc = 3; @@ -38,11 +35,11 @@ static PyObject* dmidecode_get(PyObject *self, char* section) { if(opt.type==NULL) return NULL; PyObject* pydata = PyDict_New(); + Py_INCREF(pydata); /* First try EFI (ia64, Intel-based Mac) */ char efiAddress[32]; efi = address_from_efi(&fp, efiAddress); - dmiSetItem(pydata, "efi_address", efiAddress); if(efi == EFI_NOT_FOUND) { /* Fallback to memory scan (x86, x86_64) */ if((buf=mem_chunk(0xF0000, 0x10000, opt.devmem))==NULL) { @@ -65,6 +62,7 @@ static PyObject* dmidecode_get(PyObject *self, char* section) { } else { if(smbios_decode(buf, opt.devmem, pydata)) found++; } + dmiSetItem(pydata, "efi_address", efiAddress); } if(ret==0) { @@ -74,7 +72,6 @@ static PyObject* dmidecode_get(PyObject *self, char* section) { dmiSetItem(pydata, "detect", "No SMBIOS nor DMI entry point found, sorry G."); } - Py_Finalize(); free(opt.type); @@ -93,9 +90,8 @@ static PyObject* dmidecode_get(PyObject *self, char* section) { if(ret == 1) return NULL; + /* PyObject* data = PyDict_New(); - - char *nextLine = strtok(buffer, "\n"); PyObject* s = NULL; PyObject* d = NULL; PyObject* key = NULL; @@ -110,9 +106,10 @@ static PyObject* dmidecode_get(PyObject *self, char* section) { } nextLine = strtok(NULL, "\n"); } + */ - muntrace(); - return data; + //muntrace(); + return pydata; } static PyObject* dmidecode_get_bios(PyObject *self, PyObject *args) { return dmidecode_get(self, "bios"); } diff --git a/dmidecodemodule.h b/dmidecodemodule.h index 4274f94..f499d7c 100644 --- a/dmidecodemodule.h +++ b/dmidecodemodule.h @@ -20,11 +20,11 @@ #include "catsprintf.h" extern const char *dmi_dump(struct dmi_header *h, char *_); -extern void dmi_decode(struct dmi_header *h, u16 ver); -extern int address_from_efi(size_t *address); +extern void dmi_decode(struct dmi_header *h, u16 ver, PyObject* pydata); +extern int address_from_efi(size_t *address, char *_); extern void to_dmi_header(struct dmi_header *h, u8 *data); extern void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem); -extern int smbios_decode(u8 *buf, const char *devmem, char *_); -extern int legacy_decode(u8 *buf, const char *devmem, char *_); +extern int smbios_decode(u8 *buf, const char *devmem, PyObject* pydata); +extern int legacy_decode(u8 *buf, const char *devmem, PyObject* pydata); extern void *mem_chunk(size_t base, size_t len, const char *devmem); extern u8 *parse_opt_type(u8 *p, const char *arg); @@ -24,8 +24,8 @@ struct string_keyword const char *keyword; u8 type; u8 offset; - const char *(*lookup)(u8, char *); - void (*print)(u8 *); + const char *(*lookup)(u8); + const char *(*print)(u8 *, char *); }; struct opt @@ -8,14 +8,13 @@ def l(x): return len(x) import dmidecode, time -print(dir(dmidecode)) +#print(dir(dmidecode)) -dmidecode.bios() print "bios\n", l(dmidecode.bios()) +#print "proc\n", l(dmidecode.processor()) +#print "sys\n", l(dmidecode.system()) +#print "bios\n", l(dmidecode.bios()) -print "proc\n", l(dmidecode.processor()) -print "sys\n", l(dmidecode.system()) -print "bios\n", l(dmidecode.bios()) -print "proc\n", l(dmidecode.processor()) -print "sys\n", l(dmidecode.system()) -print "bios\n", l(dmidecode.bios()) +#print "proc\n", l(dmidecode.processor()) +#print "sys\n", l(dmidecode.system()) +#print "bios\n", l(dmidecode.bios()) @@ -6,10 +6,12 @@ setup( description = "A python module rewrite of dmidecode", author = "Nima Talebi", author_email = "nima@autonomy.net.au", - url = "http://projects/autonomy.net.au/dmidecode/", + url = "http://projects.autonomy.net.au/dmidecode/", ext_modules = [ Extension( - "dmidecode", ["dmidecodemodule.c"], library_dirs=["/home/nima/dev-room/projects/dmidecode"], libraries=["util"] + "dmidecode", [ "dmidecodemodule.c", "util.c", "catsprintf.c", "dmioem.c", "biosdecode.c", "dmiopt.c", "dmidecode.c" ], + library_dirs=[ "/home/nima/dev-room/projects/dmidecode" ], + libraries=[ "util" ], ) ] ) |