I have initialized Intel 82815 SDRAM controller but for a special type
of RAM without reading SPD registers. I know that DRP register is :
0xCC. I added the code to Coreboot.
I tested much and concluded that RAM has a problem in a way as you
guys told me before. When i change the hardwaremain() , even adding
some code which are bypassed, the results of the post code numbers
become different!
I do not know what to do! c_start.S is OK and it is executed and the
program starts executing hardwaremain() but adding code to the
hardwaremain() any where seems to disorder printed post code values.
Is there any interrupt or timer set immediately after hardwaremain()?
I checked coreboot_ram in build/. The assembly code of hardwaremian() seems OK.
void sdram_enable(void)
{
asm("pushal");
asm("push %eax");
asm("push %ebx");
asm("push %ecx");
asm("push %edx");
asm("push %esi");
asm("push %edi");
asm("push %esp");
asm("push %ebp");
asm("pushfl");
asm("jmp firstlbl");
asm("mov %ax, %ax");
asm("nop");
/* Cache disable */
asm("firstlbl:");
asm("mov %cr0, %eax");
asm("and $0x9fffffff, %eax");
asm("or $0x40000000, %eax");
asm("mov %eax, %cr0");
/* Configure the RAM command. */
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("movw $0x0CFC, %dx");
asm("in %dx, %eax");
asm("and $0x1fffffff, %eax");
asm("or $0x05000000, %eax");
asm("movw $0x0CFC, %dx");
asm("out %eax, %dx");
//general initialization
//50-53**************************
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
//Res mask
asm("and $0x0000F823, %eax");
//Bios => cas 2clk
asm("or $0x2fcc0140, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//70,72-73**************************
asm("mov $0x0cf8, %dx");
asm("mov $0x80000070, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("movb $0xc0, %al");
asm("out %al, %dx");
asm("mov $0x0cfe, %dx");
asm("inw %dx, %ax");
//Res mask
asm("and $0x7704, %ax");
//Bios
asm("or $0x0012, %ax");
asm("mov $0x0cfe, %dx");
asm("out %ax, %dx");
//92-93****************************
asm("mov $0x0cf8, %dx");
asm("mov $0x80000090, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfe, %dx");
asm("movw $0xff5c, %ax");
asm("out %ax, %dx");
//#94-95*****************************
asm("mov $0x0cf8, %dx");
asm("mov $0x80000094, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfe, %dx");
asm("inw %dx, %ax");
//#Res mask
asm("and $0xffc0, %ax");
//#Bios
asm("or $0x001c, %ax");
asm("mov $0x0cfe, %dx");
asm("out %ax, %dx");
//#98-9B*****************************
asm("mov $0x0cf8, %dx");
asm("mov $0x80000098, %eax");
asm("out %eax, %dx");
asm("movw $0x0cfc, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0x7F887F88, %eax");
//#Bios
asm("or $0x80238023, %eax");
asm("movw $0x0cfc, %dx");
asm("out %eax, %dx");
//#9c-9f***************************
asm("mov $0x0cf8, %dx");
asm("mov $0x8000009c, %eax");
asm("out %eax, %dx");
asm(" movw $0x0CFC, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0xFFFF7FFF, %eax");
//#Bios
asm("or $0x00008000, %eax");
asm("movw $0x0CFC, %dx");
asm("out %eax, %dx");
//#2c-2f***************************
asm("mov $0x0cf8, %dx");
asm("mov $0x8000002c, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("mov $0x80271043, %eax");
asm("out %eax, %dx");
//58-5b**************************
asm("mov $0x0cf8, %dx");
asm("mov $0x80000058, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
asm("and $0xcccccf7f, %eax");
asm("or $0x33333000, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//5c-5f**************************
asm("mov $0x0cf8, %dx");
asm("mov $0x8000005c, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
asm("and $0xcccccccc, %eax");
asm("or $0x33333333, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//#;--------------------------------------------------
//#NOP /* 1. Apply NOP. */
//#display 1
asm("mov $1, %al");
asm("out %al, $0x80");
//#%%%%%%%%%%%%%%%%%%%%
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0x0000F823, %eax");
//#Bios => cas 2clk
asm("or $0x8fcc0140, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//#%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x00000000, %ebx");
asm("mov (%ebx), %eax");
asm("mov $0x08000000, %ebx");
asm("mov (%ebx), %eax");
asm("mov $0x10000000, %ebx");
asm("mov (%ebx), %eax");
asm("mov $0x18000000, %ebx");
asm("mov (%ebx), %eax");
//#%%%%%%%%%%%%%%%%%%%%%
asm("mov $1, %di");
asm("delay11:");
asm("mov $200000, %ecx");
asm("delay1:");
asm("dec %ecx");
asm("jnz delay1");
asm("dec %di");
asm("jnz delay11");
//#;--------------------------------------------------
//#precharge /* 2. Precharge all. Wait tRP. */
//#display 2
asm("mov $2, %al");
asm("out %al, $0x80");
//#%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0x0000F823, %eax");
//#Bios => cas 2clk
asm("or $0xafcc0140, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//#%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x00000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x08000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x10000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x18000000, %ebx");
asm("mov %ds:(%ebx), %eax");
//#%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $10, %di");
asm("delay21:");
asm("mov $1000, %ecx");
asm("delay2:");
asm("dec %ecx");
asm("jnz delay2");
asm("dec %di");
asm("jnz delay21 ");
//#;--------------------------------------------------
//#CBR cycle /* 3. Perform 8 refresh cycles. Wait tRC each time. */
//#display 3
asm("mov $3, %al");
asm("out %al, $0x80");
//#%%%%%%%%%%%%%%%%%%%%%%
asm("mov $8, %esi");
asm("refreshcycle:");
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0x0000F823, %eax");
//#Bios => cas 2clk
asm("or $0xefcc0140, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//#%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x00000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x08000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x10000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x18000000, %ebx");
asm("mov %ds:(%ebx), %eax");
//#%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $10, %di");
asm("delay31:");
asm("mov $1000, %ecx");
asm("delay3:");
asm("dec %ecx");
asm("jnz delay3");
asm("dec %di");
asm("jnz delay31");
asm("dec %esi");
asm("jnz refreshcycle");
//#;--------------------------------------------------
//#mode register set /* 4. Mode register set. Wait two memory cycles. */
//#display 4
asm("mov $4, %al");
asm("out %al, $0x80");
//#%%%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0x0000F823, %eax");
//#Bios => cas 2clk
asm("or $0xcfcc0140, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//#%%%%%%%%%%%%%%%%%%%%%%%%
//#1d0 =>150 => 03a
//#650 => 650 => 0ca
asm("mov $0x0000003a, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x0800003a, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x100000ca, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x180000ca, %ebx");
asm("mov %ds:(%ebx), %eax");
//#%%%%%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $10, %di");
asm("delay41:");
asm("mov $1000, %ecx");
asm("delay4:");
asm("dec %ecx");
asm("jnz delay4");
asm("dec %di");
asm("jnz delay41");
//#;--------------------------------------------------
//#normal operation /* 5. Normal operation (enables refresh at 15.6usec). */
//#display 5
asm("mov $5, %al");
asm("out %al, $0x80");
//#%%%%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x0cf8, %dx");
asm("mov $0x80000050, %eax");
asm("out %eax, %dx");
asm("mov $0x0cfc, %dx");
asm("in %dx, %eax");
//#Res mask
asm("and $0x0000F823, %eax");
//#Bios => cas 2clk
asm("or $0x2fcc0140, %eax");
asm("mov $0x0cfc, %dx");
asm("out %eax, %dx");
//#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $0x00000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x08000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x10000000, %ebx");
asm("mov %ds:(%ebx), %eax");
asm("mov $0x18000000, %ebx");
asm("mov %ds:(%ebx), %eax");
//#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
asm("mov $10, %di");
asm("delay51:");
asm("mov $1000, %ecx");
asm("delay5:");
asm("dec %ecx");
asm("jnz delay5");
asm("dec %di");
asm("jnz delay51");
//#;--------------------------------------------------
asm("mov $10, %al");
asm("out %al, $0x80");
//#;--------------------------------------------------
asm("mov $0xffff, %cx");
asm("delayea1:");
asm("dec %cx");
asm("jnz delayea1");
//asm("mov %cr0, %eax");
//asm("and $0x9fffffff, %eax");
//asm("mov %eax, %cr0");
asm("popfl");
asm("pop %ebp");
asm("pop %esp");
asm("pop %edi");
asm("pop %esi");
asm("pop %edx");
asm("pop %ecx");
asm("pop %ebx");
asm("pop %eax");
asm("popal");
}