Patchwork Improve i82830 MBI SMI Handler - take 2

login
register
about
Submitter Joseph Smith
Date 2010-05-27 20:24:32
Message ID <4BFED500.4040808@settoplinux.org>
Download mbox | patch
Permalink /patch/1410/
State Accepted, archived
Headers show

Comments

Joseph Smith - 2010-05-27 20:24:32
On 05/27/2010 12:22 PM, Stefan Reinauer wrote:
> On 5/27/10 7:20 AM, Joseph Smith wrote:
>> Hello,
>> Let's try this again. This way is as dynamic as possibly possible.
>>
>> This patch improves the i82830 MBI SMI Handler. It is now able to load
>> Intel vbios VBT and Flexaim modules. Build and boot tested.
> Ok, I tried to understand what's wrong from reading your patch and it
> seems the name fields need to be properly aligned.
> I created this patch. Can you try and see if it helps, please?
>
YAHOO, you are the man Stefan:-) Works Great! Thank you.
One minor adjustment, had to add the len for MBI_GetObject because it is 
part of the for() loop. (new patch attached)

Acked-by: Joseph Smith <joe@settoplinux.org>

Patch

Index: src/northbridge/intel/i82830/i82830_smihandler.c
===================================================================
--- src/northbridge/intel/i82830/i82830_smihandler.c	(revision 5594)
+++ src/northbridge/intel/i82830/i82830_smihandler.c	(working copy)
@@ -196,7 +196,7 @@ 
 			}
 
 			mbi_header = (mbi_header_t *)&mbi[i];
-			len = ALIGN((mbi_header->size * 16) + sizeof(mbi_header) + mbi_header->name_len, 16);
+			len = ALIGN((mbi_header->size * 16) + sizeof(mbi_header) + ALIGN(mbi_header->name_len, 16), 16); 
 
 			if (obj_header->objnum == count) {
 #ifdef DEBUG_SMI_I82830
@@ -205,7 +205,7 @@ 
 					break;
 				}
 #endif
-				int headerlen = ALIGN(sizeof(mbi_header) + mbi_header->name_len + 15, 16);
+				int headerlen = ALIGN(sizeof(mbi_header) + ALIGN(mbi_header->name_len, 16), 16);
 #ifdef DEBUG_SMI_I82830
 				printk(BIOS_DEBUG, "|  |- headerlen = %d\n", headerlen);
 #endif
@@ -245,7 +245,7 @@ 
 		getobj->banner.retsts = MSH_IF_NOT_FOUND;
 
 		for (i=0; i< mbi_len;) {
-			int len;
+			int len, headerlen, objectlen;
 
 			if (!(mbi[i] == 0xf0 && mbi [i+1] == 0xf6)) {
 				i+=16;
@@ -253,17 +253,20 @@ 
 			}
 
 			mbi_header = (mbi_header_t *)&mbi[i];
-			len = ALIGN((mbi_header->size * 16) + sizeof(mbi_header) + mbi_header->name_len, 16);
+			len = ALIGN((mbi_header->size * 16) + sizeof(mbi_header) + ALIGN(mbi_header->name_len, 16), 16); 
+			headerlen = ALIGN(sizeof(mbi_header) + ALIGN(mbi_header->name_len, 16), 16);
+			objectlen = ALIGN((mbi_header->size * 16), 16);
 
 			if (getobj->objnum == count) {
-				printk(BIOS_DEBUG, "|  |- len = %x\n", len);
+				printk(BIOS_DEBUG, "|  |- len = %x\n", headerlen + objectlen);
+
 				memcpy((void *)(getobj->buffer + OBJ_OFFSET),
-						((char *)mbi_header) + 0x20 , (len > getobj->buflen) ? getobj->buflen : len);
+						((char *)mbi_header) + headerlen, (objectlen > getobj->buflen) ? getobj->buflen : objectlen);
 
 				getobj->banner.retsts = MSH_OK;
 #ifdef DEBUG_SMI_I82830
 				dump((u8 *)banner_id, sizeof(*getobj));
-				dump((u8 *)getobj->buffer + OBJ_OFFSET, len);
+				dump((u8 *)getobj->buffer + OBJ_OFFSET, objectlen);
 #endif
 				break;
 			}