CoreMod
From Wiki.cyring.fr
(→coremod.h) |
(→coremod.c) |
||
| Line 483: | Line 483: | ||
===== coremod.c ===== | ===== coremod.c ===== | ||
| + | <syntaxhighlight lang="c" line start="1"> | ||
| + | /* | ||
| + | * CoreMod by CyrIng | ||
| + | * | ||
| + | * Copyright (C) 2012 CYRIL INGENIERIE | ||
| + | * | ||
| + | * Licenses: GPL2 | ||
| + | * | ||
| + | * coremod.c release 2012-0.1.2 | ||
| + | */ | ||
| + | |||
| + | #include <stdio.h> | ||
| + | #include <stdlib.h> | ||
| + | #include <unistd.h> | ||
| + | #include <sys/stat.h> | ||
| + | #include <fcntl.h> | ||
| + | #include <ctype.h> | ||
| + | #include <errno.h> | ||
| + | #include "coremod.h" | ||
| + | |||
| + | |||
| + | struct STRING *SMB_Dig_Strings(struct PACKED *packed, int ID) | ||
| + | { | ||
| + | struct STRING *pstr=NULL; | ||
| + | char *buffer=NULL; | ||
| + | size_t rbyte=0; | ||
| + | |||
| + | if( getdelim(&buffer, &rbyte, STRING_DELIMITER, packed->File) > 1 ) | ||
| + | { | ||
| + | pstr=malloc(sizeof(struct STRING)); | ||
| + | pstr->Buffer=buffer; | ||
| + | pstr->ID=++ID; | ||
| + | pstr->Link=SMB_Dig_Strings(packed, ID); | ||
| + | return(pstr); | ||
| + | } | ||
| + | else | ||
| + | return(NULL); | ||
| + | } | ||
| + | |||
| + | struct STRING *SMB_Read_Strings(struct PACKED *packed) | ||
| + | { | ||
| + | return(packed->Length==0 ? SMB_Dig_Strings(packed, 0) : NULL); | ||
| + | } | ||
| + | |||
| + | void SMB_Dump_Strings(struct STRUCTINFO *smb) | ||
| + | { | ||
| + | struct STRING *pstr=NULL; | ||
| + | |||
| + | if(smb!=NULL) | ||
| + | { | ||
| + | printf("\nString#\t- Buffer -\n"); | ||
| + | pstr=smb->String; | ||
| + | while(pstr!=NULL) | ||
| + | { | ||
| + | printf("%3d\t[%s]\n", pstr->ID, pstr->Buffer); | ||
| + | pstr=pstr->Link; | ||
| + | }; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | char *SMB_Find_String(struct STRUCTINFO *smb, int ID) | ||
| + | { | ||
| + | struct STRING *pstr=NULL; | ||
| + | |||
| + | if(smb!=NULL) | ||
| + | { | ||
| + | pstr=smb->String; | ||
| + | while(pstr!=NULL && pstr->ID!=ID) | ||
| + | pstr=pstr->Link; | ||
| + | } | ||
| + | return(pstr!=NULL ? pstr->Buffer : ""); | ||
| + | } | ||
| + | |||
| + | int SMB_Read_Length(struct PACKED *packed) | ||
| + | { | ||
| + | char pathName[]="/sys/firmware/dmi/entries/999-99/file1234567890"; | ||
| + | |||
| + | sprintf(pathName, "/sys/firmware/dmi/entries/%d-%d/length", packed->Type, packed->Instance); | ||
| + | if( (packed->File=fopen(pathName, "r")) != NULL ) | ||
| + | { | ||
| + | fscanf(packed->File, "%zd\n", &packed->Length); | ||
| + | fclose(packed->File); | ||
| + | packed->Length-=sizeof(struct HEADER); | ||
| + | return(0); | ||
| + | } | ||
| + | else | ||
| + | return(errno); | ||
| + | } | ||
| + | |||
| + | int SMB_Open_Structure(struct PACKED *packed) | ||
| + | { | ||
| + | char pathName[]="/sys/firmware/dmi/entries/999-99/file1234567890"; | ||
| + | |||
| + | sprintf(pathName, "/sys/firmware/dmi/entries/%d-%d/raw", packed->Type, packed->Instance); | ||
| + | if( (packed->File=fopen(pathName, "rb")) == NULL ) | ||
| + | return(errno); | ||
| + | else | ||
| + | return(0); | ||
| + | } | ||
| + | |||
| + | int SMB_Close_Structure(struct PACKED *packed) | ||
| + | { | ||
| + | if(packed->File) | ||
| + | { | ||
| + | fclose(packed->File); | ||
| + | packed->File=NULL; | ||
| + | } | ||
| + | return(errno); | ||
| + | } | ||
| + | |||
| + | struct STRUCTINFO *SMB_Read_Structure(struct PACKED *packed) | ||
| + | { | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | unsigned long long poly=0; | ||
| + | unsigned int head=0; | ||
| + | |||
| + | if( (smb=calloc(1, sizeof(struct STRUCTINFO))) !=NULL ) | ||
| + | { | ||
| + | fread(&smb->Header, sizeof(struct HEADER), 1, packed->File); | ||
| + | |||
| + | while(packed->Tape[head] != _EOT_) | ||
| + | { | ||
| + | smb->Attrib=realloc(smb->Attrib, (head + 1) * sizeof(unsigned long long)); | ||
| + | fread(&poly, 0b0001 << packed->Tape[head], 1, packed->File); | ||
| + | smb->Attrib[head]=poly; | ||
| + | packed->Length-=0b0001 << packed->Tape[head]; | ||
| + | poly=0; | ||
| + | head++ ; | ||
| + | } | ||
| + | smb->Dimension=head; | ||
| + | } | ||
| + | return(smb); | ||
| + | } | ||
| + | |||
| + | void SMB_Read_Extension(struct PACKED *packed, struct STRUCTINFO *smb) | ||
| + | { | ||
| + | unsigned long long poly=0; | ||
| + | unsigned int head=0; | ||
| + | |||
| + | while(smb!=NULL && packed->Tape[head]!=_EOT_) | ||
| + | { | ||
| + | smb->Attrib=realloc(smb->Attrib, (smb->Dimension + head + 1) * sizeof(unsigned long long)); | ||
| + | fread(&poly, 0b0001 << packed->Tape[head], 1, packed->File); | ||
| + | smb->Attrib[smb->Dimension + head]=poly; | ||
| + | packed->Length-=0b0001 << packed->Tape[head]; | ||
| + | poly=0; | ||
| + | head++ ; | ||
| + | } | ||
| + | smb->Dimension+=head ; | ||
| + | } | ||
| + | |||
| + | void BIOS_Free_Structure(struct STRUCTINFO *smb) | ||
| + | { | ||
| + | struct STRING *Link=NULL, *pstr=NULL; | ||
| + | |||
| + | if(smb!=NULL) | ||
| + | { | ||
| + | pstr=smb->String; | ||
| + | while(pstr!=NULL) | ||
| + | { | ||
| + | Link=pstr->Link; | ||
| + | free(pstr); | ||
| + | pstr=Link; | ||
| + | }; | ||
| + | smb->String=NULL; | ||
| + | if(smb->Attrib) | ||
| + | { | ||
| + | free(smb->Attrib); | ||
| + | smb->Attrib=NULL; | ||
| + | } | ||
| + | free(smb); | ||
| + | smb=NULL; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void SMB_Dump_Attribs(struct STRUCTINFO *smb) | ||
| + | { | ||
| + | int ix=0; | ||
| + | if(smb!=NULL) | ||
| + | { | ||
| + | printf("\nAttribute#\tHex\t\t\tDec\n"); | ||
| + | for(ix=0; ix < smb->Dimension; ix++) | ||
| + | printf("%3d\t\t0x%-16llX\t( %20llu )\n", \ | ||
| + | ix, smb->Attrib[ix], smb->Attrib[ix]); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | struct BIOSINFO *BIOS_Read_Info(void) | ||
| + | { | ||
| + | int tape[]=SMBIOS_BIOSINFO_PACKED; | ||
| + | struct PACKED packed={SMBIOS_BIOSINFO_TYPE, SMBIOS_BIOSINFO_INSTANCE, NULL, 0, &tape[0]}; | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | |||
| + | if(!SMB_Read_Length(&packed) && !SMB_Open_Structure(&packed)) | ||
| + | { | ||
| + | smb=SMB_Read_Structure(&packed); | ||
| + | smb->String=SMB_Read_Strings(&packed); | ||
| + | SMB_Close_Structure(&packed); | ||
| + | } | ||
| + | return((struct BIOSINFO*) smb); | ||
| + | } | ||
| + | |||
| + | struct BOARDINFO *BOARD_Read_Info(void) | ||
| + | { | ||
| + | int tape[]=SMBIOS_BOARDINFO_PACKED, | ||
| + | extens[]=SMBIOS_BOARDINFO_EXTENS; | ||
| + | struct PACKED packed={SMBIOS_BOARDINFO_TYPE, SMBIOS_BOARDINFO_INSTANCE, NULL, 0, &tape[0]}; | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | |||
| + | if(!SMB_Read_Length(&packed) && !SMB_Open_Structure(&packed)) | ||
| + | { | ||
| + | smb=SMB_Read_Structure(&packed); | ||
| + | if(smb->Attrib[9] > 0) | ||
| + | { | ||
| + | packed.Tape=&extens[0]; | ||
| + | while(packed.Length > 0) | ||
| + | SMB_Read_Extension(&packed, smb); | ||
| + | } | ||
| + | smb->String=SMB_Read_Strings(&packed); | ||
| + | SMB_Close_Structure(&packed); | ||
| + | } | ||
| + | return((struct BOARDINFO*) smb); | ||
| + | } | ||
| + | |||
| + | struct PROCINFO *PROC_Read_Info(void) | ||
| + | { | ||
| + | int tape[]=SMBIOS_PROCINFO_PACKED, | ||
| + | extens[]=SMBIOS_PROCINFO_EXTENS; | ||
| + | struct PACKED packed={SMBIOS_PROCINFO_TYPE, SMBIOS_PROCINFO_INSTANCE, NULL, 0, &tape[0]}; | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | |||
| + | if(!SMB_Read_Length(&packed) && !SMB_Open_Structure(&packed)) | ||
| + | { | ||
| + | smb=SMB_Read_Structure(&packed); | ||
| + | if(packed.Length > 0) | ||
| + | { | ||
| + | packed.Tape=&extens[0]; | ||
| + | SMB_Read_Extension(&packed, smb); | ||
| + | } | ||
| + | smb->String=SMB_Read_Strings(&packed); | ||
| + | SMB_Close_Structure(&packed); | ||
| + | } | ||
| + | return((struct PROCINFO*) smb); | ||
| + | } | ||
| + | |||
| + | struct CACHEINFO *CACHE_Read_Info(int instance) | ||
| + | { | ||
| + | int tape[]=SMBIOS_CACHEINFO_PACKED; | ||
| + | struct PACKED packed={SMBIOS_CACHEINFO_TYPE, instance, NULL, 0, &tape[0]}; | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | |||
| + | if(!SMB_Read_Length(&packed) && !SMB_Open_Structure(&packed)) | ||
| + | { | ||
| + | smb=SMB_Read_Structure(&packed); | ||
| + | smb->String=SMB_Read_Strings(&packed); | ||
| + | SMB_Close_Structure(&packed); | ||
| + | } | ||
| + | return((struct CACHEINFO*) smb); | ||
| + | } | ||
| + | |||
| + | struct MEMARRAY *MEM_Read_Array(void) | ||
| + | { | ||
| + | int tape[]=SMBIOS_MEMARRAY_PACKED, | ||
| + | extens[]=SMBIOS_MEMARRAY_EXTENS; | ||
| + | struct PACKED packed={SMBIOS_MEMARRAY_TYPE, SMBIOS_MEMARRAY_INSTANCE, NULL, 0, &tape[0]}; | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | |||
| + | if(!SMB_Read_Length(&packed) && !SMB_Open_Structure(&packed)) | ||
| + | { | ||
| + | smb=SMB_Read_Structure(&packed); | ||
| + | if(packed.Length > 0) | ||
| + | { | ||
| + | packed.Tape=&extens[0]; | ||
| + | SMB_Read_Extension(&packed, smb); | ||
| + | } | ||
| + | smb->String=SMB_Read_Strings(&packed); | ||
| + | SMB_Close_Structure(&packed); | ||
| + | } | ||
| + | return((struct MEMARRAY*) smb); | ||
| + | } | ||
| + | |||
| + | struct MEMDEV *MEM_Read_Device(int instance) | ||
| + | { | ||
| + | int tape[]=SMBIOS_MEMDEV_PACKED, | ||
| + | extens[]=SMBIOS_MEMDEV_EXTENS; | ||
| + | struct PACKED packed={SMBIOS_MEMDEV_TYPE, instance, NULL, 0, &tape[0]}; | ||
| + | struct STRUCTINFO *smb=NULL; | ||
| + | |||
| + | if(!SMB_Read_Length(&packed) && !SMB_Open_Structure(&packed)) | ||
| + | { | ||
| + | smb=SMB_Read_Structure(&packed); | ||
| + | if(packed.Length > 0) | ||
| + | { | ||
| + | packed.Tape=&extens[0]; | ||
| + | SMB_Read_Extension(&packed, smb); | ||
| + | } | ||
| + | smb->String=SMB_Read_Strings(&packed); | ||
| + | SMB_Close_Structure(&packed); | ||
| + | } | ||
| + | return((struct MEMDEV*) smb); | ||
| + | } | ||
| + | |||
| + | struct MEMDEV **MEM_ReadAll_Devices(struct MEMARRAY *memArray) | ||
| + | { | ||
| + | struct MEMDEV **memory=NULL; | ||
| + | int stick=0; | ||
| + | |||
| + | if(memArray!=NULL) | ||
| + | { | ||
| + | memory=malloc(sizeof(struct MEMDEV*) * memArray->Attrib->Number_Devices); | ||
| + | for(stick=0; stick < memArray->Attrib->Number_Devices; stick++) | ||
| + | memory[stick]=MEM_Read_Device(stick); | ||
| + | } | ||
| + | return(memory); | ||
| + | } | ||
| + | |||
| + | void MEM_FreeAll_Devices(struct MEMDEV **memory, struct MEMARRAY *memArray) | ||
| + | { | ||
| + | int stick=0; | ||
| + | |||
| + | if(memArray!=NULL) | ||
| + | { | ||
| + | for(stick=0; stick < memArray->Attrib->Number_Devices; stick++) | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) memory[stick]); | ||
| + | |||
| + | free(memory); | ||
| + | memory=NULL; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | struct COREINFO *CORE_Read_Info(struct PROCINFO *proc) | ||
| + | { | ||
| + | struct COREINFO *core=NULL; | ||
| + | char pathName[]="/dev/cpu/99/msr"; | ||
| + | ssize_t rbyte=0; | ||
| + | int cpu=0, File=-1; | ||
| + | |||
| + | if(proc!=NULL) | ||
| + | { | ||
| + | core=malloc(sizeof(struct COREINFO) * proc->Attrib->ThreadCount); | ||
| + | for(cpu=0; core && cpu < proc->Attrib->ThreadCount; cpu++) | ||
| + | { | ||
| + | sprintf(pathName, "/dev/cpu/%d/msr", cpu); | ||
| + | if((File=open(pathName, O_RDONLY)) != -1) | ||
| + | { | ||
| + | rbyte=pread(File, &core[cpu].Temp, 8, MSR_TEMPERATURE_TARGET); | ||
| + | close(File); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | return(core); | ||
| + | } | ||
| + | |||
| + | void CORE_Update_Info(struct COREINFO *core, struct PROCINFO *proc) | ||
| + | { | ||
| + | char pathName[]="/dev/cpu/99/msr"; | ||
| + | ssize_t rbyte=0; | ||
| + | int cpu=0, File=-1; | ||
| + | |||
| + | if(core!=NULL && proc!=NULL) | ||
| + | for(cpu=0; cpu < proc->Attrib->ThreadCount; cpu++) | ||
| + | { | ||
| + | sprintf(pathName, "/dev/cpu/%d/msr", cpu); | ||
| + | if((File=open(pathName, O_RDONLY)) != -1) | ||
| + | { | ||
| + | rbyte=pread(File, &core[cpu].Perf, 8, IA32_PERF_STATUS); | ||
| + | rbyte=pread(File, &core[cpu].Therm, 8, IA32_THERM_STATUS); | ||
| + | close(File); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void CORE_Free_Info(struct COREINFO *core) | ||
| + | { | ||
| + | if(core) | ||
| + | { | ||
| + | free(core); | ||
| + | core=NULL; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void CORE_Show_Info(struct COREINFO *core, struct PROCINFO *proc) | ||
| + | { | ||
| + | int cpu=0; | ||
| + | |||
| + | if(core!=NULL && proc!=NULL) | ||
| + | { | ||
| + | printf("\n\tCore#\tRatio\tx Clock\t= Frequency\tTJMAX\t- DTS\t= Temperature\n"); | ||
| + | for(cpu=0; cpu < proc->Attrib->ThreadCount; cpu++) | ||
| + | printf("\t%2d\t %2d\tx %3lld\t= %4lld MHz\t %3d\t- %3d\t= %3d°C\n", \ | ||
| + | cpu, \ | ||
| + | core[cpu].Perf.Ratio, \ | ||
| + | proc->Attrib->Clock, \ | ||
| + | core[cpu].Perf.Ratio * proc->Attrib->Clock, \ | ||
| + | core[cpu].Temp.Target, \ | ||
| + | core[cpu].Therm.DTS, \ | ||
| + | core[cpu].Temp.Target - core[cpu].Therm.DTS); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void PROC_Show_Info(struct PROCINFO *proc, struct CACHEINFO *cache[]) | ||
| + | { | ||
| + | const float tension[0B1000]={0.0f, 5.0f, 3.3f, 0.0f, 2.9f, 0.0f, 0.0f, 0.0f}; | ||
| + | const char *power[2]={"OFF", "ON"}; | ||
| + | int ix=0; | ||
| + | |||
| + | if(proc!=NULL && cache[0]!=NULL && cache[1]!=NULL && cache[2]!=NULL) | ||
| + | { | ||
| + | printf("\n\t%s\n\tBase clock @ %lld MHz\n\t%sclocked @ %lld MHz\n", \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) proc, proc->Attrib->Version), \ | ||
| + | proc->Attrib->Clock, \ | ||
| + | llabs(proc->Attrib->CurrentSpeed - proc->Attrib->MaxSpeed) > 20 ? \ | ||
| + | "Over" : "Factory ", \ | ||
| + | proc->Attrib->CurrentSpeed); | ||
| + | printf("\t%lld/%lld cores enabled, %lld threads detected.\n", \ | ||
| + | proc->Attrib->CoreEnabled, \ | ||
| + | proc->Attrib->CoreCount, \ | ||
| + | proc->Attrib->ThreadCount); | ||
| + | printf("\tSocket : %s\n", \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) proc, proc->Attrib->Socket)); | ||
| + | printf("\tTension: %.1f V\n\t", | ||
| + | proc->Attrib->Voltage.Mode ? proc->Attrib->Voltage.Tension / 10.0f \ | ||
| + | : tension[proc->Attrib->Voltage.Tension & 0B0111]); | ||
| + | for(ix=0; ix < 3; ix++) | ||
| + | printf("%s [%4lld]%s", \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) cache[ix], cache[ix]->Attrib->Socket), \ | ||
| + | cache[ix]->Attrib->Installed_Size, ix < 2 ? " " : ""); | ||
| + | printf("\n\n\tCPUID.1:EAX=0x%08X CPUID.1:EDX=0x%08X\n\n", \ | ||
| + | proc->Attrib->CPUID.EAX, proc->Attrib->CPUID.EDX); | ||
| + | printf("\tAdvanced Programmable Interrupt Controller APIC [%3s]\n", \ | ||
| + | power[proc->Attrib->CPUID.EDX.APIC]); | ||
| + | printf("\tHyper-Threading [%3s]\n", \ | ||
| + | power[proc->Attrib->CPUID.EDX.HyperThreading]); | ||
| + | printf("\tMemory Type Range Registers MTRR [%3s]\n", \ | ||
| + | power[proc->Attrib->CPUID.EDX.MTRR]); | ||
| + | printf("\tPage Attribute Table PAT [%3s]\n", \ | ||
| + | power[proc->Attrib->CPUID.EDX.PAT]); | ||
| + | printf("\tInstruction set: MMX [%3s] SSE [%3s] SSE2 [%3s]\n", \ | ||
| + | power[proc->Attrib->CPUID.EDX.MMX], \ | ||
| + | power[proc->Attrib->CPUID.EDX.SSE], \ | ||
| + | power[proc->Attrib->CPUID.EDX.SSE2]); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void SYS_Show_Info(struct BIOSINFO *bios, \ | ||
| + | struct BOARDINFO *board, \ | ||
| + | struct MEMARRAY *memArray, \ | ||
| + | struct MEMDEV **memory ) | ||
| + | { | ||
| + | unsigned long long totalMemSize=0; | ||
| + | int ix=0; | ||
| + | |||
| + | if(bios!=NULL && board!=NULL && memArray!=NULL && memory!=NULL) | ||
| + | { | ||
| + | printf("\n\tBoard: %s\n\t |- version %s\n\t |- manufactured by %s\n", \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) board, board->Attrib->Product), \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) board, board->Attrib->Version), \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) board, board->Attrib->Manufacturer)); | ||
| + | printf("\n\tBIOS: %s\n\t |- version %s\n\t |- released date %s\n\t |- revision %lld.%lld\n", \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) bios, bios->Attrib->Vendor), \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) bios, bios->Attrib->Version), \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) bios, bios->Attrib->Release_Date), \ | ||
| + | bios->Attrib->Major_Release, bios->Attrib->Minor_Release); | ||
| + | printf("\t |- ROM Size: %lld KB at 0x%04X\n", | ||
| + | 64 * (1 + bios->Attrib->ROM_Size), bios->Attrib->Address); | ||
| + | for(ix=0; ix < memArray->Attrib->Number_Devices; ix++) | ||
| + | totalMemSize+=memory[ix]->Attrib->Size; | ||
| + | printf("\n\tRAM: %lld/%lld MB\n", totalMemSize, memArray->Attrib->Maximum_Capacity/1024); | ||
| + | for(ix=0; ix < memArray->Attrib->Number_Devices; ix++) | ||
| + | printf("\t |- %s:%s %lld MB @ %lld MHz\n", \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) memory[ix], memory[ix]->Attrib->Socket), \ | ||
| + | SMB_Find_String((struct STRUCTINFO*) memory[ix], memory[ix]->Attrib->Bank), \ | ||
| + | memory[ix]->Attrib->Size, memory[ix]->Attrib->Speed); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | int Menu_Getkey(void) | ||
| + | { | ||
| + | int key=0, flush=0; | ||
| + | |||
| + | key=flush=tolower(getchar()); | ||
| + | while(flush != '\n') | ||
| + | flush=getchar(); | ||
| + | return(key); | ||
| + | } | ||
| + | |||
| + | |||
| + | int main(int argc, char *argv[]) | ||
| + | { | ||
| + | int ix=0, runLevel=0, function=FN_NOOP, command=0; | ||
| + | |||
| + | struct BIOSINFO *Bios = BIOS_Read_Info(); | ||
| + | struct BOARDINFO *Board= BOARD_Read_Info(); | ||
| + | struct PROCINFO *Proc = PROC_Read_Info(); | ||
| + | struct CACHEINFO *Cache[3]={CACHE_Read_Info(0), CACHE_Read_Info(1), CACHE_Read_Info(2)}; | ||
| + | struct MEMARRAY *MemArray = MEM_Read_Array(); | ||
| + | struct MEMDEV **Memory = MEM_ReadAll_Devices(MemArray); | ||
| + | struct COREINFO *Core=CORE_Read_Info(Proc); | ||
| + | |||
| + | char menuLabel[LEVELS][CHARS]= | ||
| + | { | ||
| + | MENU_LABEL_ROOT, | ||
| + | MENU_LABEL_HELP, | ||
| + | MENU_LABEL_SHOW, | ||
| + | MENU_LABEL_DUMP, | ||
| + | MENU_LABEL_ATTR, | ||
| + | MENU_LABEL_STRG, | ||
| + | MENU_LABEL_CACH, | ||
| + | MENU_LABEL_CACH, | ||
| + | MENU_LABEL_MEMY, | ||
| + | MENU_LABEL_MEMY, | ||
| + | MENU_LABEL_CMOD | ||
| + | }; | ||
| + | char menuPrompt[LEVELS][CHARS]= | ||
| + | { | ||
| + | MENU_PROMPT_ROOT, | ||
| + | MENU_PROMPT_HELP, | ||
| + | MENU_PROMPT_SHOW, | ||
| + | MENU_PROMPT_DUMP, | ||
| + | MENU_PROMPT_ATTR, | ||
| + | MENU_PROMPT_STRG, | ||
| + | MENU_PROMPT_CACH, | ||
| + | MENU_PROMPT_CACH, | ||
| + | MENU_PROMPT_MEMY, | ||
| + | MENU_PROMPT_MEMY, | ||
| + | MENU_PROMPT_CMOD | ||
| + | }; | ||
| + | struct MENUNAV levelRoot[]=MENU_LEVEL_ROOT, | ||
| + | levelHelp[]=MENU_LEVEL_HELP, | ||
| + | levelShow[]=MENU_LEVEL_SHOW, | ||
| + | levelDump[]=MENU_LEVEL_DUMP, | ||
| + | levelAttr[]=MENU_LEVEL_ATTR, | ||
| + | levelStrg[]=MENU_LEVEL_STRG, | ||
| + | levelAttH[]=MENU_LEVEL_ATTH, | ||
| + | levelStrH[]=MENU_LEVEL_STRH, | ||
| + | levelAttY[]=MENU_LEVEL_ATTY, | ||
| + | levelStrY[]=MENU_LEVEL_STRY, | ||
| + | levelCMod[]=MENU_LEVEL_CMOD; | ||
| + | |||
| + | struct MENUNAV *menuNav[LEVELS]= | ||
| + | { | ||
| + | levelRoot, | ||
| + | levelHelp, | ||
| + | levelShow, | ||
| + | levelDump, | ||
| + | levelAttr, | ||
| + | levelStrg, | ||
| + | levelAttH, | ||
| + | levelStrH, | ||
| + | levelAttY, | ||
| + | levelStrY, | ||
| + | levelCMod | ||
| + | }; | ||
| + | |||
| + | if(MemArray!=NULL) | ||
| + | for(ix=0; ix < MemArray->Attrib->Number_Devices; ix++) | ||
| + | { | ||
| + | menuPrompt[LV_ATTY][23+ix*6]='['; | ||
| + | menuPrompt[LV_ATTY][24+ix*6]='1'+ix; | ||
| + | menuPrompt[LV_ATTY][25+ix*6]=']'; | ||
| + | menuNav[LV_ATTY][3+ix].Command='1'+ix; | ||
| + | menuNav[LV_ATTY][3+ix].Function=FN_ATTD+ix; | ||
| + | menuPrompt[LV_STRY][23+ix*6]='['; | ||
| + | menuPrompt[LV_STRY][24+ix*6]='1'+ix; | ||
| + | menuPrompt[LV_STRY][25+ix*6]=']'; | ||
| + | menuNav[LV_STRY][3+ix].Command='1'+ix; | ||
| + | menuNav[LV_STRY][3+ix].Function=FN_STRD+ix; | ||
| + | } | ||
| + | |||
| + | while(function != FN_EXIT) | ||
| + | { | ||
| + | Menu_Display(runLevel); | ||
| + | { | ||
| + | command=Menu_Getkey(); | ||
| + | |||
| + | ix=0; | ||
| + | while( command != menuNav[runLevel][ix].Command \ | ||
| + | && menuNav[runLevel][ix].Command != EOL ) | ||
| + | ix++ ; | ||
| + | |||
| + | function =menuNav[runLevel][ix].Function; | ||
| + | runLevel=menuNav[runLevel][ix].NewLevel; | ||
| + | } | ||
| + | switch(function) | ||
| + | { | ||
| + | case FN_SHWC: CORE_Update_Info(Core, Proc); | ||
| + | CORE_Show_Info(Core, Proc); | ||
| + | break; | ||
| + | case FN_SHWP: PROC_Show_Info(Proc, Cache); | ||
| + | break; | ||
| + | case FN_SHWS: SYS_Show_Info(Bios, Board, MemArray, Memory); | ||
| + | break; | ||
| + | case FN_ATTB: SMB_Dump_Attribs((struct STRUCTINFO*) Bios); | ||
| + | break; | ||
| + | case FN_ATTM: SMB_Dump_Attribs((struct STRUCTINFO*) Board); | ||
| + | break; | ||
| + | case FN_ATTP: SMB_Dump_Attribs((struct STRUCTINFO*) Proc); | ||
| + | break; | ||
| + | case FN_ATL1: SMB_Dump_Attribs((struct STRUCTINFO*) Cache[0]); | ||
| + | break; | ||
| + | case FN_ATL2: SMB_Dump_Attribs((struct STRUCTINFO*) Cache[1]); | ||
| + | break; | ||
| + | case FN_ATL3: SMB_Dump_Attribs((struct STRUCTINFO*) Cache[2]); | ||
| + | break; | ||
| + | case FN_ATTY: SMB_Dump_Attribs((struct STRUCTINFO*) MemArray); | ||
| + | break; | ||
| + | case FN_ATTD+0: | ||
| + | case FN_ATTD+1: | ||
| + | case FN_ATTD+2: | ||
| + | case FN_ATTD+3: | ||
| + | case FN_ATTD+4: | ||
| + | case FN_ATTD+5: | ||
| + | case FN_ATTD+6: | ||
| + | case FN_ATTD+7: SMB_Dump_Attribs((struct STRUCTINFO*) Memory[function-FN_ATTD]); | ||
| + | break; | ||
| + | case FN_STRB: SMB_Dump_Strings((struct STRUCTINFO*) Bios); | ||
| + | break; | ||
| + | case FN_STRM: SMB_Dump_Strings((struct STRUCTINFO*) Board); | ||
| + | break; | ||
| + | case FN_STRP: SMB_Dump_Strings((struct STRUCTINFO*) Proc); | ||
| + | break; | ||
| + | case FN_STL1: SMB_Dump_Strings((struct STRUCTINFO*) Cache[0]); | ||
| + | break; | ||
| + | case FN_STL2: SMB_Dump_Strings((struct STRUCTINFO*) Cache[1]); | ||
| + | break; | ||
| + | case FN_STL3: SMB_Dump_Strings((struct STRUCTINFO*) Cache[2]); | ||
| + | break; | ||
| + | case FN_STRY: SMB_Dump_Strings((struct STRUCTINFO*) MemArray); | ||
| + | break; | ||
| + | case FN_STRD+0: | ||
| + | case FN_STRD+1: | ||
| + | case FN_STRD+2: | ||
| + | case FN_STRD+3: | ||
| + | case FN_STRD+4: | ||
| + | case FN_STRD+5: | ||
| + | case FN_STRD+6: | ||
| + | case FN_STRD+7: SMB_Dump_Strings((struct STRUCTINFO*) Memory[function-FN_STRD]); | ||
| + | } | ||
| + | }; | ||
| + | |||
| + | CORE_Free_Info(Core); | ||
| + | MEM_FreeAll_Devices(Memory, MemArray); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) MemArray); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) Cache[2]); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) Cache[1]); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) Cache[0]); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) Proc); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) Board); | ||
| + | BIOS_Free_Structure((struct STRUCTINFO*) Bios); | ||
| + | |||
| + | return(function); | ||
| + | } | ||
| + | |||
| + | </syntaxhighlight> | ||
| + | |||
==== Release 2012-0.1.1 ==== | ==== Release 2012-0.1.1 ==== | ||
===== coremod.c ===== | ===== coremod.c ===== | ||