📄 grub-0.97-fc5-tcg-0.2.0-beta1.patch
字号:
+ /* TCG_PassThroughToTPM Input Parameter Block */+tcg_passthru_ipb:+tcg_passthru_ipb_length:+ .word 0 /* IPBLength */+ .word 0 /* Reserved */+tcg_passthru_ipb_opb_length: /* OPBLength */+ .word tcg_passthru_opb_end - tcg_passthru_opb+ .word 0 /* Reserved */+tpm_operand_in_buff:+ .space 34 /* TPMOperandIn */+tpm_operand_in_buff_end:+++ /* TCG_PassThroughToTPM Output Parameter Block */+tcg_passthru_opb:+tcg_passthru_opb_length: /* OPBLength */+ .word tcg_passthru_opb_end - tcg_passthru_opb+ .word 0 /* Reserved */+tpm_operand_out_buff:+ .space 2 /* tag */+ .space 4 /* paramSize */+tpm_operand_out_return_code:+ .space 4 /* returnCode */+ .space 20 /* Buffer for output values */+tpm_operand_out_buff_end:+tcg_passthru_opb_end:++ + /* TPM_Extend Input (Note: TPM Operands are Network-Byte-Order */+tpm_extend_in:+ .byte 0,0xC1 /* tag = TPM_TAG_RQU_COMMAND */+ .byte 0,0,0,tpm_extend_in_end - tpm_extend_in+ /* paramSize */+ .byte 0,0,0,20 /* ordinal = TPM_ORD_Extend */+ .byte 0,0,0 /* pcrNum (Bit 31-8) */+tpm_extend_pcr_num:+ .byte 0 /* pcrNum (Bit 7-0) */+tpm_extend_digest:+ .space TCG_DIGEST_SIZE+tpm_extend_in_end:++ /* TPM_Extend Output parameter offsets */+tpm_extend_pcr_value = 10 +++ /* TPM_PcrRead Input (Note: TPM Operands are Network-Byte-Order */+tpm_pcrread_in:+ .byte 0,0xC1 /* tag = TPM_TAG_RQU_COMMAND */+ .byte 0,0,0,tpm_pcrread_in_end - tpm_pcrread_in+ /* paramSize */+ .byte 0,0,0,21 /* ordinal = TPM_ORD_PcrRead */+ .byte 0,0,0 /* pcrNum (Bit 31-8) */+tpm_pcrread_pcrindex:+ .byte 0 /* pcrNum (Bit 7-0) */+tpm_pcrread_in_end:++ /* TPM_PcrRead Output parameter offsets */+tpm_pcrread_pcr_value = 10+++ + /* TCG_HashLogExtendEvent Input Parameter Block (Format 1)*/+tcg_hlee_ipb:+ .word tcg_hlee_ipb_end - tcg_hlee_ipb /* IPBLength, 18h */+ .word 0 /* Reserved */+tcg_hlee_ipb_hashdata:+ .long 0 /* HashDataPtr */+tcg_hlee_ipb_hashdatalen:+ .long 0 /* HashDataLen */+tcg_hlee_ipb_pcr_index:+ .long 0 /* PCRIndex */+tcg_hlee_ipb_logdata:+ .long 0 /* LogDataPtr */+tcg_hlee_ipb_logdatalen: + .long 0 /* LogDataLen */+tcg_hlee_ipb_end:+ /* TBD */+ + /* TCG_HashLogExtendEvent Input Parameter Block (Format 2) */+ /* TCG_LogEvent Input Parameter Block */+tcg_le_ipb:+ .word tcg_le_ipb_end - tcg_le_ipb /* IPBLength, 18h */+ .word 0 /* Reserved */+tcg_le_ipb_hashdata:+ .long 0 /* HashDataPtr */+tcg_le_ipb_hashdatalen:+ .long 0 /* HashDataLen */+tcg_le_ipb_pcr_index:+ .long 0 /* PCRIndex */+tcg_le_ipb_eventtype:+ .long 0 /* reserved/type */+tcg_le_ipb_logdata:+ .long 0 /* LogDataPtr */+tcg_le_ipb_logdatalen:+ .long 0 /* LogDataLen */+tcg_le_ipb_end:++ + /* TCG_HashLogExtendEvent Output Parameter Block */+ /* TCG_LogEvent Output Parameter Block */+tcg_le_opb:+ .word tcg_le_opb_end - tcg_le_opb /* OPBLength */+ .word 0 /* Reserved */+ .long 0 /* EventNumber */+ .space TCG_PCR_VALUE_SIZE /* Hash */+tcg_le_opb_end:+ ++ + /* TCG_HashAll Input Parameter Block */+tcg_hashall_ipb:+ .word tcg_hashall_ipb_end - tcg_hashall_ipb /* IPBLength =16 */+ .word 0 /* Reserved */+tcg_hashall_ipb_data_ptr:+ .long 0 /* HashDataPtr */+tcg_hashall_ipb_data_len:+ .long 0 /* HashDataLen */+ .long 4 /* AlgorithmID TPM_ALG_SHA 0x00000004 */+tcg_hashall_ipb_end:++ /* TCG_HashAll Outnput Parameter Block */+tcg_hashall_opb:+ .space TCG_DIGEST_SIZE /* Hash size = PCR size */+tcg_hashall_opb_end:++ /* Buffer for "tpm test" command */ +tcg_chlee_buf:+ .byte 0xBB, 0x07++ +#ifdef TCG_DEBUG+ /* DEBUG: Display debug message */+debugmsg:+ push %ax+ push %bx+ cld+debugmsg_loop:+ lodsb+ cmpb $0, %al+ je debugmsg_ret+ movw $0x0001, %bx+ movb $0xe, %ah+ int $0x10 /* Display a byte */+ jmp debugmsg_loop+debugmsg_ret:+ pop %bx+ pop %ax+ ret++#define MSG(x) push %si; movw $ABS(x), %si; call debugmsg; pop %si++status_check_msg: .string "DEBUG: TCG_StatusCheck "+tcg_passthru_msg: .string "DEBUG: TCG_PassThru "+logevent_msg: .string "DEBUG: TCG_LogEvent "+hashlogevent_msg: .string "DEBUG: TCG_HashLogExtendEvent "+compacthashlogevent_msg: .string "DEBUG: TCG_CompactHashLogExtendEvent "+hashall_msg: .string "DEBUG: TCG_HashAll 0816 "+ok_msg: .string "ok\r\n"+ng_msg: .string "ng\r\n"+ /* DEBUG: End of debug messages */+#else /* TCG_DEBUG */+#define MSG(x)+#endif /* TCG_DEBUG */++ .code32++ +/*+ * int TCG_StatusCheck (unsigned char *major, *OUT*+ * unsigned char *minor, *OUT* + * unsigned char **event_log ); *OUT*+ * Check TCG status.+ * This returns 0 if the BIOS has TCG function.+ * If system does not have TCG BIOS, TCG_PC_UNSUPPORTED(0x0003) is+ * returned.+ *+ * TCG_StatusCheck + * BIOS Call "Int 1AH Function" verify the presence of TCG BIOS I/F+ * Call with %ax = 0xBB00h (TCG_LogEvent)+ * %ebx = "TCPA" (0x41504354)+ * %ecx = 0+ * %edx = 0+ * 2006-06-20 SM revised + */+ENTRY(TCG_StatusCheck)+ push %ebx+ push %ecx+ push %edx+ push %esi+ push %edi+ push %ebp++#ifdef TCG_BIOS_BIGREALMODE_FIX + call EXT_C(prot_to_big_real)+#else + call EXT_C(prot_to_real)+#endif /* TCG_BIOS_BIGREALMODE_FIX */+ .code16++ MSG(status_check_msg)++ /* TCG_StatusCheck */+ movw $0xBB00, %ax+ int $0x1A+ and %eax, %eax+ jnz tcg_sc_ng+ cmpl %ebx, ABS(tcg_signature)+ je tcg_sc_ok+tcg_sc_ng:+ MSG(ng_msg)+ /* movw $0x0003, %ax # 2006-06-28 SM remove */+ jmp tcg_sc_goback+tcg_sc_ok:+ MSG(ok_msg)+tcg_sc_goback:+ movw %ax, %bx+ DATA32 call EXT_C(real_to_prot)+ .code32++ movzwl %bx, %eax+ test %eax, %eax+ jnz tcg_sc_skip_copy_event_log+ + /* *version major */+ movl 0x1C(%esp), %edi+ movb %ch, (%edi)+ + /* *version minor */ + movl 0x20(%esp), %edi+ movb %cl, (%edi)+ + /* *event_log */+ movl 0x24(%esp), %edi + test %edi, %edi+ jz tcg_sc_skip_copy_event_log++ movl %esi, (%edi)++tcg_sc_skip_copy_event_log:+ pop %ebp+ pop %edi+ pop %esi+ pop %edx+ pop %ecx+ pop %ebx+ ret++/*+ * int TCG_HashLogExtendEventF1( int pcr_index, *IN+ * int hashdatasize *IN+ * unsigned char *hashdeta *IN+ * int logdatasize *IN+ * unsigned char *logdata ) *IN+ *+ * Format 1 (?)+ *+ * BIOS Call "Int 1AH Function" to log TCG_PCR_EVENT+ * Call with %ax = 0xBB01h (TCG_HashLogExtendEvent)+ * %es = Segment of the TPM input parameter block+ * %di = Offset of the TPM input parameter block+ * %ds = Segment of the TPM output parameter block+ * %si = Offset of the TPM output parameter block+ * %ebx = "TCPA" (0x41504354)+ * %ecx = 0+ * %edx = 0+ */+ENTRY(TCG_HashLogExtendEventF1)+ push %ebp+ movl %esp, %ebp+ push %ebx+ push %ecx+ push %edx+ push %esi+ push %edi+ /* ipb - PCR index */+ movl 0x08(%ebp), %eax + movl %eax, ABS(tcg_hlee_ipb_pcr_index)++ /* ipb - Hash Data Size */+ movl 0x0C(%ebp), %eax + movl %eax, ABS(tcg_hlee_ipb_hashdatalen)+ + /* ipb - Hash Data Ptr */+ movl 0x10(%ebp), %esi+ movl %esi, ABS(tcg_hlee_ipb_hashdata)+ + /* ipb - Log Data Size */+ movl 0x14(%ebp), %eax + movl %eax, ABS(tcg_hlee_ipb_logdatalen)+ + /* ipb - Log Data Ptr */+ movl 0x18(%ebp), %esi+ movl %esi, ABS(tcg_hlee_ipb_logdata)++ +#ifdef TCG_BIOS_BIGREALMODE_FIX + call EXT_C(prot_to_big_real)+#else + call EXT_C(prot_to_real)+#endif /* TCG_BIOS_BIGREALMODE_FIX */+ .code16++ /* TCG_HashLogExtendEvent */+ MSG(hashlogevent_msg)++ movw $0xBB01, %ax+ movw $ABS(tcg_hlee_ipb), %di+ movw $ABS(tcg_le_opb), %si+ movl ABS(tcg_signature), %ebx+ xorl %ecx, %ecx+ movl %ecx, %edx+ int $0x1A+ and %eax, %eax+ jz tcg_hlee_ok+ MSG(ng_msg)+ jmp tcg_hlee_go_back++tcg_hlee_ok:+ MSG(ok_msg)++tcg_hlee_go_back:+ movl %eax, %ebx /* TODO return 3h??? */+ DATA32 call EXT_C(real_to_prot)+ .code32++ movl %ebx, %eax+ pop %edi+ pop %esi+ pop %edx+ pop %ecx+ pop %ebx+ pop %ebp+ ret+ +/*+ * int TCG_HashLogExtendEventF2( int pcr_index, *IN+ * int hashdatasize *IN+ * unsigned char *hashdeta *IN+ * int logdatasize *IN+ * unsigned char *logdata ) *IN+ *+ * Format 2 (IBM/Lenove)+ *+ * BIOS Call "Int 1AH Function" to log TCG_PCR_EVENT+ * Call with %ax = 0xBB01h (TCG_HashLogExtendEvent)+ * %es = Segment of the TPM input parameter block+ * %di = Offset of the TPM input parameter block+ * %ds = Segment of the TPM output parameter block+ * %si = Offset of the TPM output parameter block+ * %ebx = "TCPA" (0x41504354)+ * %ecx = 0+ * %edx = 0+ */+ENTRY(TCG_HashLogExtendEventF2)+ push %ebp+ movl %esp, %ebp+ push %ebx+ push %ecx+ push %edx+ push %esi+ push %edi+ /* ipb - PCR index */+ movl 0x08(%ebp), %eax + movl %eax, ABS(tcg_le_ipb_pcr_index)++ /* ipb - Hash Data Size */+ movl 0x0C(%ebp), %eax + movl %eax, ABS(tcg_le_ipb_hashdatalen)+ + /* ipb - Hash Data Ptr */+ movl 0x10(%ebp), %esi+ movl %esi, ABS(tcg_le_ipb_hashdata)+ + /* ipb - Log Data Size */+ movl 0x14(%ebp), %eax + movl %eax, ABS(tcg_le_ipb_logdatalen)+ + /* ipb - Log Data Ptr */+ movl 0x18(%ebp), %esi+ movl %esi, ABS(tcg_le_ipb_logdata)+ /* ipb - reserved - clear */+ xorl %esi, %esi+ movl %esi, ABS(tcg_le_ipb_eventtype)+ +#ifdef TCG_BIOS_BIGREALMODE_FIX + call EXT_C(prot_to_big_real)+#else + call EXT_C(prot_to_real)+#endif /* TCG_BIOS_BIGREALMODE_FIX */+ .code16++ /* TCG_HashLogExtendEvent */+ MSG(hashlogevent_msg)++ movw $0xBB01, %ax+ movw $ABS(tcg_le_ipb), %di+ movw $ABS(tcg_le_opb), %si+ movl ABS(tcg_signature), %ebx+ xorl %ecx, %ecx+ movl %ecx, %edx+ int $0x1A+ and %eax, %eax+ jz tcg_hlee2_ok+ MSG(ng_msg)+ jmp tcg_hlee2_go_back++tcg_hlee2_ok:+ MSG(ok_msg)++tcg_hlee2_go_back:+ movl %eax, %ebx /* TODO return 3h??? */+ DATA32 call EXT_C(real_to_prot)+ .code32++ movl %ebx, %eax+ pop %edi+ pop %esi+ pop %edx+ pop %ecx+ pop %ebx+ pop %ebp+ ret++ +/*+ * TCG PassthroughToTPM+ * Call with (%esi) = TPM OperandIn+ *+ * Return with %eex = Return code+ * (%esi) = TPM OperandOut (= $tpm_operand_out_buff )+ *+ * Modified registers: ebx, ecx, edx, edi+ *+ * BIOS Call "Int 1AH Function" to send a TPM operation.+ * Call with %ax = 0xBB02h (TCG_PassThroughToTPM)+ * %es = Segment of the TPM input parameter block+ * %di = Offset of the TPM input parameter block+ * %ds = Segment of the TPM output parameter block+ * %si = Offset of the TPM output parameter block+ * %ebx = "TCG" (0x41504354)+ * %ecx = 0+ * %edx = 0+ */+tcg_passthru_to_tpm:+ movl $ABS(tpm_operand_in_buff), %edi+ movl 2(%esi), %ecx /* Load operandIn paramSize */+ bswap %ecx /* ecx = operandIn size */+ movl $(tpm_operand_in_buff - tcg_passthru_ipb), %eax+ addl %ecx, %eax /* eax = IPB size */+ movl %eax, ABS(tcg_passthru_ipb_length)++ cld+ rep+ movsb /* Copy operandIn to IPB */++#ifdef TCG_BIOS_BIGREALMODE_FIX + call EXT_C(prot_to_big_real)+#else + call EXT_C(prot_to_real)+#endif /* TCG_BIOS_BIGREALMODE_FIX */+ .code16++ MSG(tcg_passthru_msg)+ movw $0xBB02, %ax+ movw $ABS(tcg_passthru_ipb), %di+ movw $ABS(tcg_passthru_opb), %si+ movl ABS(tcg_signature), %ebx+ xorl %ecx, %ecx+ movl %ecx, %edx+ int $0x1A+ and %eax, %eax+ jnz tcg_passthru_ng+ cmpl %eax, ABS(tpm_operand_out_return_code)+ je tcg_passthru_ok+ movl $0x0004, %eax++tcg_passthru_ng:+ MSG(ng_msg)+ jmp tcg_passthru_return++tcg_passthru_ok:+ MSG(ok_msg)++tcg_passthru_return:+ movl %eax, %ebx+ DATA32 call EXT_C(real_to_prot)+ .code32++ movl $ABS(tpm_operand_out_buff), %esi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -