Soeren Sonnenburg wrote:
> On Tue, 2007-08-28 at 09:12 +0200, Giacomo Catenazzi wrote:
>> Soeren Sonnenburg wrote:
>>> Package: microcode.ctl
>>> Version: 1.17-3
>>> Severity: wishlist
>>>
>>> Rudolf Marek posted on June 21 a way to also extract core duo microcode
>>> updates, which fixes the infamous "Errata AE18 not fixed, update BIOS or
>>> microcode of the CPU!".
>> Could give me more info (links) about these microcodes?
> 
> not really... as you can see the microcodes are extracted from ibm
> thinkpads bios updates ... errata AE18 is the temperature sensor not
> anymore working (important if you have a macbook* core one duo and as
> apple did/does not release firmware/bios updates to fix this it is
> necessary to get temperature monitoring workin) ...
> 
>  errate list is here:
> http://www.geek.com/images/geeknews/2006Jan/core_duo_errata__2006_01_21__full.gif

I don't understand why new intel microcodes doesn't include it.
I'll ask Intel, but for one of the next version I'll include
also a small utility to extract information from microcode,
to show CPU and microcode date.

I attach a "preliminary" version. I used this version to check
what wrong with microcodes (a strange microcode caused reject
of all updates, because of a kernel bug).


ciao
        cate
/* */


#include <stdlib.h>
#include <stdio.h>


#define BUFFER_SIZE     4096
#define MICROCODE_SIZE (64*1024)


static
int check_microcode(const unsigned int microcode[], size_t len, const char title[])  {
    unsigned int header	  = microcode[0];
    unsigned int version  = microcode[1];
    unsigned int date	  = microcode[2];
    unsigned int cpu	  = microcode[3];
    unsigned int checksum = microcode[4];
    unsigned int loader	  = microcode[5];
    unsigned int flags	  = microcode[6];
    unsigned int size	  = microcode[7];
    unsigned int tot_size = microcode[8];

    unsigned int cpu1 = cpu        & 0xff;
    unsigned int cpu2 = cpu >>  8u & 0xff;
    unsigned int cpu3 = cpu >> 16u & 0xff;
    unsigned int cpu4 = cpu >> 24u & 0xff;

    unsigned int sum = 0;
    size_t i;

    if(size == 0)
	size = 2000;
    if(tot_size == 0)
	tot_size = 48 + size;

    printf("sec:%14s, header:%1u, loader:%1u, date: %08x, version:%4u, cpu:%8x, flag1:%08x, ",
	    title,    header,	  loader,     date,       version,     cpu,     flags);

    if(len*4 != tot_size || size < 2000 || tot_size < 2048) {
	fprintf(stderr, "Size error: readed: %u, tot_size: %u, size: %u\n", len, tot_size, size);
	return 1;
    }

    for(i=0; i<len; i++) {
	sum += microcode[i];
    }
    if (sum == 0) {
	printf("checksum ok!\n");
    } else {
	printf("checksum error\n");
    }
}	


static
int read_microcode(void)  {
    int line_no = 0;
    char line_buffer[BUFFER_SIZE+1];
    char title[16+1];
    unsigned int microcode[MICROCODE_SIZE+1];
    size_t pos = 0;
    int scanned;

    title[0]=0;
    while(fgets(line_buffer, BUFFER_SIZE, stdin) != NULL)  {
	++line_no;
	if (line_buffer[0] == 0) {
	    if (pos != 0)
	        check_microcode(microcode, pos, title);
	    continue;

	}
	if (line_buffer[0] == '/' && line_buffer[1] == '*')  {
	    if (pos !=0)
		check_microcode(microcode, pos, title);
	    pos = 0;
	    if ( sscanf(line_buffer, "/* %16s.inc  ", title) != 1) {
		title[0] = 0;
	    }
	    continue;
	}
	if (line_buffer[0] == '/')
	    continue;
	scanned = sscanf(line_buffer, "%x, %x, %x, %x",
					microcode + pos,
					microcode + pos + 1,
					microcode + pos + 2,
					microcode + pos + 3);
	if(scanned != 4) {
	    fprintf(stderr, "Invalid format at line %i\n", line_no);
	    return 1;
        }
	pos += 4;
    }
}


int main() {
  read_microcode();
  return 0;
}

Reply via email to