--- title: 第二次作業 --- # 目標 1. 練習寫Client APP (CA)跟Trusted APP (TA),並用QEMU的環境測試 2. 簡單使用TEE API 3. 練習Bitwise operations   # 作業內容 * 在example中,optee_example_hello_world的CA會執行Invoke Command,然後由TA來做加減數值的動作,再回傳給CA * Q1:請練習寫一個CA跟TA,由CA向TA發起Command,TA回傳系統時間 * 請取得兩種不同的系統時間:Unix time、uptime * TA如何獲取時間? > Hints:TEE_Time、TEE Client API、TEE Internal Core API * bitwise operations(bitops)對二進位數進行操作,在許多古老的微處理器上,位元運算比加減運算略快,通常位元運算比乘除法運算要快很多。在現代架構中:位元運算的運算速度通常與加法運算相同(仍然快於乘法運算)。 * C/C++的位元運算子:<< 、 >> 、 & 、 | 、 ^ 、 ~ ,可以修改變數的位元 * Q2:請練習寫一個CA跟TA,進行setBit、clearBit、inverseBit * setBit(x,y):將x的第y個bit設為1 * clearBit(x,y):將x的第y個bit設為0 * inverseBit(x,y):將x的第y個bit設為inverse * ex:假設CA傳x=2454、y=3給TA,TA收到轉二進位之後setBit(x,y)=100110011110,TA回傳2462 * 可用[計算機](https://www.rapidtables.com/convert/number/binary-to-decimal.html)來驗證你們算的結果 * Q3:傳送Instruction給TA,TA解析並計算後會回傳結果 * 類似於模擬計組的machine code、每個都是16 bit長度(包含opcode,與兩個數值) * 正常計組可能是opcode、destination(register)、source(register)、value、flag等等 * 只要做ADD、AND兩種Instruction * ADD OPCODE = 0001 * AND OPCODE = 0101 * NOT DEFIND OPCODE:DO NOTHING * ex:CA傳送4291給TA,TA收到轉二進位解析之後0001000011000011=3 + 3 = 6,TA回傳6 <!-- # 繳交方式 * 報告 * 截圖 >[!Warning] !!!檔名請讓我看得出來你是誰!!! [繳交連結](https://drive.google.com/drive/folders/1Kiv8cZwtLrKaxSSIMDd9AwXo-KTbbCCw?usp=sharing) -->
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up