//return 1 if the list of bad memory devices changes, 0 otherwise, -1 if no mapped int add_dmi_err(ulong adr){ int i,j,found=-1; if(!dmi_initialized) init_dmi(); for(i=0; i < md_maps_count; i++){ if ( adr < (md_maps[i]->start<<10) || adr > (md_maps[i]->end<<10) ) continue; //matching map found, now check find corresponding dev for(j=0; j < mem_devs_count; j++){ if (mem_devs[j]->header.handle != md_maps[i]->md_handle) continue; if (dmi_err_cnts[j]){ found=0; }else{ found = dmi_err_cnts[j] = 1; } } } return found; }
void gm45_late_init(const stepping_t stepping) { const device_t mch = PCI_DEV(0, 0, 0); const int peg_enabled = (pci_read_config8(mch, D0F0_DEVEN) >> 1) & 1; const int sdvo_enabled = (MCHBAR16(0x40) >> 8) & 1; const int peg_x16 = (peg_enabled && !sdvo_enabled); init_egress(); init_dmi(stepping >= STEPPING_B2); init_pcie(peg_enabled, sdvo_enabled, peg_x16); setup_aspm(stepping, peg_enabled); setup_rcrb(peg_enabled); }
void x4x_late_init(void) { init_egress(); init_dmi(); }
void early_pch_init_native (void) { pci_write_config8 (SOUTHBRIDGE, 0xa6, pci_read_config8 (SOUTHBRIDGE, 0xa6) | 2); write32 (DEFAULT_RCBA + 0x2088, 0x00109000); read32 (DEFAULT_RCBA + 0x20ac); // !!! = 0x00000000 write32 (DEFAULT_RCBA + 0x20ac, 0x40000000); write32 (DEFAULT_RCBA + 0x100c, 0x01110000); write8 (DEFAULT_RCBA + 0x2340, 0x1b); read32 (DEFAULT_RCBA + 0x2314); // !!! = 0x0a080000 write32 (DEFAULT_RCBA + 0x2314, 0x0a280000); read32 (DEFAULT_RCBA + 0x2310); // !!! = 0xc809605b write32 (DEFAULT_RCBA + 0x2310, 0xa809605b); write32 (DEFAULT_RCBA + 0x2324, 0x00854c74); read8 (DEFAULT_RCBA + 0x0400); // !!! = 0x00 read32 (DEFAULT_RCBA + 0x2310); // !!! = 0xa809605b write32 (DEFAULT_RCBA + 0x2310, 0xa809605b); read32 (DEFAULT_RCBA + 0x2310); // !!! = 0xa809605b write32 (DEFAULT_RCBA + 0x2310, 0xa809605b); write_iobp(0xea007f62, 0x00590133); write_iobp(0xec007f62, 0x00590133); write_iobp(0xec007f64, 0x59555588); write_iobp(0xea0040b9, 0x0001051c); write_iobp(0xeb0040a1, 0x800084ff); write_iobp(0xec0040a1, 0x800084ff); write_iobp(0xea004001, 0x00008400); write_iobp(0xeb004002, 0x40201758); write_iobp(0xec004002, 0x40201758); write_iobp(0xea004002, 0x00601758); write_iobp(0xea0040a1, 0x810084ff); write_iobp(0xeb0040b1, 0x0001c598); write_iobp(0xec0040b1, 0x0001c598); write_iobp(0xeb0040b6, 0x0001c598); write_iobp(0xea0000a9, 0x80ff969f); write_iobp(0xea0001a9, 0x80ff969f); write_iobp(0xeb0040b2, 0x0001c396); write_iobp(0xeb0040b3, 0x0001c396); write_iobp(0xec0040b2, 0x0001c396); write_iobp(0xea0001a9, 0x80ff94ff); write_iobp(SATA_IOBP_SP0G3IR, 0x0088037f); write_iobp(0xea0000a9, 0x80ff94ff); write_iobp(SATA_IOBP_SP1G3IR, 0x0088037f); write_iobp(0xea007f05, 0x00010642); write_iobp(0xea0040b7, 0x0001c91c); write_iobp(0xea0040b8, 0x0001c91c); write_iobp(0xeb0040a1, 0x820084ff); write_iobp(0xec0040a1, 0x820084ff); write_iobp(0xea007f0a, 0xc2480000); write_iobp(0xec00404d, 0x1ff177f); write_iobp(0xec000084, 0x5a600000); write_iobp(0xec000184, 0x5a600000); write_iobp(0xec000284, 0x5a600000); write_iobp(0xec000384, 0x5a600000); write_iobp(0xec000094, 0x000f0501); write_iobp(0xec000194, 0x000f0501); write_iobp(0xec000294, 0x000f0501); write_iobp(0xec000394, 0x000f0501); write_iobp(0xec000096, 0x00000001); write_iobp(0xec000196, 0x00000001); write_iobp(0xec000296, 0x00000001); write_iobp(0xec000396, 0x00000001); write_iobp(0xec000001, 0x00008c08); write_iobp(0xec000101, 0x00008c08); write_iobp(0xec000201, 0x00008c08); write_iobp(0xec000301, 0x00008c08); write_iobp(0xec0040b5, 0x0001c518); write_iobp(0xec000087, 0x06077597); write_iobp(0xec000187, 0x06077597); write_iobp(0xec000287, 0x06077597); write_iobp(0xec000387, 0x06077597); write_iobp(0xea000050, 0x00bb0157); write_iobp(0xea000150, 0x00bb0157); write_iobp(0xec007f60, 0x77777d77); write_iobp(0xea00008d, 0x01320000); write_iobp(0xea00018d, 0x01320000); write_iobp(0xec0007b2, 0x04514b5e); write_iobp(0xec00078c, 0x40000200); write_iobp(0xec000780, 0x02000020); init_dmi(); }
TPM_RESULT VTPM_LoadManagerData(void) { TPM_RESULT status=TPM_SUCCESS; int fh, stat_ret, dmis=0; long fh_size = 0, step_size; BYTE *flat_table=NULL; buffer_t unsealed_data, enc_table_abuf; struct pack_buf_t storage_key_pack, boot_key_pack; UINT32 *dmi_id_key, enc_size; BYTE vtpm_manager_gen; VTPM_DMI_RESOURCE *dmi_res; UINT32 dmi_id; BYTE dmi_type; struct stat file_stat; TPM_HANDLE boot_key_handle; TPM_AUTHDATA boot_usage_auth; memset(&boot_usage_auth, 0, sizeof(TPM_AUTHDATA)); fh = open(STATE_FILE, O_RDONLY ); stat_ret = fstat(fh, &file_stat); if (stat_ret == 0) fh_size = file_stat.st_size; else { status = TPM_IOERROR; goto abort_egress; } flat_table = (BYTE *) malloc(fh_size); if ((long) read(fh, flat_table, fh_size) != fh_size ) { status = TPM_IOERROR; goto abort_egress; } // Read Boot Key step_size = BSG_UnpackList( flat_table, 2, BSG_TPM_SIZE32_DATA, &boot_key_pack, BSG_TYPE_UINT32, &enc_size); TPMTRYRETURN(buffer_init(&vtpm_globals->bootKeyWrap, 0, 0) ); TPMTRYRETURN(buffer_init_alias_convert(&enc_table_abuf, enc_size, flat_table + step_size) ); TPMTRYRETURN(buffer_append_raw(&vtpm_globals->bootKeyWrap, boot_key_pack.size, boot_key_pack.data) ); //Load Boot Key TPMTRYRETURN( VTSP_LoadKey( vtpm_globals->manager_tcs_handle, TPM_SRK_KEYHANDLE, &vtpm_globals->bootKeyWrap, &SRK_AUTH, &boot_key_handle, &vtpm_globals->keyAuth, &vtpm_globals->bootKey, FALSE) ); TPMTRYRETURN( envelope_decrypt(&enc_table_abuf, vtpm_globals->manager_tcs_handle, boot_key_handle, (const TPM_AUTHDATA*) &boot_usage_auth, &unsealed_data) ); step_size += enc_size; if (*unsealed_data.bytes != VTPM_MANAGER_GEN) { // Once there is more than one gen, this will include some compatability stuff vtpmlogerror(VTPM_LOG_VTPM, "Warning: Manager Data file is gen %d, which this manager is gen %d.\n", vtpm_manager_gen, VTPM_MANAGER_GEN); } // Global Values needing to be saved BSG_UnpackList( unsealed_data.bytes, 4, BSG_TYPE_BYTE, &vtpm_manager_gen, BSG_TPM_AUTHDATA, &vtpm_globals->owner_usage_auth, BSG_TPM_SECRET, &vtpm_globals->storage_key_usage_auth, BSG_TPM_SIZE32_DATA, &storage_key_pack); TPMTRYRETURN(buffer_init(&vtpm_globals->storageKeyWrap, 0, 0) ); TPMTRYRETURN(buffer_append_raw(&vtpm_globals->storageKeyWrap, storage_key_pack.size, storage_key_pack.data) ); // Per DMI values to be saved while ( step_size < fh_size ){ if (fh_size - step_size < (long) (sizeof(UINT32) + sizeof(BYTE) + 2*sizeof(TPM_DIGEST))) { vtpmlogerror(VTPM_LOG_VTPM, "Encountered %ld extra bytes at end of manager state.\n", fh_size-step_size); step_size = fh_size; } else { step_size += BSG_UnpackList(flat_table + step_size, 2, BSG_TYPE_UINT32, &dmi_id, BSG_TYPE_BYTE, &dmi_type); //TODO: Try and gracefully recover from problems. TPMTRYRETURN(init_dmi(dmi_id, dmi_type, &dmi_res) ); dmis++; step_size += BSG_UnpackList(flat_table + step_size, 2, BSG_TPM_DIGEST, &dmi_res->NVM_measurement, BSG_TPM_DIGEST, &dmi_res->DMI_measurement); } } vtpmloginfo(VTPM_LOG_VTPM, "Loaded saved state (dmis = %d).\n", dmis); goto egress; abort_egress: vtpmlogerror(VTPM_LOG_VTPM, "Failed to load service data with error = %s\n", tpm_get_error_name(status)); egress: free(flat_table); close(fh); // TODO: Could be nice and evict BootKey. (Need to add EvictKey to VTSP. return status; }
void print_dmi_info(void){ int i,j,page; char * string=0; if(!dmi_initialized) init_dmi(); if (mem_devs_count == 0){ cprint(POP2_Y+1, POP2_X+2, "No valid DMI Memory Devices info found"); while (get_key() == 0); return; } for(page=1; page <= 1 + (mem_devs_count-1)/8; page++){ pop2clear(); cprint(POP2_Y+1, POP2_X+2, "DMI Memory Device Info (page "); itoa(string,page); cprint(POP2_Y+1, POP2_X+32, string); cprint(POP2_Y+1, POP2_X+33, "/"); itoa(string,1 + (mem_devs_count-1)/8); cprint(POP2_Y+1, POP2_X+34, string); cprint(POP2_Y+1, POP2_X+35, ")"); cprint(POP2_Y+3, POP2_X+4, "Location Size(MB) Speed(MHz) Type Form"); cprint(POP2_Y+4, POP2_X+4, "--------------------------------------------------------------"); for(i=8*(page-1); i<mem_devs_count && i<8*page; i++){ int size_in_mb; int yof; yof=POP2_Y+5+2*(i-8*(page-1)); cprint(yof, POP2_X+4, get_tstruct_string(&(mem_devs[i]->header), mem_devs[i]->dev_locator)); if (mem_devs[i]->size == 0){ cprint(yof, POP2_X+4+18, "Empty"); }else if (mem_devs[i]->size == 0xFFFF){ cprint(yof, POP2_X+4+18, "Unknown"); }else{ size_in_mb = 0xEFFF & mem_devs[i]->size; if (mem_devs[i]->size & 0x8000) size_in_mb = size_in_mb<<10; itoa(string, size_in_mb); cprint(yof, POP2_X+4+18, string); } //this is the only field that needs to be SMBIOS 2.3+ if ( mem_devs[i]->speed && mem_devs[i]->header.length > 21){ itoa(string, mem_devs[i]->speed); cprint(yof, POP2_X+4+27, string); }else{ cprint(yof, POP2_X+4+27, "Unknown"); } cprint(yof, POP2_X+4+37, memory_types[mem_devs[i]->type]); cprint(yof, POP2_X+4+44, form_factors[mem_devs[i]->form]); //print mappings int mapped=0,of=0; cprint(yof+1, POP2_X+6,"mapped to: "); for(j=0; j<md_maps_count; j++){ if (mem_devs[i]->header.handle != md_maps[j]->md_handle) continue; if (mapped++){ cprint(yof+1, POP2_X+17+of, ","); of++; } hprint3(yof+1, POP2_X+17+of, md_maps[j]->start<<10, 12); of += 12; cprint(yof+1, POP2_X+17+of, "-"); of++; hprint3(yof+1, POP2_X+17+of, md_maps[j]->end<<10, 12); of += 12; } if (!mapped) cprint(yof+1, POP2_X+17, "No mapping (Interleaved Device)"); } wait_keyup(); while (get_key() == 0); } }