From b8e5a8e97918ca30e53d518f76de298bccfe9306 Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Mon, 28 Jun 2021 18:10:43 +0300 Subject: Add information about simple types to lesson 3 --- Lesson_03/README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'Lesson_03') diff --git a/Lesson_03/README.md b/Lesson_03/README.md index f0aef2e..af1d1ad 100644 --- a/Lesson_03/README.md +++ b/Lesson_03/README.md @@ -132,7 +132,68 @@ UefiMain ( The `L""` signifies that the string is composed from CHAR16 symbols, as was required in spec. -Let's compile our edk2 module: +As for `CHAR16` - UEFI uses special names like these for simple types. It is a proxy for a different type realization in different processor architectures. +When we compile our code code for X64, our realization would be picked from a file https://github.com/tianocore/edk2/blob/master/MdePkg/Include/X64/ProcessorBind.h: +``` +typedef unsigned short CHAR16; +``` +For example RISCV would define it like this (https://github.com/tianocore/edk2/blob/master/MdePkg/Include/RiscV64/ProcessorBind.h): +``` +typedef unsigned short CHAR16 __attribute__ ((aligned (2))); +``` + +All the simple types for X64: +``` + /// + /// 8-byte unsigned value + /// + typedef unsigned long long UINT64; + /// + /// 8-byte signed value + /// + typedef long long INT64; + /// + /// 4-byte unsigned value + /// + typedef unsigned int UINT32; + /// + /// 4-byte signed value + /// + typedef int INT32; + /// + /// 2-byte unsigned value + /// + typedef unsigned short UINT16; + /// + /// 2-byte Character. Unless otherwise specified all strings are stored in the + /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards. + /// + typedef unsigned short CHAR16; + /// + /// 2-byte signed value + /// + typedef short INT16; + /// + /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other + /// values are undefined. + /// + typedef unsigned char BOOLEAN; + /// + /// 1-byte unsigned value + /// + typedef unsigned char UINT8; + /// + /// 1-byte Character + /// + typedef char CHAR8; + /// + /// 1-byte signed value + /// + typedef signed char INT8; +``` + + +Let's finally compile our edk2 module: ``` $ build --platform=UefiLessonsPkg/UefiLessonsPkg.dsc \ --module=UefiLessonsPkg/HelloWorld/HelloWorld.inf \ -- cgit v1.2.3-18-g5258