From patchwork Thu May 27 20:24:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Improve i82830 MBI SMI Handler - take 2 Date: Thu, 27 May 2010 20:24:32 -0000 From: Joseph Smith X-Patchwork-Id: 1410 Message-Id: <4BFED500.4040808@settoplinux.org> To: Stefan Reinauer Cc: coreboot@coreboot.org 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 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; }