Skip to content

Commit 1a258b1

Browse files
committed
boot: Move PIC challenge to 1BL low ROM, before 2BL RAM copy
1 parent f1ad8cf commit 1a258b1

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

boot_rom/2bBootStartBios.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,9 @@ void BootStartBiosLoader(void)
261261
SHA1Input(&context,(void*)(PROGRAMM_Memory_2bl+20),bootloadersize-20);
262262
SHA1Result(&context,SHA1_result);
263263

264-
if (memcmp(&bootloaderChecksum[0],&SHA1_result[0],20)==0) {
265-
// HEHE, the Image we copy'd into ram is SHA-1 hash identical, this is Optimum
266-
BootPerformPicChallengeResponseAction();
267-
268-
} else {
269-
// Bad, the checksum does not match, but we can nothing do now, we wait until PIC kills us
264+
if (memcmp(&bootloaderChecksum[0],&SHA1_result[0],20)) {
265+
// Bad, the checksum does not match, we did not get a valid image to RAM, we stop and display an error
266+
setLED("rrrr");
270267
while(1);
271268
}
272269

@@ -358,9 +355,6 @@ void BootStartBiosLoader(void)
358355
// We are not Longer here
359356
}
360357

361-
// Bad, we did not get a valid im age to RAM, we stop and display a error
362-
//setLED("rrrr");
363-
364358
setLED("oooo");
365359

366360
// I2CTransmitWord(0x10, 0x1901); // no reset on eject

boot_rom/2bBootStartup.S

+5-3
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@
211211

212212
cld
213213

214+
// Set the stack pointer to give us a valid stack
215+
movl $0x1ffff0, %esp
216+
217+
call pic_challenge_response
218+
214219
// copy everything into RAM
215220

216221
mov $_ram_location, %edi
@@ -309,9 +314,6 @@ reload_cs:
309314
mov %eax, %fs
310315
mov %eax, %gs
311316

312-
// Set the stack pointer to give us a valid stack
313-
movl $0x1ffff0, %esp
314-
315317
// Clear out .bss
316318
xor %eax, %eax
317319
mov $BSS_SIZE_L, %ecx

boot_rom/2bPicResponseAction.c

+30-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int I2CTransmitWord(u8 bPicAddressI2cFormat, u16 wDataToWrite)
8484
}
8585
return ERR_I2C_ERROR_BUS;
8686
}
87-
87+
#if 0
8888
// ---------------------------- PIC challenge/response -----------------------------------------------------------
8989
//
9090
// given four bytes, returns a u16
@@ -143,6 +143,35 @@ int BootPerformPicChallengeResponseAction()
143143
// continues as part of video setup....
144144
return ERR_SUCCESS;
145145
}
146+
#endif
147+
void pic_challenge_response(void)
148+
{
149+
register u8 x1c, x1d, x1e, x1f;
150+
register u8 b1, b2, b3, b4;
151+
register int i;
152+
153+
smbus_set_addr(0x21); /* set PIC address; read command */
154+
x1c = smbus_read(0x1c);
155+
x1d = smbus_read(0x1d);
156+
x1e = smbus_read(0x1e);
157+
x1f = smbus_read(0x1f);
158+
159+
b1 = 0x33;
160+
b2 = 0xed;
161+
b3 = x1c << 2;
162+
b3 ^= x1d + 0x39;
163+
b3 ^= x1e >> 2;
164+
b3 ^= x1f + 0x63;
165+
b4 = x1c + 0x0b;
166+
b4 ^= x1d >> 2;
167+
b4 ^= x1e + 0x1b;
168+
169+
for (i = 0; i < 4; b1 += b2 ^ b3, b2 += b1 ^ b4, ++i);
170+
171+
smbus_set_addr(0x20); /* set PIC address; write command */
172+
smbus_write(0x20, b1);
173+
smbus_write(0x21, b2);
174+
}
146175

147176
extern int I2cSetFrontpanelLed(u8 b)
148177
{

boot_rom/2bload.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ static INLINE u8 smbus_read(u8 cmd)
168168
}
169169

170170
// boot process
171-
int BootPerformPicChallengeResponseAction(void);
171+
//int BootPerformPicChallengeResponseAction(void);
172+
void pic_challenge_response(void) __attribute__((section(".low_rom"),aligned(16)));
172173
// LED control (see associated enum above)
173174
int I2cSetFrontpanelLed(u8 b);
174175
int I2cResetFrontpanelLed(void);

0 commit comments

Comments
 (0)