Best Python code snippet using autotest_python
save_state_area.py
Source:save_state_area.py
...121 ql.mem.write(address, bytes(data))122def create_smm_save_state(ql):123 save_state_base = ql.os.smm.smbase + 0x8000124 offset = 0x7C00125 def _write_field(value, size):126 nonlocal offset127 ql.mem.write(save_state_base + offset, value.to_bytes(size, 'little'))128 offset += size129 #130 # See Intel Software Developers Manual, Volume 3C:131 # https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3c-part-3-manual.pdf132 #133 _write_field(0, 464) # Reserved134 _write_field(0, 4) # GDT Base (Upper 32 bits)135 _write_field(0, 4) # LDT Base (Upper 32 bits)136 _write_field(0, 4) # IDT Base (Upper 32 bits)137 _write_field(0, 12) # Reserved138 _write_field(0, 8) # IO_RIP139 _write_field(0, 80) # Reserved140 _write_field(ql.reg.cr4, 4)141 _write_field(0, 72) # Reserved142 _write_field(0, 4) # GDT Base (lower 32 bits)143 _write_field(0, 4) # Reserved144 _write_field(0, 4) # IDT Base (lower 32 bits)145 _write_field(0, 4) # Reserved146 _write_field(0, 4) # LDT Base (lower 32 bits)147 _write_field(0, 56) # Reserved148 _write_field(0, 8) # Value of EPTP VM-execution control field149 _write_field(0, 4) # Setting of âenable EPTâ VM-execution control150 _write_field(0, 20) # Reserved151 _write_field(0, 4) # SMBASE Field (Doubleword)152 _write_field(0, 4) # SMM Revision Identifier Field (Doubleword)153 _write_field(0, 2) # I/O Instruction Restart Field (Word)154 _write_field(0, 2) # Auto HALT Restart Field (Word) 155 _write_field(0, 24) # Reserved156 _write_field(ql.reg.r15, 8)157 _write_field(ql.reg.r14, 8)158 _write_field(ql.reg.r13, 8)159 _write_field(ql.reg.r12, 8)160 _write_field(ql.reg.r11, 8)161 _write_field(ql.reg.r10, 8)162 _write_field(ql.reg.r9, 8)163 _write_field(ql.reg.r8, 8)164 _write_field(ql.reg.rax, 8)165 _write_field(ql.reg.rcx, 8)166 _write_field(ql.reg.rdx, 8)167 _write_field(ql.reg.rbx, 8)168 _write_field(ql.reg.rsp, 8)169 _write_field(ql.reg.rbp, 8)170 _write_field(ql.reg.rsi, 8)171 _write_field(ql.reg.rdi, 8)172 _write_field(0, 8) # IO_MEM_ADDR173 _write_field(0, 4) # IO_MISC174 _write_field(ql.reg.es, 4)175 _write_field(ql.reg.cs, 4)176 _write_field(ql.reg.ss, 4)177 _write_field(ql.reg.ds, 4)178 _write_field(ql.reg.fs, 4)179 _write_field(ql.reg.gs, 4)180 _write_field(0, 4) # LDTR SEL181 _write_field(0, 4) # TR SEL182 _write_field(0, 8) # DR7183 _write_field(0, 8) # DR6184 _write_field(ql.reg.rip, 8)185 _write_field(0, 8) # IA32_EFER186 _write_field(ql.reg.ef, 8)187 _write_field(ql.reg.cr3, 8)188 _write_field(ql.reg.cr0, 8)...
dist.py
Source:dist.py
...50 version = '1.0'51 if (self.provides or self.requires or self.obsoletes or52 self.classifiers or self.download_url):53 version = '1.1'54 self._write_field(file, 'Metadata-Version', version)55 self._write_field(file, 'Name', self.get_name())56 self._write_field(file, 'Version', self.get_version())57 self._write_field(file, 'Summary', self.get_description())58 self._write_field(file, 'Home-page', self.get_url())59 self._write_field(file, 'Author', self.get_contact())60 self._write_field(file, 'Author-email', self.get_contact_email())61 self._write_field(file, 'License', self.get_license())62 if self.download_url:63 self._write_field(file, 'Download-URL', self.download_url)64 long_desc = rfc822_escape( self.get_long_description())65 self._write_field(file, 'Description', long_desc)66 keywords = ",".join(self.get_keywords())67 if keywords:68 self._write_field(file, 'Keywords', keywords)69 self._write_list(file, 'Platform', self.get_platforms())70 self._write_list(file, 'Classifier', self.get_classifiers())71 # PEP 31472 self._write_list(file, 'Requires', self.get_requires())73 self._write_list(file, 'Provides', self.get_provides())74 self._write_list(file, 'Obsoletes', self.get_obsoletes())75 def _write_field(self, file, name, value):76 file.write('%s: %s\n' % (name, self._encode_field(value)))77 def _write_list (self, file, name, values):78 for value in values:79 self._write_field(file, name, value)80 def _encode_field(self, value):81 if value is None:82 return None83 if isinstance(value, str):84 return value.encode(PKG_INFO_ENCODING)85 return str(value)86 # -- Metadata query methods ----------------------------------------87 def get_name (self):88 return self.name or "UNKNOWN"89 def get_version(self):90 return self.version or "0.0.0"91 def get_fullname (self):92 return "%s-%s" % (self.get_name(), self.get_version())93 def get_author(self):...
intr.py
Source:intr.py
...14 self.me = me15 self.hv = hv16 self.s = s17 def write_msr(self, msr):18 def _write_field(field, value):19 stmts = []20 if value is not None:21 stmts.append(getattr(msr.w_mask, field).eq(-1))22 stmts.append(getattr(msr.w_data, field).eq(value))23 return stmts24 # See PowerISA v3.1, Book III, Section 7.5, Figure 6725 stmts = [26 _write_field("ir" , self.ir),27 _write_field("dr" , self.dr),28 _write_field("fe0", 0),29 _write_field("fe1", 0),30 _write_field("ee" , self.ee),31 _write_field("ri" , self.ri),32 _write_field("me" , self.me),33 _write_field("hv" , self.hv),34 _write_field("s" , self.s),35 _write_field("pr" , 0),36 _write_field("pmm", 0),37 _write_field("te" , 0),38 _write_field("fp" , 0),39 _write_field("vec", 0),40 _write_field("vsx", 0),41 _write_field("sf" , 1),42 msr.w_mask[63- 5].eq(1),43 msr.w_data[63- 5].eq(0),44 msr.w_mask[63-31].eq(1),45 msr.w_data[63-31].eq(0),46 ]47 return stmts48# TODO:49# - Support MSR.{IR,DR,HV,S,LE} bits, which depend on context (e.g. LPCR)50# - Support LPCR.{AIL,HAIL} fields. For now, assume AIL=0 and HAIL=051# (i.e. interrupts always set IR/DR to 0).52INTR_ALIGNMENT = Interrupt(0x600, ir=0, dr=0, ee=0, ri=0, me=None, hv=None, s=None)53INTR_PROGRAM = Interrupt(0x700, ir=0, dr=0, ee=0, ri=0, me=None, hv=None, s=None)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!