[coreboot] Getting more useful patterns out of replay logs

mrnuke mr.nuke.me at gmail.com
Fri Dec 19 04:06:40 CET 2014


I want to convert a replay log to something that looks more structured, and 
easier to parse through mentally. I've tried to use coccinelle, but I came 
across a couple of problems. First, the file is over 13000 (thirteen thousand) 
lines long, and coccinelle crashes with a "stack overflow" error even on the 
simplest patterns. Second, I couldn't figure out how to use coccinelle to 
extract the bits I want from those 32-bit constants.

This is an example pattern. I've described the relevant information I want to 
extract in '//' style comments:

 read(0x6530); /* 0f410000 */
 write(0x6530, 0x0f410000);
 read(0x6530); /* 0f410000 */
 write(0x6530, 0x0f410000);
 read(0x6200); /* 21000101 */
 write(0x6200, 0x21000101);		// <- [30:28] hpd_id (2)
 read(0x6200); /* 21000101 */
 write(0x6200, 0x21000101);
 read(0x9fffbe00); /* 50400050 */
 read(0x6204); /* 00030000 */
 write(0x6204, 0x00050000);		// <- [20:16] tx_bytes (5)
 read(0x6204); /* 00050000 */
 write(0x6204, 0x00050000);
 read(0x9fffbe00); /* 50400050 */
 write(0x6218, 0x80004000);		// <- [15:8] cmd_byte
 read(0x9fffbe00); /* 50400050 */
 write(0x6218, 0x00000000);		// <- [15:8] address[15:8]
 read(0x9fffbe00); /* 50400050 */
 write(0x6218, 0x00005000);		// <- [15:8] address[7:0] (0x50)
 read(0x9fffbe00); /* 50400050 */
 write(0x6218, 0x00000000);		// <- [15:8] expected_rx_bytes - 1
 read(0x9fffbe04); /* 00000050 */
 write(0x6218, 0x00003000);		// <- [15:8] i2c_reg (0x30)
 read(0x9fffbe04); /* 00000050 */
 write(0x6218, 0x00000000);
 read(0x9fffbe04); /* 00000050 */
 write(0x6218, 0x00000000);
 read(0x9fffbe04); /* 00000050 */
 write(0x6218, 0x00000000);
 read(0x620c); /* 00000000 */
 write(0x620c, 0x00000002);
 read(0x6204); /* 00050000 */
 write(0x6204, 0x00050001);
 read(0x6210); /* c1000000 */
 delay(0x0088c9bd - 0x0088c79b);
 read(0x6210); /* c1000000 */
 delay(0x0088f0b7 - 0x0088ee9b);
 read(0x6210); /* 01000001 */
 read(0x6210); /* 01000001 */		
 write(0x6218, 0x80000001);
 read(0x6218); /* 00000001 */		// <- [15:8] reply	(0)		
 read(0x6210); /* 01000001 */		// <- [28:24] actual_rx_bytes (1)
 read(0x9fffa414); /* 22232121 */
 read(0x9fffa418); /* 00000000 */
 read(0x9fffa52c); /* 80010000 */
 read(0x9fffa530); /* 00000108 */
 write(0x9fffbe04, 0x08800100);
 write(0x9fffbe00, 0x4f500050);

Now assuming I have a struct called jelly_donut instantiated as 'donut', I'd 
like the output to look like:

 donut->hpd_id = 2;
 donut->tx_bytes = 5;
 donut->cmd_byte = 0x40;
 donut->address = 0x0050;
 donut->i2c_reg = 0x30;
 process_food(donut);
 /* .reply = 0; actual_rx_bytes = 1 */

or, I'll even settle for something like:

 regurgitate(2, 5, 0x40, 0x0050, 0x30); /* .reply = 0; actual_rx_bytes = 1 */

Any ideas how I'd get this done?

Alex



More information about the coreboot mailing list