⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cooking.c

📁 Linux下的系统信息获取
💻 C
📖 第 1 页 / 共 5 页
字号:
        case 7:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_128ECC);					break;        case 8:		sprintf (line, "%-35s%s %s\n", TYPE5_ERROR_DETECTION, SEP1, TYPE5_ED_CRC);					break;    	default:    sprintf (line, "%-35s%s %d\n", TYPE5_ERROR_DETECTION, SEP1, type5->error_detection);	}  	strcat(file, line);    sprintf(line, "%-35s%s\n", TYPE5_ECC, SEP1);    strcat(file, line);    if( (type5->ecc) & 0x01 )    {   sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_OTHER);        strcat(file, line);    }    if( (type5->ecc) & 0x02 )    {   sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_UNKNOWN);        strcat(file, line);    }    if( (type5->ecc) & 0x04 )    {   sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_NONE);        strcat(file, line);    }    if( (type5->ecc) & 0x08 )    {   sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_SINGLE_BIT);        strcat(file, line);    }    if( (type5->ecc) & 0x10 )    {   sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_DOUBLE_BIT);        strcat(file, line);    }    if( (type5->ecc) & 0x20 )    {   sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_SCRUBBING);        strcat(file, line);    }    switch(type5->supported_interleave)	{	    case 1:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_OTHER);					break;        case 2:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_UNKNOWN);					break;        case 3:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_ONE_WAY);					break;        case 4:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_TWO_WAY);					break;        case 5:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_FOUR_WAY);					break;        case 6:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_EIGHT_WAY);					break;        case 7:		sprintf (line, "%-35s%s %s\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, TYPE5_I_SIXTEEN_WAY);					break;    	default:    sprintf (line, "%-35s%s %d\n", TYPE5_SUPPORTED_INTERLEAVE, SEP1, type5->supported_interleave);	}  	strcat(file, line);    switch(type5->current_interleave)	{	    case 1:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_OTHER);					break;        case 2:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_UNKNOWN);					break;        case 3:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_ONE_WAY);					break;        case 4:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_TWO_WAY);					break;        case 5:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_FOUR_WAY);					break;        case 6:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_EIGHT_WAY);					break;        case 7:		sprintf (line, "%-35s%s %s\n", TYPE5_CURRENT_INTERLEAVE, SEP1, TYPE5_I_SIXTEEN_WAY);					break;    	default:    sprintf (line, "%-35s%s %d\n", TYPE5_CURRENT_INTERLEAVE, SEP1, type5->current_interleave);	}  	strcat(file, line);    sprintf(line, "%-35s%s %d %s\n", TYPE5_MAX_MEM_MOD_SIZE, SEP1, pow2(type5->max_mem_module_size), MB);    strcat(file, line);    sprintf(line, "%-35s%s\n", TYPE5_SUPPORTED_SPEEDS, SEP1);    strcat(file, line);    if( (type5->supported_speeds) & 0x01 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SSPEED_OTHER);        strcat(file, line);    }    if( (type5->supported_speeds) & 0x02 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SSPEED_UNKNOWN);        strcat(file, line);    }    if( (type5->supported_speeds) & 0x04 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SSPEED_70);        strcat(file, line);    }    if( (type5->supported_speeds) & 0x08 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SSPEED_60);        strcat(file, line);    }    if( (type5->supported_speeds) & 0x10 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SSPEED_50);        strcat(file, line);    }    sprintf(line, "%-35s%s\n", TYPE5_SUPPORTED_TYPES, SEP1);    strcat(file, line);    if( (type5->supported_types) & 0x0001 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_OTHER);        strcat(file, line);    }    if( (type5->supported_types) & 0x0002 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_UNKNOWN);        strcat(file, line);    }    if( (type5->supported_types) & 0x0004 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_STANDARD);        strcat(file, line);    }    if( (type5->supported_types) & 0x0008 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_FAST_PAGE);        strcat(file, line);    }    if( (type5->supported_types) & 0x0010 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_EDO);        strcat(file, line);    }    if( (type5->supported_types) & 0x0020 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_PARITY);        strcat(file, line);    }    if( (type5->supported_types) & 0x0040 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_ECC);        strcat(file, line);    }    if( (type5->supported_types) & 0x0080 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_SIMM);        strcat(file, line);    }    if( (type5->supported_types) & 0x0100 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_DIMM);        strcat(file, line);    }    if( (type5->supported_types) & 0x0200 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_BURST_EDO);        strcat(file, line);    }    if( (type5->supported_types) & 0x0400 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ST_SDRAM);        strcat(file, line);    }    sprintf(line, "%-35s%s\n", TYPE5_SUPPORTED_VOLTAGES, SEP1);    strcat(file, line);    if( (type5->voltage) & 0x01 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SV_50);        strcat(file, line);    }    if( (type5->voltage) & 0x02 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SV_33);        strcat(file, line);    }    if( (type5->voltage) & 0x04 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_SV_29);        strcat(file, line);    }    sprintf(line, "%-35s%s %d %s \n", TYPE5_NR_ASSOC_SLOTS, SEP1, type5->nr_assoc_slots, TYPE5_SLOTS);    strcat(file, line);    ptr = (unsigned char *)smbiosstruct;    ptr += 0x0f;    sprintf(line, "%-35s%s \n", TYPE5_MEM_MOD_HANDLES, SEP1);    strcat(file, line);    for (i=0; i < (int)(type5->nr_assoc_slots); i++)    {        sprintf(line, "%-35s  %s %s %d \n", "", SEP2, HANDLE, (unsigned int)(*ptr));        strcat(file, line);        ptr += 2;    }    /* SMBIOS 2.1 and higher */    if( smbiosstruct->length == ((type5->nr_assoc_slots * 2) + 16) )    {        ptr = (unsigned char *) smbiosstruct;        ptr = ptr + ((type5->nr_assoc_slots * 2) + 0x0F);        sprintf(line, "%-35s%s\n", TYPE5_ENABLED_ECC, SEP1);        strcat(file, line);        if( (*ptr) & 0x01 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_OTHER);            strcat(file, line);        }        if( (*ptr) & 0x02 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_UNKNOWN);            strcat(file, line);        }        if( (*ptr) & 0x04 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_NONE);            strcat(file, line);        }        if( (*ptr) & 0x08 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_SINGLE_BIT);            strcat(file, line);        }        if( (*ptr) & 0x10 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_DOUBLE_BIT);            strcat(file, line);        }        if( (*ptr) & 0x20 )        {            sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE5_ECC_SCRUBBING);            strcat(file, line);        }    }    /* now line contains a string with fully interpreted type 4 data */	*plength = strlen(file);	/* allocate memory */	scratch = kmalloc (*plength+1, GFP_BUFFER);	if (scratch == NULL)	{		*plength = 0;		return NULL;	}	/* copy the interpreted data */	memcpy (scratch, file, *plength);	/* return a string with all the interpreted data for the given raw structure. */	/* the caller is responsible to free the memory. */		return scratch;}/** \fn unsigned char * bios_cook_type_6 (smbios_struct *smbiosstruct, unsigned int * plength)  * \brief writes interpreted SMBIOS Type 6 data to a /proc file  * \param smbiosstruct pointer to SMBIOS Type 6 raw structure  * \param plength amount of memory allocated by this function  * \return pointer to string that holds the interpreted data  *  * this function gets a raw SMBIOS Type 6 (Memory Module) structure. it  * interpretes the raw data and builds a string with the interpreted  * data. this is the return value of this structure. the caller is  * responsible to free the allocated memory.  *  * \author Joachim Braeuer  * \date March 2001  */unsigned char *bios_cook_type_6 (smbios_struct * smbiosstruct, unsigned int *plength){	smbios_type_6 *type6;    unsigned char * scratch;		/* contains the full block of interpreted data */    /* on some systems the system crashed if the stack (local variables) */    /* is bigger than one pages (4k). since linux needs some space in this */    /* page the variables should never exceed 3kB. */	unsigned char file[2800];	/* contains one line of the above file */    unsigned char line[128];    /* cast our data ptr to a structure ptr of SMBIOS type 6 */    type6 = (smbios_type_6 *)smbiosstruct;    sprintf (line, "%-35s%s %d %s\n", TYPE, SEP1, smbiosstruct->type, TYPE6_NAME);    strcpy(file, line);	sprintf (line, "%-35s%s %d %s\n", LENGTH, SEP1, smbiosstruct->length, BYTES);	strcat(file, line);	sprintf (line, "%-35s%s %d\n\n", HANDLE, SEP1, smbiosstruct->handle);	strcat(file, line);	sprintf (line, "%-35s%s %s\n", TYPE6_SOCKET_DESIGNATION, SEP1, GetString(smbiosstruct, (unsigned int)(type6->designation)));	strcat(file, line);    sprintf(line, "%-35s%s ", TYPE6_RAS, SEP1);    strcat(file, line);    if( (type6->connection & 0xF0) != 0xF0 )    {        sprintf(line, "%d", (type6->connection & 0xF0) >> 4);        strcat(file, line);    }    if( (type6->connection & 0x0F) != 0x0F )    {        sprintf(line, " & %d", (type6->connection & 0x0F));        strcat(file, line);    }    strcat(file, "\n");    if(type6->current_speed > 0)    {        sprintf(line, "%-35s%s %d %s \n", TYPE6_CURRENT_SPEED, SEP1, type6->current_speed, NS);        strcat(file, line);    }        sprintf(line, "%-35s%s\n", TYPE6_CURRENT_TYPE, SEP1);    strcat(file, line);    if( (type6->current_type) & 0x0001 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_OTHER);        strcat(file, line);    }    if( (type6->current_type) & 0x0002 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_UNKNOWN);        strcat(file, line);    }    if( (type6->current_type) & 0x0004 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_STANDARD);        strcat(file, line);    }    if( (type6->current_type) & 0x0008 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_FAST_PAGE);        strcat(file, line);    }    if( (type6->current_type) & 0x0010 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_EDO);        strcat(file, line);    }    if( (type6->current_type) & 0x0020 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_PARITY);        strcat(file, line);    }    if( (type6->current_type) & 0x0040 )    {        sprintf(line, "%-35s  %s %s \n", "", SEP2, TYPE6_CT_ECC);  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -