Chameleon

Chameleon Commit Details

Date:2015-03-13 13:37:09 (9 years 1 month ago)
Author:zenith432
Commit:2631
Parents: 2630
Message:Fix setupChosenNode, Tweak asm.s
Changes:
M/branches/zenith432/i386/libsaio/fake_efi.c
M/branches/zenith432/i386/libsaio/saio_internal.h
M/branches/zenith432/i386/libsaio/asm.s

File differences

branches/zenith432/i386/libsaio/asm.s
303303
304304
305305
306
307
308
309
310
311306
312307
313308
314309
315
310
311
316312
313
314
317315
318316
319317
movzwl %sp, %esp
movzwl %bp, %ebp
// Modify caller's return address on the stack
// from linear address to segment offset.
popl %eax
// Reenable maskable interrupts.
sti
jmp *%ax
// Modify caller's return address on the stack
// from linear address to segment offset.
ret $2
.code32
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
branches/zenith432/i386/libsaio/fake_efi.c
738738
739739
740740
741
742
743
741
742
744743
745
746
747
748744
749745
750746
......
753749
754750
755751
756
752
757753
758754
759755
760756
761
757
762758
763759
764760
......
776772
777773
778774
775
776
777
778
779
779780
780781
781782
......
784785
785786
786787
787
788
789
788
789
790
790791
791
792
792793
793
794
795
796
794
795
796
797
797798
798
799
799800
800801
801802
//
UInt8 index = 0;
EFI_UINT16 PMTimerValue = 0;
EFI_UINT32 randomValue, tempValue, cpuTick;
EFI_UINT32 ecx, esi, edi = 0;
EFI_UINT32 rcx, rdx, rsi, rdi;
EFI_UINT32 randomValue = 0, cpuTick = 0;
EFI_UINT32 ecx = 0, edx = 0, esi = 0, edi = 0;
randomValue = tempValue = ecx = esi = edi = 0;// xor%ecx,%ecx
cpuTick = rcx = rdx = rsi = rdi = 0;
// LEAF_1 - Feature Information (Function 01h).
if (Platform.CPU.CPUID[CPUID_1][2] & 0x40000000)// Checking ecx:bit-30
{
//
EFI_UINT32 seedBuffer[16] = {0};
//
// Main loop to get 16 qwords (four bytes each).
// Main loop to get 16 dwords (four bytes each).
//
for (index = 0; index < 16; index++)// 0x17e12:
{
randomValue = computeRand();// callq0x18e20
cpuTick = getCPUTick();// callq0x121a7
cpuTick = (EFI_UINT32) getCPUTick();// callq0x121a7
randomValue = (randomValue ^ cpuTick);// xor%rdi,%rax
seedBuffer[index] = randomValue;// mov%rax,(%r15,%rsi,8)
}// jb0x17e12
//
do// 0x17e55:
{
//
// FIXME: PM Timer is usually @ 0x408, but its position is relocatable
// via PCI-to-ISA bridge. The location is reported in ACPI FADT,
// PM Timer Block address - zenith432
//
PMTimerValue = inw(0x408);// in(%dx),%ax
esi = PMTimerValue;// movzwl%ax,%esi
continue;// jb0x17e55(retry)
}
cpuTick = getCPUTick();// callq0x121a7
//printf("value: 0x%llx\n", getCPUTick());
rcx = (cpuTick >> 8);// mov%rax,%rcx
cpuTick = (EFI_UINT32) getCPUTick();// callq0x121a7
//printf("value: 0x%x\n", getCPUTick());
ecx = (cpuTick >> 8);// mov%rax,%rcx
// shr$0x8,%rcx
rdx = (cpuTick >> 10);// mov%rax,%rdx
edx = (cpuTick >> 0x10);// mov%rax,%rdx
// shr$0x10,%rdx
rdi = rsi;// mov%rsi,%rdi
rdi = (rdi ^ cpuTick);// xor%rax,%rdi
rdi = (rdi ^ rcx);// xor%rcx,%rdi
rdi = (rdi ^ rdx);// xor%rdx,%rdi
edi = esi;// mov%rsi,%rdi
edi = (edi ^ cpuTick);// xor%rax,%rdi
edi = (edi ^ ecx);// xor%rcx,%rdi
edi = (edi ^ edx);// xor%rdx,%rdi
seedBuffer[index] = (rdi & 0xff);// mov%dil,(%r15,%r12,1)
seedBuffer[index] = (edi & 0xff);// mov%dil,(%r15,%r12,1)
edi = (edi & 0x2f);// and$0x2f,%edi
edi = (edi + esi);// add%esi,%edi
branches/zenith432/i386/libsaio/saio_internal.h
3333
3434
3535
36
36
3737
3838
3939
extern voidhalt(void) __attribute__((noreturn));
extern voidstartprog(unsigned int address, void *arg) __attribute__((noreturn));
extern voidloader(UInt32 code, UInt32 cmdptr);
extern uint64_tcomputeRand(void);
extern uint32_tcomputeRand(void);
/* bios.s */
extern void bios(biosBuf_t *bb);

Archive Download the corresponding diff file

Revision: 2631