acpitable解析過程分析_第1頁
acpitable解析過程分析_第2頁
acpitable解析過程分析_第3頁
acpitable解析過程分析_第4頁
acpitable解析過程分析_第5頁
已閱讀5頁,還剩16頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

acpitable解析過程分析acpi表結構?概是這樣的知道了表的?概結構我問來分析的解析的過程解析的??函數為acpi_tb_parse_root_table函數/*********************************************************************************FUNCTION:acpi_tb_parse_root_table**PARAMETERS:rsdp*-PointertotheRSDP*RETURN:*Status*DESCRIPTION:ThisfunctioniscalledtoparsetheRootSystemDescription*Table(RSDTorXSDT)**NOTE:Tablesaremapped(notcopied)forefficiency.TheFACSmustbemappedandcannotbecopiedbecauseitcontainstheactualmemorylocationoftheACPIGlobalLock.*********************************************************************************/acpi_status__initacpi_tb_parse_root_table(acpi_physical_addressrsdp_address){structacpi_table_rsdp*rsdp;u32table_entry_size;u32i;u32table_count;structacpi_table_header*table;acpi_physical_addressaddress;u32length;u8*table_entry;acpi_statusstatus;u32table_index;ACPI_FUNCTION_TRACE(tb_parse_root_table);/*MaptheentireRSDPandextracttheaddressoftheRSDTorXSDT*/rsdp=acpi_os_map_memory(rsdp_address,sizeof(structacpi_table_rsdp));if(!rsdp){return_ACPI_STATUS(AE_NO_MEMORY);}acpi_tb_print_table_header(rsdp_address,ACPI_CAST_PTR(structacpi_table_header,rsdp));/*UseXSDTifpresentandnotoverridden.Otherwise,useRSDT*/if((rsdp->revision>1)&&if((rsdp->revision>1)&&rsdp->xsdt_physical_address&&!acpi_gbl_do_not_use_xsdt){/**RSDPcontainsanXSDT(64-bitphysicaladdresses).Wemustuse*theXSDTiftherevisionis>1andtheXSDTpointerispresent,*aspertheACPIspecification.*/address=(acpi_physical_address)rsdp->xsdt_physical_address;table_entry_size=ACPI_XSDT_ENTRY_SIZE;}else{/*RoottableisanRSDT(32-bitphysicaladdresses)*/address=(acpi_physical_address)rsdp->rsdt_physical_address;table_entry_size=ACPI_RSDT_ENTRY_SIZE;}/**Itisnotpossibletomapmorethanoneentryinsomeenvironments,*sounmaptheRSDPherebeforemappingothertables*/acpi_os_unmap_memory(rsdp,sizeof(structacpi_table_rsdp));/*MaptheRSDT/XSDTtableheadertogetthefulltablelength*/table=acpi_os_map_memory(address,sizeof(structacpi_table_header));if(!table){return_ACPI_STATUS(AE_NO_MEMORY);}acpi_tb_print_table_header(address,table);/**Validatelengthofthetable,andmapentiretable.*Minimumlengthtablemustcontainatleastoneentry.*/length=table->length;acpi_os_unmap_memory(table,sizeof(structacpi_table_header));if(length<(sizeof(structacpi_table_header)+table_entry_size)){ACPI_BIOS_ERROR((AE_INFO,"Invalidtablelength0x%XinRSDT/XSDT",length));return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);}table=acpi_os_map_memory(address,length);if(!table){return_ACPI_STATUS(AE_NO_MEMORY);}/*Validatetheroottablechecksum*/status=acpi_tb_verify_checksum(table,length);if(ACPI_FAILURE(status)){acpi_os_unmap_memory(table,length);return_ACPI_STATUS(status);}/*Getthenumberofentriesandpointertofirstentry*/table_count=(u32)((table->length-sizeof(structacpi_table_header))/table_entry_size);table_entry=ACPI_ADD_PTR(u8,table,sizeof(structacpi_table_header));/**FirstthreeentriesinthetablearrayarereservedfortheDSDT*FirstthreeentriesinthetablearrayarereservedfortheDSDT*and32bit/64bitFACS,whicharenotactuallypresentinthe*RSDT/XSDT-theycomefromtheFADT*/acpi_gbl_root_table_list.current_table_count=3;/*InitializetheroottablearrayfromtheRSDT/XSDT*/for(i=0;i<table_count;i++){/*Getthetablephysicaladdress(32-bitforRSDT,64-bitforXSDT)*/address=acpi_tb_get_root_table_entry(table_entry,table_entry_size);/*SkipNULLentriesinRSDT/XSDT*/if(!address){gotonext_table;}status=acpi_tb_install_standard_table(address,ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,FALSE,TRUE,&table_index);if(ACPI_SUCCESS(status)&&ACPI_COMPARE_NAME(&acpi_gbl_root_table_list.tables[table_index].signature,ACPI_SIG_FADT)){acpi_tb_parse_fadt(table_index);}next_table:table_entry+=table_entry_size;}acpi_os_unmap_memory(table,length);return_ACPI_STATUS(AE_OK);}?先注釋上說acpi表為了?效使?map映射,?FACS必須使?映射因為這段內存中存在全局鎖1rsdp=acpi_os_map_memory(rsdp_address,sizeof(structacpi_table_rsdp));映射到虛擬地址RSDP2acpi_tb_print_table_header打印表頭表頭結構如下,注意表頭是直接從rsdp轉換得到的/*********************************************************************************MasterACPITableHeader.ThiscommonheaderisusedbyallACPItables*excepttheRSDPandFACS.*******************************************************************************/structacpi_table_header{charsignature[ACPI_NAME_SIZE];/*ASCIItablesignature*/u32length;/*Lengthoftableinbytes,includingthisheader*/u8revision;/*ACPISpecificationminorversionnumber*//*Tomakesumofentiretable==0*/u8checksum;charoem_id[ACPI_OEM_ID_SIZE];/*ASCIIOEMidentification*/charoem_table_id[ACPI_OEM_TABLE_ID_SIZE];/*ASCIIOEMtableidentification*/u32oem_revision;/*OEMrevisionnumber*/charasl_compiler_id[ACPI_NAME_SIZE];/*ASCIIASLcompilervendorID*/u32asl_compiler_revision;/*ASLcompilerversion*/};第?項signature是表的簽名length為表的長度revision版本checksum校驗值oem_id?商idoem_table_idtable的idoem_revision?商版本asl_compiler_id編譯器idasl_compiler_revision編譯器版本編譯是為解釋acpi操作語?ASL的編譯器3根據版本選擇使?xsdt還是rsdt,revision>1并且存在xsdt的情況必須使?XSDTXSDT表全稱ExtendedRootSystemDescriptionTable,它的作?于RSDT?樣,區別在于兩者包含的指針地址?個是32位的,?個是64位的。XSDT表結構如下typedefstruct{EFI_ACPI_DESCRIPTION_HEADERHeader;UINT64Entry;RSDT結構如下typedefstruct{EFI_ACPI_DESCRIPTION_HEADERHeader;UINT32}Entry;4找到要具體使?的RSDT/XSDT就可以進?解析了,?先解除RSDP的映射,然后映射RSDT/XSDT表頭,通過表頭驗證表長度是否正確,如果正確再映射整張表5驗證表校驗和6處表頭后為entry,獲取entry個數,able_count=(u32)((table->length-sizeof(structacpi_table_header))/table_entry_size)7acpi_gbl_root_table_list.current_table_count=3該值設置為3的理由是保留前三項?于存放DSDT和FACS,這兩個表不是從RSDT和XSDT中獲取的,?是從FADT中得到的8按照計算好的表項個數去遍歷RSDT/XSDTacpi_tb_get_root_table_entry函數?于獲取?個entryacpi_tb_install_standard_table?于安裝標準table如果table是FADT則使?acpi_tb_parse_fadt函數去解析DSDT和FACS下?具體分析下acpi_tb_get_root_table_entry函數,acpi_tb_install_standard_table和acpi_tb_parse_fadtacpi_tb_get_root_table_entry?于從RSDT/XSDT中解析?table注意RSDT/XSDT的entry變量描述的就是?table的物理地址/*********************************************************************************FUNCTION:acpi_tb_get_root_table_entry**PARAMETERS:table_entry-PointertotheRSDT/XSDTtableentry**table_entry_size-sizeof32or64(RSDTorXSDT)*RETURN:*Physicaladdressextractedfromtheroottable*DESCRIPTION:Getoneroottableentry.Handles32-bitand64-bitcaseson*both32-bitand64-bitplatforms**NOTE:acpi_physical_addressis32-biton32-bitplatforms,64-biton64-bitplatforms.********************************************************************************/staticacpi_physical_addressacpi_tb_get_root_table_entry(u8*table_entry,u32table_entry_size){u64address64;/**Getthetablephysicaladdress(32-bitforRSDT,64-bitforXSDT):*Note:Addressesare32-bitaligned(not64)inbothRSDTandXSDT*/if(table_entry_size==ACPI_RSDT_ENTRY_SIZE){/**32-bitplatform,RSDT:Return32-bittableentry*64-bitplatform,RSDT:Expand32-bitto64-bitandreturn*/return((acpi_physical_address)(*ACPI_CAST_PTR(u32,table_entry)));}else{/**32-bitplatform,XSDT:Truncate64-bitto32-bitandreturn*64-bitplatform,XSDT:Move(unaligned)64-bittolocal,*return64-bit*/ACPI_MOVE_64_TO_64(&address64,table_entry);#ifACPI_MACHINE_WIDTH==32if(address64>ACPI_UINT32_MAX){/*Willtruncate64-bitaddressto32bits,issuewarning*/ACPI_BIOS_WARNING((AE_INFO,"64-bitPhysicalAddressinXSDTistoolarge(0x%8.8X%8.8X),""truncating",ACPI_FORMAT_UINT64(address64)));}#endifreturn((acpi_physical_address)(address64));}}其實很簡單,就是按照RSDT(32位entry)或者XDDT(64位entry)轉換?下。acpi_tb_install_standard_table函數?于安裝前?解析到的tableentry指向的table/*******************************************************************************/*********************************************************************************FUNCTION:acpi_tb_install_standard_table**PARAMETERS:address-Addressofthetable(mightbeavirtual******addressdependingonthetable_flags)flags-Flagsforthetablereload-Whetherreloadshouldbeperformed-Whetheroverrideshouldbeperformed-Wherethetableindexisreturnedoverridetable_index*RETURN:*Status*DESCRIPTION:ThisfunctioniscalledtoinstallanACPItablethatis******neitherDSDTnorFACS(a"standard"table.)Whenthisfunctioniscalledby"Load"or"LoadTable"opcodes,orbyacpi_load_table()API,the"Reload"parameterisset.Aftersucessfullyreturningfromthisfunction,tableis"INSTALLED"butnot"VALIDATED".******************************************************************************/acpi_statusacpi_tb_install_standard_table(acpi_physical_addressaddress,u8flags,u8reload,u8override,u32*table_index){u32i;acpi_statusstatus=AE_OK;structacpi_table_descnew_table_desc;ACPI_FUNCTION_TRACE(tb_install_standard_table);/*Acquireatemporarytabledescriptorforvalidation*/status=acpi_tb_acquire_temp_table(&new_table_desc,address,flags);if(ACPI_FAILURE(status)){ACPI_ERROR((AE_INFO,"Couldnotacquiretablelengthat%8.8X%8.8X",ACPI_FORMAT_UINT64(address)));return_ACPI_STATUS(status);}/**OptionallydonotloadanySSDTsfromtheRSDT/XSDT.Thiscan*beusefulfordebuggingACPIproblemsonsomemachines.*/if(!reload&&acpi_gbl_disable_ssdt_table_install&&ACPI_COMPARE_NAME(&new_table_desc.signature,ACPI_SIG_SSDT)){"Ignoringinstallationof%4.4sat%8.8X%8.8X",new_table_desc.signature.ascii,ACPI_INFO((AE_INFO,ACPI_FORMAT_UINT64(address)));gotorelease_and_exit;}/*Validateandverifyatablebeforeinstallation*/status=acpi_tb_verify_temp_table(&new_table_desc,NULL);if(ACPI_FAILURE(status)){gotorelease_and_exit;}*Validatetheincomingtablesignature.**1)Originally,wecheckedthetablesignaturefor"SSDT"or"PSDT".tables,signature"OEM".*2)WeaddedsupportforOEMx*3)Validtableswereencounteredwithanullsignature,sowejust*gaveuponvalidatingthesignature,(05/2008).*4)Weencounterednon-AMLtablessuchastheMADT,whichcausedfaults.Sonow,weonceagainallow*interpretererrorsandkernel*only"SSDT","OEMx",andnow,alsoanullsignature.(05/2011).*/if((new_table_desc.signature.ascii[0]!=0x00)&&(!ACPI_COMPARE_NAME(&new_table_desc.signature,ACPI_SIG_SSDT))&&(ACPI_STRNCMP(new_table_desc.signature.ascii,"OEM",3)))ACPI_BIOS_ERROR((AE_INFO,"Tablehasinvalidsignature[%4.4s](0x%8.8X),""mustbeSSDTorOEMx",{acpi_ut_valid_acpi_name(new_table_desc.signature.ascii)?new_table_desc.signature.ascii:"",new_table_eger));status=AE_BAD_SIGNATURE;gotorelease_and_exit;}/*Checkiftableisalreadyregistered*/for(i=0;i<acpi_gbl_root_table_list.current_table_count;++i){/**Checkforatablematchontheentiretablelength,*notjusttheheader.*/if(!acpi_tb_compare_tables(&new_table_desc,i)){continue;}/**Note:thecurrentmechanismdoesnotunregisteratableifitis*dynamicallyunloaded.Therelatednamespaceentriesaredeleted,tablelist.*butthetableremainsintheroot**Theassumptionhereisthatthenumberofdifferenttablesthat*willbeloadedisactuallysmall,andthereisminimaloverhead*injustkeepingthetableincaseitisneededagain.**Ifthisassumptionchangesinthefuture(perhapsonlarge*machineswithmanytableload/unloadoperations),tableswill*needtobeunregisteredwhentheyareunloaded,andslotsintheempty.*roottablelistshouldbereusedwhen*/if(acpi_gbl_root_table_list.tables[i].flags&ACPI_TABLE_IS_LOADED){/*Tableisstillloaded,thisisanerror*/status=AE_ALREADY_EXISTS;gotorelease_and_exit;}else{*AswearegoingtoreturnAE_OKtothecaller,weshould*taketheresponsibilityoffreeingtheinputdescriptor.*Refilltheinputdescriptortoensure*acpi_tb_install_table_with_override()canbecalledagainto*indicatethere-installation.*/acpi_tb_uninstall_table(&new_table_desc);*table_index=i;return_ACPI_STATUS(AE_OK);}}}/*Addthetabletotheglobalroottablelist*/status=acpi_tb_get_next_root_index(&i);if(ACPI_FAILURE(status)){gotorelease_and_exit;}*table_index=i;acpi_tb_install_table_with_override(i,&new_table_desc,override);release_and_exit:/*Releasethetemporarytabledescriptor*/acpi_tb_release_temp_table(&new_table_desc);return_ACPI_STATUS(status);}這是?個?較兇惡的函數,代碼很長1acpi_tb_acquire_temp_table?于創建?個acpi_table_desc結構,acpi_table_desc定義如下structacpi_table_desc{acpi_physical_addressaddress;structacpi_table_header*pointer;u32length;/*Lengthfixedat32bits(fixedintableheader)*/unionacpi_name_unionsignature;acpi_owner_idowner_id;u8flags;};主要描述了table的物理地址,table頭地址和table長度,簽名以及標志2acpi_tb_verify_temp_table驗證table是否可?,主要驗證包括簽名,checksum,長度等信息3reload表?重新加載,要先卸載原來的再加載當前的4acpi_tb_install_table_with_override安裝/*********************************************************************************FUNCTION:acpi_tb_install_table_with_override**PARAMETERS:table_index-Indexintoroottablearray-Newtabledescriptortoinstall***new_table_descoverride-Whetheroverrideshouldbeperformed*RETURN:*None*DESCRIPTION:InstallanACPItableintotheglobaldatastructure.The****tableoverridemechanismiscalledtoallowthehostOStoreplaceanytablebeforeitisinstalledintheroottablearray.******************************************************************************/voidacpi_tb_install_table_with_override(u32table_index,structacpi_table_desc*new_table_desc,u8override){if(table_index>=acpi_gbl_root_table_list.current_table_count){return;}/**ACPITableOverride:**Beforeweinstallthetable,letthehostOSoverrideitwithanew*oneifdesired.AnytablewithintheRSDT/XSDTcanbereplaced,*includingtheDSDTwhichispointedtobytheFADT.*/if(override){acpi_tb_override_table(new_table_desc);}acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[table_index],new_table_desc->address,new_table_desc->flags,new_table_desc->pointer);acpi_tb_print_table_header(new_table_desc->address,new_table_desc->pointer);/*Settheglobalintegerwidth(baseduponrevisionoftheDSDT)*/if(table_index==ACPI_TABLE_INDEX_DSDT){acpi_ut_set_integer_width(new_table_desc->pointer->revision);}}1如果覆蓋參數為真,則?新表覆蓋?表acpi_tb_override_table2acpi_tb_init_table_descriptor初始化表,注意這?的參數是&acpi_gbl_root_table_list.tables[table_index],也就是把table_descriptor安裝到acpi_gbl_root_table_list.tables數組就算安裝完成了acpi_tb_parse_fadt函數去解析DSDT和FACS/*********************************************************************************PARAMETERS:table_index*-IndexfortheFADT*RETURN:*None*DESCRIPTION:InitializetheFADT,DSDTandFACStables**(FADTcontainstheaddressesoftheDSDTandFACS)*********************************************************************

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論