Patchwork Improve i82830 MBI SMI Handler - take 2

login
register
about
Submitter Stefan Reinauer
Date 2010-05-27 16:22:27
Message ID <4BFE9C43.20902@coresystems.de>
Download mbox | patch
Permalink /patch/1409/
State Superseded, archived
Headers show

Comments

Stefan Reinauer - 2010-05-27 16:22:27
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?

Stefan
MBI name field alignment

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Joseph Smith - 2010-05-27 16:56:14
On Thu, 27 May 2010 18:22:27 +0200, Stefan Reinauer <stepan@coresystems.de>
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?
> 
Sure no problem Stefan, I will be glad to test it as soon as I can :-)

I wasn't really sure what the ALIGN() did exactly, but if it basically does
what my take 2 patch does that would be sweet!

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 headerlen, objectlen;
 
 			if (!(mbi[i] == 0xf0 && mbi [i+1] == 0xf6)) {
 				i+=16;
@@ -253,17 +253,19 @@ 
 			}
 
 			mbi_header = (mbi_header_t *)&mbi[i];
-			len = ALIGN((mbi_header->size * 16) + sizeof(mbi_header) + mbi_header->name_len, 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;
 			}