[Etherboot-users] Via RNG xstore in Etherboot
Brought to you by:
marty_connor,
stefanhajnoczi
From: Robert H. <rob...@ya...> - 2006-01-10 16:22:23
|
Hi all, OK this question may be a bit obscure, but I hope someone might have some insight as to what is going on... I am trying to call the Via RNG (xstore instruction) from etherboot, and my platform resets every time I call it. I have copied the xstore asm() code from the hw_random.c driver in Linux. I have made sure the Via MSR 0x110b is set up correctly. I've checked that the assembler and byte code looks OK (the same as the hwrandom driver), but I still get the reset. Do I have to set something else up on the processor, or call xstore in a different way? Thanks, Robert The following is the code I am using showing the MSR initialization and the xstore call. Though the first read of the MSR indicates that the RNG is enabled by default anyway. It is pretty much a straight copy from hw_random.c. #define MSR_VIA_RNG 0x110b enum { VIA_STRFILT_CNT_SHIFT = 16, VIA_STRFILT_FAIL = (1 << 15), VIA_STRFILT_ENABLE = (1 << 14), VIA_RAWBITS_ENABLE = (1 << 13), VIA_RNG_ENABLE = (1 << 6), VIA_XSTORE_CNT_MASK = 0x0F, VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */ VIA_RNG_CHUNK_4 = 0x01, /* 32 rand bits, 32 stored bits */ VIA_RNG_CHUNK_4_MASK = 0xFFFFFFFF, VIA_RNG_CHUNK_2 = 0x02, /* 16 rand bits, 32 stored bits */ VIA_RNG_CHUNK_2_MASK = 0xFFFF, VIA_RNG_CHUNK_1 = 0x03, /* 8 rand bits, 32 stored bits */ VIA_RNG_CHUNK_1_MASK = 0xFF, }; #define rdmsr(msr,val1,val2) \ __asm__ __volatile__("rdmsr" \ : "=a" (val1), "=d" (val2) \ : "c" (msr)) #define wrmsr(msr,val1,val2) \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (msr), "a" (val1), "d" (val2)) static int via_RNGinit( void ) { u32 lo, hi, old_lo; printf( "VIA init\n" ); rdmsr(MSR_VIA_RNG, lo, hi); printf( "lo = %#x, hi = %#x\n", lo, hi ); old_lo = lo; lo &= ~(0x7f << VIA_STRFILT_CNT_SHIFT); lo &= ~VIA_XSTORE_CNT_MASK; lo |= (VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE); lo |= VIA_RNG_ENABLE; lo |= ( 0x3 << 8 ); if (lo != old_lo) wrmsr(MSR_VIA_RNG, lo, hi); rdmsr(MSR_VIA_RNG, lo, hi); printf( "lo = %#x, hi = %#x\n", lo, hi ); if ((lo & VIA_RNG_ENABLE) == 0) { printf( "cannot enable VIA C3 RNG, aborting\n"); return -1; } printf( "Done!\n" ); return 0; } static inline u32 xstore(u32 *addr, u32 edx_in) { u32 eax_out; asm volatile (".byte 0x0f,0xa7,0xc0 /* xstore %%edi (addr=%0) */" : "=a"(eax_out), "=m"(*addr) : "D"(addr), "d"(edx_in)); return eax_out; } __________________________________________ Yahoo! DSL Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com |