├── .gitignore ├── 050_bs_malloc ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c ├── common.c └── shell.c ├── 032_load_devpath_1 ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 035_load_devpath_2 ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 036_start_devpath ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 037_start_bzImage ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 051_rs_resetsystem ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── main.c ├── graphics.h ├── common.h ├── efi.c ├── graphics.c └── common.c ├── 031_create_devpath_1 ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── main.c ├── graphics.h ├── common.h ├── efi.c ├── graphics.c └── common.c ├── 034_create_devpath_2 ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 040_evt_timer_blocking ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 038_start_bzImage_options ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 041_evt_timer_nonblocking ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 012_simple_text_output_query_mode ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 013_simple_text_output_set_mode ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 010_simple_text_output_set_attribute ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── efi.c ├── main.c ├── graphics.c └── common.c ├── 011_simple_text_output_test_string ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 030_loaded_image_protocol_file_path ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── main.c ├── graphics.h ├── common.h ├── efi.c ├── graphics.c └── common.c ├── 033_loaded_image_protocol_device_handle ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c ├── 020_simple_text_input_ex_register_key_notify ├── file.c ├── gui.h ├── shell.h ├── file.h ├── Makefile ├── graphics.h ├── common.h ├── main.c ├── efi.c ├── graphics.c └── common.c └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.EFI 3 | *.efi 4 | fs 5 | -------------------------------------------------------------------------------- /050_bs_malloc/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /032_load_devpath_1/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /035_load_devpath_2/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /036_start_devpath/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /037_start_bzImage/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /051_rs_resetsystem/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /031_create_devpath_1/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /034_create_devpath_2/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /038_start_bzImage_options/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /050_bs_malloc/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /031_create_devpath_1/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /032_load_devpath_1/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /034_create_devpath_2/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /035_load_devpath_2/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /036_start_devpath/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /037_start_bzImage/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /051_rs_resetsystem/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /038_start_bzImage_options/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/file.c: -------------------------------------------------------------------------------- 1 | #include "file.h" 2 | 3 | struct FILE file_list[MAX_FILE_NUM]; 4 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/gui.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUI_H_ 2 | #define _GUI_H_ 3 | 4 | void gui(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /050_bs_malloc/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /031_create_devpath_1/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /032_load_devpath_1/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /034_create_devpath_2/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /035_load_devpath_2/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /036_start_devpath/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /037_start_bzImage/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /051_rs_resetsystem/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /038_start_bzImage_options/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHELL_H_ 2 | #define _SHELL_H_ 3 | 4 | void dialogue_get_filename(int idx); 5 | void pstat(void); 6 | int ls(void); 7 | void cat(unsigned short *file_name); 8 | void edit(unsigned short *file_name); 9 | void view(unsigned short *img_name); 10 | void shell(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # "フルスクラッチで作る!UEFIベアメタルプログラミング パート2"サンプルプログラム 2 | 同人誌"フルスクラッチで作る!UEFIベアメタルプログラミング パート2"のサンプルプログラムです。 3 | 4 | サンプル毎にディレクトリが分かれています。 5 | 同人誌本文でサンプルコードを紹介する際、ディレクトリ名を書いていますので、 6 | 各サンプルの内容については同人誌を参照してください。 7 | 8 | なお、同人誌のPDF版は、新刊として頒布する[技術書典3](https://techbookfest.org/event/tbf03)のイベント日(10/22(日))以降、 9 | 以下のページで公開しています。 10 | 11 | * http://yuma.ohgami.jp/ 12 | -------------------------------------------------------------------------------- /050_bs_malloc/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /032_load_devpath_1/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /035_load_devpath_2/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /036_start_devpath/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /037_start_bzImage/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /051_rs_resetsystem/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /031_create_devpath_1/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /034_create_devpath_2/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /038_start_bzImage_options/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "graphics.h" 5 | 6 | #define MAX_FILE_NAME_LEN 4 7 | #define MAX_FILE_NUM 10 8 | #define MAX_FILE_BUF 1024 9 | 10 | struct FILE { 11 | struct RECT rect; 12 | unsigned char is_highlight; 13 | unsigned short name[MAX_FILE_NAME_LEN]; 14 | }; 15 | 16 | extern struct FILE file_list[MAX_FILE_NUM]; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /050_bs_malloc/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /032_load_devpath_1/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /035_load_devpath_2/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /036_start_devpath/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /037_start_bzImage/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /051_rs_resetsystem/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /031_create_devpath_1/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /034_create_devpath_2/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /038_start_bzImage_options/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/Makefile: -------------------------------------------------------------------------------- 1 | all: fs/EFI/BOOT/BOOTX64.EFI 2 | 3 | fs/EFI/BOOT/BOOTX64.EFI: efi.c common.c file.c graphics.c shell.c gui.c main.c 4 | mkdir -p fs/EFI/BOOT 5 | x86_64-w64-mingw32-gcc -Wall -Wextra -e efi_main -nostdinc -nostdlib \ 6 | -fno-builtin -Wl,--subsystem,10 -o $@ $+ 7 | 8 | run: fs/EFI/BOOT/BOOTX64.EFI 9 | qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda fat:fs 10 | 11 | clean: 12 | rm -rf *~ fs 13 | 14 | .PHONY: clean 15 | -------------------------------------------------------------------------------- /051_rs_resetsystem/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | efi_init(SystemTable); 8 | ST->ConOut->ClearScreen(ST->ConOut); 9 | 10 | /* キー入力待ち */ 11 | puts(L"何かキーを押すとシャットダウンします。。。\r\n"); 12 | getc(); 13 | 14 | /* シャットダウン */ 15 | ST->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, 16 | NULL); 17 | 18 | while (TRUE); 19 | } 20 | -------------------------------------------------------------------------------- /031_create_devpath_1/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | 9 | efi_init(SystemTable); 10 | ST->ConOut->ClearScreen(ST->ConOut); 11 | 12 | dev_path = DPFTP->ConvertTextToDevicePath(L"\\test.efi"); 13 | puts(L"dev_path: "); 14 | puts(DPTTP->ConvertDevicePathToText(dev_path, FALSE, FALSE)); 15 | puts(L"\r\n"); 16 | 17 | while (TRUE); 18 | } 19 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | unsigned long long status; 7 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 8 | 9 | efi_init(SystemTable); 10 | ST->ConOut->ClearScreen(ST->ConOut); 11 | 12 | status = ST->BootServices->OpenProtocol( 13 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 14 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 15 | assert(status, L"OpenProtocol"); 16 | 17 | puts(L"lip->FilePath: "); 18 | puts(DPTTP->ConvertDevicePathToText(lip->FilePath, FALSE, FALSE)); 19 | puts(L"\r\n"); 20 | 21 | while (TRUE); 22 | } 23 | -------------------------------------------------------------------------------- /050_bs_malloc/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /032_load_devpath_1/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /035_load_devpath_2/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /036_start_devpath/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /037_start_bzImage/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /051_rs_resetsystem/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /031_create_devpath_1/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /032_load_devpath_1/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /034_create_devpath_2/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /035_load_devpath_2/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /036_start_devpath/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /037_start_bzImage/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /031_create_devpath_1/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /032_load_devpath_1/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | unsigned long long status; 9 | void *image; 10 | 11 | efi_init(SystemTable); 12 | ST->ConOut->ClearScreen(ST->ConOut); 13 | 14 | dev_path = DPFTP->ConvertTextToDevicePath(L"\\test.efi"); 15 | puts(L"dev_path: "); 16 | puts(DPTTP->ConvertDevicePathToText(dev_path, FALSE, FALSE)); 17 | puts(L"\r\n"); 18 | 19 | status = ST->BootServices->LoadImage(FALSE, ImageHandle, dev_path, NULL, 20 | 0, &image); 21 | assert(status, L"LoadImage"); 22 | puts(L"LoadImage: Success!\r\n"); 23 | 24 | while (TRUE); 25 | } 26 | -------------------------------------------------------------------------------- /034_create_devpath_2/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /038_start_bzImage_options/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAPHICS_H_ 2 | #define _GRAPHICS_H_ 3 | 4 | #include "efi.h" 5 | 6 | struct RECT { 7 | unsigned int x, y; 8 | unsigned int w, h; 9 | }; 10 | 11 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white; 12 | extern const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow; 13 | 14 | void draw_pixel(unsigned int x, unsigned int y, 15 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color); 16 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c); 17 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y); 18 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r); 19 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | efi_init(SystemTable); 8 | ST->ConOut->ClearScreen(ST->ConOut); 9 | 10 | /* test1 */ 11 | if (!ST->ConOut->TestString(ST->ConOut, L"Hello")) 12 | puts(L"test1: success\r\n"); 13 | else 14 | puts(L"test1: fail\r\n"); 15 | 16 | /* test2 */ 17 | if (!ST->ConOut->TestString(ST->ConOut, L"こんにちは")) 18 | puts(L"test2: success\r\n"); 19 | else 20 | puts(L"test2: fail\r\n"); 21 | 22 | /* test3 */ 23 | if (!ST->ConOut->TestString(ST->ConOut, L"Hello,こんにちは")) 24 | puts(L"test3: success\r\n"); 25 | else 26 | puts(L"test3: fail\r\n"); 27 | 28 | while (TRUE); 29 | } 30 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 18 | void assert(unsigned long long status, unsigned short *message); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /050_bs_malloc/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned long long strlen(unsigned short *str); 18 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 19 | void assert(unsigned long long status, unsigned short *message); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /051_rs_resetsystem/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned long long strlen(unsigned short *str); 18 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 19 | void assert(unsigned long long status, unsigned short *message); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /038_start_bzImage_options/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned long long strlen(unsigned short *str); 18 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 19 | void assert(unsigned long long status, unsigned short *message); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned long long strlen(unsigned short *str); 18 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 19 | void assert(unsigned long long status, unsigned short *message); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #define NULL (void *)0 5 | #define TRUE 1 6 | #define FALSE 0 7 | #define SC_OFS 0x1680 8 | #define SC_ESC (SC_OFS + 0x0017) 9 | 10 | void putc(unsigned short c); 11 | void puts(unsigned short *s); 12 | void puth(unsigned long long val, unsigned char num_digits); 13 | unsigned short getc(void); 14 | unsigned int gets(unsigned short *buf, unsigned int buf_size); 15 | int strcmp(const unsigned short *s1, const unsigned short *s2); 16 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n); 17 | unsigned long long strlen(unsigned short *str); 18 | unsigned char check_warn_error(unsigned long long status, unsigned short *name); 19 | void assert(unsigned long long status, unsigned short *message); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void timer_callback(void *event __attribute__ ((unused)), 5 | void *context __attribute__ ((unused))) 6 | { 7 | puts(L"wait."); 8 | } 9 | 10 | void efi_main(void *ImageHandle __attribute__ ((unused)), 11 | struct EFI_SYSTEM_TABLE *SystemTable) 12 | { 13 | unsigned long long status; 14 | void *tevent; 15 | 16 | efi_init(SystemTable); 17 | ST->ConOut->ClearScreen(ST->ConOut); 18 | 19 | /* タイマーイベントを作成し、teventへ格納 */ 20 | status = ST->BootServices->CreateEvent(EVT_TIMER | EVT_NOTIFY_SIGNAL, 21 | TPL_CALLBACK, timer_callback, 22 | NULL, &tevent); 23 | assert(status, L"CreateEvent"); 24 | 25 | /* teventへ1秒の周期トリガー時間を設定 */ 26 | status = ST->BootServices->SetTimer(tevent, TimerPeriodic, 27 | 10000000); 28 | assert(status, L"SetTimer"); 29 | 30 | while (TRUE); 31 | } 32 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | unsigned char is_exit = FALSE; 5 | 6 | unsigned long long key_notice( 7 | struct EFI_KEY_DATA *KeyData __attribute__ ((unused))) 8 | { 9 | is_exit = TRUE; 10 | 11 | return EFI_SUCCESS; 12 | } 13 | 14 | void efi_main(void *ImageHandle __attribute__ ((unused)), 15 | struct EFI_SYSTEM_TABLE *SystemTable) 16 | { 17 | unsigned long long status; 18 | struct EFI_KEY_DATA key_data = {{0, L'q'}, {0, 0}}; 19 | void *notify_handle; 20 | 21 | efi_init(SystemTable); 22 | ST->ConOut->ClearScreen(ST->ConOut); 23 | 24 | puts(L"Waiting for the 'q' key input...\r\n"); 25 | 26 | status = STIEP->RegisterKeyNotify(STIEP, &key_data, key_notice, 27 | ¬ify_handle); 28 | assert(status, L"RegisterKeyNotify"); 29 | 30 | while (!is_exit); 31 | 32 | puts(L"exit.\r\n"); 33 | 34 | while (TRUE); 35 | } 36 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | int mode; 8 | unsigned long long status; 9 | unsigned long long col, row; 10 | 11 | efi_init(SystemTable); 12 | ST->ConOut->ClearScreen(ST->ConOut); 13 | 14 | for (mode = 0; mode < ST->ConOut->Mode->MaxMode; mode++) { 15 | status = ST->ConOut->QueryMode(ST->ConOut, mode, &col, &row); 16 | switch (status) { 17 | case EFI_SUCCESS: 18 | puth(mode, 2); 19 | puts(L": "); 20 | puth(col, 4); 21 | puts(L" x "); 22 | puth(row, 4); 23 | puts(L"\r\n"); 24 | break; 25 | 26 | case EFI_UNSUPPORTED: 27 | puth(mode, 2); 28 | puts(L": unsupported\r\n"); 29 | break; 30 | 31 | default: 32 | assert(status, L"QueryMode"); 33 | break; 34 | } 35 | } 36 | 37 | while (TRUE); 38 | } 39 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | int mode; 8 | unsigned long long status; 9 | unsigned long long col, row; 10 | 11 | efi_init(SystemTable); 12 | ST->ConOut->ClearScreen(ST->ConOut); 13 | 14 | while (TRUE) { 15 | for (mode = 0; mode < ST->ConOut->Mode->MaxMode; mode++) { 16 | status = ST->ConOut->QueryMode(ST->ConOut, mode, &col, 17 | &row); 18 | if (status) 19 | continue; 20 | 21 | ST->ConOut->SetMode(ST->ConOut, mode); 22 | ST->ConOut->ClearScreen(SystemTable->ConOut); 23 | 24 | puts(L"mode="); 25 | puth(mode, 1); 26 | puts(L", col=0x"); 27 | puth(col, 2); 28 | puts(L", row=0x"); 29 | puth(row, 2); 30 | puts(L"\r\n"); 31 | puts(L"\r\n"); 32 | puts(L"Hello UEFI!こんにちは、せかい!"); 33 | 34 | getc(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | unsigned long long status; 8 | void *tevent; 9 | void *wait_list[1]; 10 | unsigned long long idx; 11 | 12 | efi_init(SystemTable); 13 | ST->ConOut->ClearScreen(ST->ConOut); 14 | 15 | /* タイマーイベントを作成し、teventへ格納 */ 16 | status = ST->BootServices->CreateEvent(EVT_TIMER, 0, NULL, NULL, 17 | &tevent); 18 | assert(status, L"CreateEvent"); 19 | 20 | /* WaitForEvent()へ渡す為にイベントリストを作成 */ 21 | wait_list[0] = tevent; 22 | 23 | while (TRUE) { 24 | /* teventへ1秒のトリガー時間を設定 */ 25 | status = ST->BootServices->SetTimer(tevent, TimerRelative, 26 | 10000000); 27 | assert(status, L"SetTimer"); 28 | 29 | /* イベント発生を待つ */ 30 | status = ST->BootServices->WaitForEvent(1, wait_list, &idx); 31 | assert(status, L"WaitForEvent"); 32 | 33 | /* 画面へ"wait."を出力 */ 34 | puts(L"wait."); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | 9 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 10 | { 11 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 12 | {0x96, 0xfb, 0x7a, 0xde, 13 | 0xd0, 0x80, 0x51, 0x6a}}; 14 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 15 | {0x9a, 0x4f, 0x0, 0x90, 16 | 0x27, 0x3f, 0xc1, 0x4d}}; 17 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 18 | {0x8e, 0x39, 0x00, 0xa0, 19 | 0xc9, 0x69, 0x72, 0x3b}}; 20 | 21 | ST = SystemTable; 22 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 23 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 24 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 25 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 26 | } 27 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | 9 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 10 | { 11 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 12 | {0x96, 0xfb, 0x7a, 0xde, 13 | 0xd0, 0x80, 0x51, 0x6a}}; 14 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 15 | {0x9a, 0x4f, 0x0, 0x90, 16 | 0x27, 0x3f, 0xc1, 0x4d}}; 17 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 18 | {0x8e, 0x39, 0x00, 0xa0, 19 | 0xc9, 0x69, 0x72, 0x3b}}; 20 | 21 | ST = SystemTable; 22 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 23 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 24 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 25 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 26 | } 27 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | 9 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 10 | { 11 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 12 | {0x96, 0xfb, 0x7a, 0xde, 13 | 0xd0, 0x80, 0x51, 0x6a}}; 14 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 15 | {0x9a, 0x4f, 0x0, 0x90, 16 | 0x27, 0x3f, 0xc1, 0x4d}}; 17 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 18 | {0x8e, 0x39, 0x00, 0xa0, 19 | 0xc9, 0x69, 0x72, 0x3b}}; 20 | 21 | ST = SystemTable; 22 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 23 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 24 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 25 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 26 | } 27 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | 9 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 10 | { 11 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 12 | {0x96, 0xfb, 0x7a, 0xde, 13 | 0xd0, 0x80, 0x51, 0x6a}}; 14 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 15 | {0x9a, 0x4f, 0x0, 0x90, 16 | 0x27, 0x3f, 0xc1, 0x4d}}; 17 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 18 | {0x8e, 0x39, 0x00, 0xa0, 19 | 0xc9, 0x69, 0x72, 0x3b}}; 20 | 21 | ST = SystemTable; 22 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 23 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 24 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 25 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 26 | } 27 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | unsigned long long status; 9 | 10 | efi_init(SystemTable); 11 | ST->ConOut->ClearScreen(ST->ConOut); 12 | 13 | /* ImageHandleのEFI_LOADED_IMAGE_PROTOCOL(lip)を取得 */ 14 | status = ST->BootServices->OpenProtocol( 15 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 16 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 17 | assert(status, L"OpenProtocol(lip)"); 18 | 19 | /* lip->DeviceHandleのEFI_DEVICE_PATH_PROTOCOL(dev_path)を取得 */ 20 | status = ST->BootServices->OpenProtocol( 21 | lip->DeviceHandle, &dpp_guid, (void **)&dev_path, ImageHandle, 22 | NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); 23 | assert(status, L"OpenProtocol(dpp)"); 24 | 25 | /* dev_pathをテキストへ変換し表示 */ 26 | puts(L"dev_path: "); 27 | puts(DPTTP->ConvertDevicePathToText(dev_path, FALSE, FALSE)); 28 | puts(L"\r\n"); 29 | 30 | while (TRUE); 31 | } 32 | -------------------------------------------------------------------------------- /050_bs_malloc/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | #define IMG_WIDTH 256 6 | #define IMG_HEIGHT 256 7 | 8 | void efi_main(void *ImageHandle __attribute__ ((unused)), 9 | struct EFI_SYSTEM_TABLE *SystemTable) 10 | { 11 | unsigned long long status; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *img_buf, *t; 13 | unsigned int i, j; 14 | 15 | efi_init(SystemTable); 16 | ST->ConOut->ClearScreen(ST->ConOut); 17 | 18 | /* 画像バッファ用のメモリを確保 */ 19 | status = ST->BootServices->AllocatePool( 20 | EfiLoaderData, 21 | IMG_WIDTH * IMG_HEIGHT * 22 | sizeof(struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 23 | (void **)&img_buf); 24 | assert(status, L"AllocatePool"); 25 | 26 | /* 画像を生成 */ 27 | t = img_buf; 28 | for (i = 0; i < IMG_HEIGHT; i++) { 29 | for (j = 0; j < IMG_WIDTH; j++) { 30 | t->Blue = i; 31 | t->Green = j; 32 | t->Red = 0; 33 | t->Reserved = 255; 34 | t++; 35 | } 36 | } 37 | 38 | /* 画像描画(フレームバッファへ書き込み) */ 39 | blt((unsigned char *)img_buf, IMG_WIDTH, IMG_HEIGHT); 40 | 41 | /* 確保したメモリを解放 */ 42 | status = ST->BootServices->FreePool((void *)img_buf); 43 | assert(status, L"FreePool"); 44 | 45 | while (TRUE); 46 | } 47 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | 10 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 11 | { 12 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 13 | {0x96, 0xfb, 0x7a, 0xde, 14 | 0xd0, 0x80, 0x51, 0x6a}}; 15 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 16 | {0x9a, 0x4f, 0x0, 0x90, 17 | 0x27, 0x3f, 0xc1, 0x4d}}; 18 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 19 | {0x8e, 0x39, 0x00, 0xa0, 20 | 0xc9, 0x69, 0x72, 0x3b}}; 21 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 22 | {0x8c, 0x14, 0xf5, 0x85, 23 | 0x17, 0xa6, 0x25, 0xaa}}; 24 | 25 | ST = SystemTable; 26 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 27 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 28 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 29 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 30 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 31 | } 32 | -------------------------------------------------------------------------------- /034_create_devpath_2/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | struct EFI_DEVICE_PATH_PROTOCOL *dev_node; 9 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path_merged; 10 | unsigned long long status; 11 | 12 | efi_init(SystemTable); 13 | ST->ConOut->ClearScreen(ST->ConOut); 14 | 15 | /* ImageHandleのEFI_LOADED_IMAGE_PROTOCOL(lip)を取得 */ 16 | status = ST->BootServices->OpenProtocol( 17 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 18 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 19 | assert(status, L"OpenProtocol(lip)"); 20 | 21 | /* lip->DeviceHandleのEFI_DEVICE_PATH_PROTOCOL(dev_path)を取得 */ 22 | status = ST->BootServices->OpenProtocol( 23 | lip->DeviceHandle, &dpp_guid, (void **)&dev_path, ImageHandle, 24 | NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); 25 | assert(status, L"OpenProtocol(dpp)"); 26 | 27 | /* "test.efi"のデバイスノードを作成 */ 28 | dev_node = DPFTP->ConvertTextToDeviceNode(L"test.efi"); 29 | 30 | /* dev_pathとdev_nodeを連結 */ 31 | dev_path_merged = DPUP->AppendDeviceNode(dev_path, dev_node); 32 | 33 | /* dev_path_mergedをテキストへ変換し表示 */ 34 | puts(L"dev_path_merged: "); 35 | puts(DPTTP->ConvertDevicePathToText(dev_path_merged, FALSE, FALSE)); 36 | puts(L"\r\n"); 37 | 38 | while (TRUE); 39 | } 40 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle __attribute__ ((unused)), 5 | struct EFI_SYSTEM_TABLE *SystemTable) 6 | { 7 | efi_init(SystemTable); 8 | 9 | puts(L" "); 10 | 11 | ST->ConOut->SetAttribute(ST->ConOut, 12 | EFI_LIGHTGREEN | EFI_BACKGROUND_LIGHTGRAY); 13 | ST->ConOut->ClearScreen(ST->ConOut); 14 | 15 | puts(L"\r\n\r\n\r\n\r\n\r\n\r\n\r\n"); 16 | puts(L" "); 17 | puts(L"フルスクラッチで作る!\r\n"); 18 | 19 | ST->ConOut->SetAttribute(ST->ConOut, 20 | EFI_LIGHTRED | EFI_BACKGROUND_LIGHTGRAY); 21 | puts(L" "); 22 | puts(L"UEFIベアメタルプログラミング\r\n"); 23 | 24 | ST->ConOut->SetAttribute(ST->ConOut, 25 | EFI_LIGHTMAGENTA | EFI_BACKGROUND_LIGHTGRAY); 26 | puts(L" "); 27 | puts(L"パート2\r\n"); 28 | 29 | ST->ConOut->SetAttribute(ST->ConOut, 30 | EFI_LIGHTBLUE | EFI_BACKGROUND_LIGHTGRAY); 31 | puts(L"\r\n\r\n\r\n\r\n\r\n\r\n\r\n"); 32 | puts(L" "); 33 | puts(L"大ネ申 ネ右真 著\r\n"); 34 | 35 | ST->ConOut->SetAttribute(ST->ConOut, 36 | EFI_GREEN | EFI_BACKGROUND_LIGHTGRAY); 37 | puts(L"\r\n\r\n\r\n\r\n\r\n\r\n\r\n"); 38 | puts(L" "); 39 | puts(L"2017-10-22 版 "); 40 | 41 | ST->ConOut->SetAttribute(ST->ConOut, 42 | EFI_MAGENTA | EFI_BACKGROUND_LIGHTGRAY); 43 | puts(L"henyapente "); 44 | 45 | ST->ConOut->SetAttribute(ST->ConOut, 46 | EFI_BLUE | EFI_BACKGROUND_LIGHTGRAY); 47 | puts(L"発 行\r\n"); 48 | 49 | while (TRUE); 50 | } 51 | -------------------------------------------------------------------------------- /035_load_devpath_2/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | struct EFI_DEVICE_PATH_PROTOCOL *dev_node; 9 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path_merged; 10 | unsigned long long status; 11 | void *image; 12 | 13 | efi_init(SystemTable); 14 | ST->ConOut->ClearScreen(ST->ConOut); 15 | 16 | /* ImageHandleのEFI_LOADED_IMAGE_PROTOCOL(lip)を取得 */ 17 | status = ST->BootServices->OpenProtocol( 18 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 19 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 20 | assert(status, L"OpenProtocol(lip)"); 21 | 22 | /* lip->DeviceHandleのEFI_DEVICE_PATH_PROTOCOL(dev_path)を取得 */ 23 | status = ST->BootServices->OpenProtocol( 24 | lip->DeviceHandle, &dpp_guid, (void **)&dev_path, ImageHandle, 25 | NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); 26 | assert(status, L"OpenProtocol(dpp)"); 27 | 28 | /* "test.efi"のデバイスノードを作成 */ 29 | dev_node = DPFTP->ConvertTextToDeviceNode(L"test.efi"); 30 | 31 | /* dev_pathとdev_nodeを連結 */ 32 | dev_path_merged = DPUP->AppendDeviceNode(dev_path, dev_node); 33 | 34 | /* dev_path_mergedをテキストへ変換し表示 */ 35 | puts(L"dev_path_merged: "); 36 | puts(DPTTP->ConvertDevicePathToText(dev_path_merged, FALSE, FALSE)); 37 | puts(L"\r\n"); 38 | 39 | /* dev_path_mergedをロード */ 40 | status = ST->BootServices->LoadImage(FALSE, ImageHandle, 41 | dev_path_merged, NULL, 0, &image); 42 | assert(status, L"LoadImage"); 43 | puts(L"LoadImage: Success!\r\n"); 44 | 45 | while (TRUE); 46 | } 47 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 11 | {0x8e, 0x3f, 0x00, 0xa0, 12 | 0xc9, 0x69, 0x72, 0x3b}}; 13 | 14 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 15 | { 16 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 17 | {0x96, 0xfb, 0x7a, 0xde, 18 | 0xd0, 0x80, 0x51, 0x6a}}; 19 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 20 | {0x9a, 0x4f, 0x0, 0x90, 21 | 0x27, 0x3f, 0xc1, 0x4d}}; 22 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 23 | {0x8e, 0x39, 0x00, 0xa0, 24 | 0xc9, 0x69, 0x72, 0x3b}}; 25 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 26 | {0x8c, 0x14, 0xf5, 0x85, 27 | 0x17, 0xa6, 0x25, 0xaa}}; 28 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 29 | {0x90, 0xcc, 0x55, 0x1a, 30 | 0x4e, 0x4a, 0x7f, 0x1c}}; 31 | 32 | ST = SystemTable; 33 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 34 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 35 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 36 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 37 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 38 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 39 | } 40 | -------------------------------------------------------------------------------- /036_start_devpath/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | struct EFI_DEVICE_PATH_PROTOCOL *dev_node; 9 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path_merged; 10 | unsigned long long status; 11 | void *image; 12 | 13 | efi_init(SystemTable); 14 | ST->ConOut->ClearScreen(ST->ConOut); 15 | 16 | /* ImageHandleのEFI_LOADED_IMAGE_PROTOCOL(lip)を取得 */ 17 | status = ST->BootServices->OpenProtocol( 18 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 19 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 20 | assert(status, L"OpenProtocol(lip)"); 21 | 22 | /* lip->DeviceHandleのEFI_DEVICE_PATH_PROTOCOL(dev_path)を取得 */ 23 | status = ST->BootServices->OpenProtocol( 24 | lip->DeviceHandle, &dpp_guid, (void **)&dev_path, ImageHandle, 25 | NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); 26 | assert(status, L"OpenProtocol(dpp)"); 27 | 28 | /* "test.efi"のデバイスノードを作成 */ 29 | dev_node = DPFTP->ConvertTextToDeviceNode(L"test.efi"); 30 | 31 | /* dev_pathとdev_nodeを連結 */ 32 | dev_path_merged = DPUP->AppendDeviceNode(dev_path, dev_node); 33 | 34 | /* dev_path_mergedをテキストへ変換し表示 */ 35 | puts(L"dev_path_merged: "); 36 | puts(DPTTP->ConvertDevicePathToText(dev_path_merged, FALSE, FALSE)); 37 | puts(L"\r\n"); 38 | 39 | /* dev_path_mergedをロード */ 40 | status = ST->BootServices->LoadImage(FALSE, ImageHandle, 41 | dev_path_merged, NULL, 0, &image); 42 | assert(status, L"LoadImage"); 43 | puts(L"LoadImage: Success!\r\n"); 44 | 45 | /* imageの実行を開始する */ 46 | status = ST->BootServices->StartImage(image, NULL, NULL); 47 | assert(status, L"StartImage"); 48 | puts(L"StartImage: Success!\r\n"); 49 | 50 | while (TRUE); 51 | } 52 | -------------------------------------------------------------------------------- /037_start_bzImage/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 7 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 8 | struct EFI_DEVICE_PATH_PROTOCOL *dev_node; 9 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path_merged; 10 | unsigned long long status; 11 | void *image; 12 | 13 | efi_init(SystemTable); 14 | ST->ConOut->ClearScreen(ST->ConOut); 15 | 16 | /* ImageHandleのEFI_LOADED_IMAGE_PROTOCOL(lip)を取得 */ 17 | status = ST->BootServices->OpenProtocol( 18 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 19 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 20 | assert(status, L"OpenProtocol(lip)"); 21 | 22 | /* lip->DeviceHandleのEFI_DEVICE_PATH_PROTOCOL(dev_path)を取得 */ 23 | status = ST->BootServices->OpenProtocol( 24 | lip->DeviceHandle, &dpp_guid, (void **)&dev_path, ImageHandle, 25 | NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); 26 | assert(status, L"OpenProtocol(dpp)"); 27 | 28 | /* "bzImage.efi"のデバイスノードを作成 */ 29 | dev_node = DPFTP->ConvertTextToDeviceNode(L"bzImage.efi"); 30 | 31 | /* dev_pathとdev_nodeを連結 */ 32 | dev_path_merged = DPUP->AppendDeviceNode(dev_path, dev_node); 33 | 34 | /* dev_path_mergedをテキストへ変換し表示 */ 35 | puts(L"dev_path_merged: "); 36 | puts(DPTTP->ConvertDevicePathToText(dev_path_merged, FALSE, FALSE)); 37 | puts(L"\r\n"); 38 | 39 | /* dev_path_mergedをロード */ 40 | status = ST->BootServices->LoadImage(FALSE, ImageHandle, 41 | dev_path_merged, NULL, 0, &image); 42 | assert(status, L"LoadImage"); 43 | puts(L"LoadImage: Success!\r\n"); 44 | 45 | /* imageの実行を開始する */ 46 | status = ST->BootServices->StartImage(image, NULL, NULL); 47 | assert(status, L"StartImage"); 48 | puts(L"StartImage: Success!\r\n"); 49 | 50 | while (TRUE); 51 | } 52 | -------------------------------------------------------------------------------- /031_create_devpath_1/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 12 | {0x8e, 0x3f, 0x00, 0xa0, 13 | 0xc9, 0x69, 0x72, 0x3b}}; 14 | 15 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 16 | { 17 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 18 | {0x96, 0xfb, 0x7a, 0xde, 19 | 0xd0, 0x80, 0x51, 0x6a}}; 20 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 21 | {0x9a, 0x4f, 0x0, 0x90, 22 | 0x27, 0x3f, 0xc1, 0x4d}}; 23 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 24 | {0x8e, 0x39, 0x00, 0xa0, 25 | 0xc9, 0x69, 0x72, 0x3b}}; 26 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 27 | {0x8c, 0x14, 0xf5, 0x85, 28 | 0x17, 0xa6, 0x25, 0xaa}}; 29 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 30 | {0x90, 0xcc, 0x55, 0x1a, 31 | 0x4e, 0x4a, 0x7f, 0x1c}}; 32 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 33 | {0x8a, 0x5f, 0x35, 0xdf, 34 | 0x33, 0x43, 0xf5, 0x1e}}; 35 | 36 | ST = SystemTable; 37 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 38 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 39 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 40 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 41 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 42 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 43 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 44 | } 45 | -------------------------------------------------------------------------------- /032_load_devpath_1/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 12 | {0x8e, 0x3f, 0x00, 0xa0, 13 | 0xc9, 0x69, 0x72, 0x3b}}; 14 | 15 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 16 | { 17 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 18 | {0x96, 0xfb, 0x7a, 0xde, 19 | 0xd0, 0x80, 0x51, 0x6a}}; 20 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 21 | {0x9a, 0x4f, 0x0, 0x90, 22 | 0x27, 0x3f, 0xc1, 0x4d}}; 23 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 24 | {0x8e, 0x39, 0x00, 0xa0, 25 | 0xc9, 0x69, 0x72, 0x3b}}; 26 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 27 | {0x8c, 0x14, 0xf5, 0x85, 28 | 0x17, 0xa6, 0x25, 0xaa}}; 29 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 30 | {0x90, 0xcc, 0x55, 0x1a, 31 | 0x4e, 0x4a, 0x7f, 0x1c}}; 32 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 33 | {0x8a, 0x5f, 0x35, 0xdf, 34 | 0x33, 0x43, 0xf5, 0x1e}}; 35 | 36 | ST = SystemTable; 37 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 38 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 39 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 40 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 41 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 42 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 43 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 44 | } 45 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 12 | {0x8e, 0x3f, 0x00, 0xa0, 13 | 0xc9, 0x69, 0x72, 0x3b}}; 14 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 15 | {0x8e, 0x39, 0x00, 0xa0, 16 | 0xc9, 0x69, 0x72, 0x3b}}; 17 | 18 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 19 | { 20 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 21 | {0x96, 0xfb, 0x7a, 0xde, 22 | 0xd0, 0x80, 0x51, 0x6a}}; 23 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 24 | {0x9a, 0x4f, 0x0, 0x90, 25 | 0x27, 0x3f, 0xc1, 0x4d}}; 26 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 27 | {0x8e, 0x39, 0x00, 0xa0, 28 | 0xc9, 0x69, 0x72, 0x3b}}; 29 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 30 | {0x8c, 0x14, 0xf5, 0x85, 31 | 0x17, 0xa6, 0x25, 0xaa}}; 32 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 33 | {0x90, 0xcc, 0x55, 0x1a, 34 | 0x4e, 0x4a, 0x7f, 0x1c}}; 35 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 36 | {0x8a, 0x5f, 0x35, 0xdf, 37 | 0x33, 0x43, 0xf5, 0x1e}}; 38 | 39 | ST = SystemTable; 40 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 41 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 42 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 43 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 44 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 45 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 46 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 47 | } 48 | -------------------------------------------------------------------------------- /038_start_bzImage_options/main.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) 5 | { 6 | struct EFI_LOADED_IMAGE_PROTOCOL *lip; 7 | struct EFI_LOADED_IMAGE_PROTOCOL *lip_bzimage; 8 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path; 9 | struct EFI_DEVICE_PATH_PROTOCOL *dev_node; 10 | struct EFI_DEVICE_PATH_PROTOCOL *dev_path_merged; 11 | unsigned long long status; 12 | void *image; 13 | unsigned short options[] = L"root=/dev/sdb2 init=/bin/sh rootwait"; 14 | 15 | efi_init(SystemTable); 16 | ST->ConOut->ClearScreen(ST->ConOut); 17 | 18 | /* ImageHandleのEFI_LOADED_IMAGE_PROTOCOL(lip)を取得 */ 19 | status = ST->BootServices->OpenProtocol( 20 | ImageHandle, &lip_guid, (void **)&lip, ImageHandle, NULL, 21 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 22 | assert(status, L"OpenProtocol(lip)"); 23 | 24 | /* lip->DeviceHandleのEFI_DEVICE_PATH_PROTOCOL(dev_path)を取得 */ 25 | status = ST->BootServices->OpenProtocol( 26 | lip->DeviceHandle, &dpp_guid, (void **)&dev_path, ImageHandle, 27 | NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); 28 | assert(status, L"OpenProtocol(dpp)"); 29 | 30 | /* "bzImage.efi"のデバイスノードを作成 */ 31 | dev_node = DPFTP->ConvertTextToDeviceNode(L"bzImage.efi"); 32 | 33 | /* dev_pathとdev_nodeを連結 */ 34 | dev_path_merged = DPUP->AppendDeviceNode(dev_path, dev_node); 35 | 36 | /* dev_path_mergedをテキストへ変換し表示 */ 37 | puts(L"dev_path_merged: "); 38 | puts(DPTTP->ConvertDevicePathToText(dev_path_merged, FALSE, FALSE)); 39 | puts(L"\r\n"); 40 | 41 | /* dev_path_mergedをロード */ 42 | status = ST->BootServices->LoadImage(FALSE, ImageHandle, 43 | dev_path_merged, NULL, 0, &image); 44 | assert(status, L"LoadImage"); 45 | puts(L"LoadImage: Success!\r\n"); 46 | 47 | /* カーネル起動オプションを設定 */ 48 | status = ST->BootServices->OpenProtocol( 49 | image, &lip_guid, (void **)&lip_bzimage, ImageHandle, NULL, 50 | EFI_OPEN_PROTOCOL_GET_PROTOCOL); 51 | assert(status, L"OpenProtocol(lip_bzimage)"); 52 | lip_bzimage->LoadOptions = options; 53 | lip_bzimage->LoadOptionsSize = 54 | (strlen(options) + 1) * sizeof(unsigned short); 55 | 56 | /* imageの実行を開始する */ 57 | status = ST->BootServices->StartImage(image, NULL, NULL); 58 | assert(status, L"StartImage"); 59 | puts(L"StartImage: Success!\r\n"); 60 | 61 | while (TRUE); 62 | } 63 | -------------------------------------------------------------------------------- /050_bs_malloc/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /034_create_devpath_2/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /035_load_devpath_2/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /036_start_devpath/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /037_start_bzImage/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /051_rs_resetsystem/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /038_start_bzImage_options/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/efi.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | struct EFI_SYSTEM_TABLE *ST; 5 | struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; 6 | struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; 7 | struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; 8 | struct EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *STIEP; 9 | struct EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DPTTP; 10 | struct EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *DPFTP; 11 | struct EFI_DEVICE_PATH_UTILITIES_PROTOCOL *DPUP; 12 | struct EFI_GUID lip_guid = {0x5b1b31a1, 0x9562, 0x11d2, 13 | {0x8e, 0x3f, 0x00, 0xa0, 14 | 0xc9, 0x69, 0x72, 0x3b}}; 15 | struct EFI_GUID dpp_guid = {0x09576e91, 0x6d3f, 0x11d2, 16 | {0x8e, 0x39, 0x00, 0xa0, 17 | 0xc9, 0x69, 0x72, 0x3b}}; 18 | 19 | void efi_init(struct EFI_SYSTEM_TABLE *SystemTable) 20 | { 21 | struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, 22 | {0x96, 0xfb, 0x7a, 0xde, 23 | 0xd0, 0x80, 0x51, 0x6a}}; 24 | struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, 25 | {0x9a, 0x4f, 0x0, 0x90, 26 | 0x27, 0x3f, 0xc1, 0x4d}}; 27 | struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459, 0x11d2, 28 | {0x8e, 0x39, 0x00, 0xa0, 29 | 0xc9, 0x69, 0x72, 0x3b}}; 30 | struct EFI_GUID stiep_guid = {0xdd9e7534, 0x7762, 0x4698, 31 | {0x8c, 0x14, 0xf5, 0x85, 32 | 0x17, 0xa6, 0x25, 0xaa}}; 33 | struct EFI_GUID dpttp_guid = {0x8b843e20, 0x8132, 0x4852, 34 | {0x90, 0xcc, 0x55, 0x1a, 35 | 0x4e, 0x4a, 0x7f, 0x1c}}; 36 | struct EFI_GUID dpftp_guid = {0x5c99a21, 0xc70f, 0x4ad2, 37 | {0x8a, 0x5f, 0x35, 0xdf, 38 | 0x33, 0x43, 0xf5, 0x1e}}; 39 | struct EFI_GUID dpup_guid = {0x379be4e, 0xd706, 0x437d, 40 | {0xb0, 0x37, 0xed, 0xb8, 41 | 0x2f, 0xb7, 0x72, 0xa4}}; 42 | 43 | ST = SystemTable; 44 | ST->BootServices->SetWatchdogTimer(0, 0, 0, NULL); 45 | ST->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); 46 | ST->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); 47 | ST->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); 48 | ST->BootServices->LocateProtocol(&stiep_guid, NULL, (void **)&STIEP); 49 | ST->BootServices->LocateProtocol(&dpttp_guid, NULL, (void **)&DPTTP); 50 | ST->BootServices->LocateProtocol(&dpftp_guid, NULL, (void **)&DPFTP); 51 | ST->BootServices->LocateProtocol(&dpup_guid, NULL, (void **)&DPUP); 52 | } 53 | -------------------------------------------------------------------------------- /036_start_devpath/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /037_start_bzImage/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /050_bs_malloc/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /031_create_devpath_1/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /032_load_devpath_1/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /034_create_devpath_2/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /035_load_devpath_2/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /051_rs_resetsystem/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /038_start_bzImage_options/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/graphics.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "graphics.h" 4 | 5 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL white = {0xff, 0xff, 0xff, 0xff}; 6 | const struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL yellow = {0x00, 0xff, 0xff, 0xff}; 7 | 8 | void draw_pixel(unsigned int x, unsigned int y, 9 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) 10 | { 11 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 12 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 13 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; 14 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 15 | 16 | p->Blue = color.Blue; 17 | p->Green = color.Green; 18 | p->Red = color.Red; 19 | p->Reserved = color.Reserved; 20 | } 21 | 22 | void draw_rect(struct RECT r, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL c) 23 | { 24 | unsigned int i; 25 | 26 | for (i = r.x; i < (r.x + r.w); i++) 27 | draw_pixel(i, r.y, c); 28 | for (i = r.x; i < (r.x + r.w); i++) 29 | draw_pixel(i, r.y + r.h - 1, c); 30 | 31 | for (i = r.y; i < (r.y + r.h); i++) 32 | draw_pixel(r.x, i, c); 33 | for (i = r.y; i < (r.y + r.h); i++) 34 | draw_pixel(r.x + r.w - 1, i, c); 35 | } 36 | 37 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) 38 | { 39 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 40 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = 41 | (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) 42 | GOP->Mode->FrameBufferBase; 43 | struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; 44 | 45 | return *p; 46 | } 47 | 48 | unsigned char is_in_rect(unsigned int x, unsigned int y, struct RECT r) 49 | { 50 | if ((r.x <= x) && (x <= (r.x + r.w - 1)) 51 | && (r.y <= y) && (y <= (r.y + r.h - 1))) 52 | return TRUE; 53 | return FALSE; 54 | } 55 | 56 | void blt(unsigned char img[], unsigned int img_width, unsigned int img_height) 57 | { 58 | unsigned char *fb; 59 | unsigned int i, j, k, vr, hr, ofs = 0; 60 | 61 | fb = (unsigned char *)GOP->Mode->FrameBufferBase; 62 | vr = GOP->Mode->Info->VerticalResolution; 63 | hr = GOP->Mode->Info->HorizontalResolution; 64 | 65 | for (i = 0; i < vr; i++) { 66 | if (i >= img_height) 67 | break; 68 | for (j = 0; j < hr; j++) { 69 | if (j >= img_width) { 70 | fb += (hr - img_width) * 4; 71 | break; 72 | } 73 | for (k = 0; k < 4; k++) 74 | *fb++ = img[ofs++]; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /032_load_devpath_1/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /035_load_devpath_2/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /036_start_devpath/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /037_start_bzImage/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /031_create_devpath_1/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /034_create_devpath_2/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /011_simple_text_output_test_string/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /012_simple_text_output_query_mode/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /013_simple_text_output_set_mode/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /010_simple_text_output_set_attribute/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /030_loaded_image_protocol_file_path/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /033_loaded_image_protocol_device_handle/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /020_simple_text_input_ex_register_key_notify/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 99 | { 100 | if (status) { 101 | puts(message); 102 | puts(L":"); 103 | puth(status, 16); 104 | puts(L"\r\n"); 105 | } 106 | 107 | return !status; 108 | } 109 | 110 | void assert(unsigned long long status, unsigned short *message) 111 | { 112 | if (!check_warn_error(status, message)) 113 | while (1); 114 | } 115 | -------------------------------------------------------------------------------- /050_bs_malloc/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned long long strlen(unsigned short *str) 99 | { 100 | unsigned long long len = 0; 101 | 102 | while (*str++ != L'\0') 103 | len++; 104 | 105 | return len; 106 | } 107 | 108 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 109 | { 110 | if (status) { 111 | puts(message); 112 | puts(L":"); 113 | puth(status, 16); 114 | puts(L"\r\n"); 115 | } 116 | 117 | return !status; 118 | } 119 | 120 | void assert(unsigned long long status, unsigned short *message) 121 | { 122 | if (!check_warn_error(status, message)) 123 | while (1); 124 | } 125 | -------------------------------------------------------------------------------- /051_rs_resetsystem/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned long long strlen(unsigned short *str) 99 | { 100 | unsigned long long len = 0; 101 | 102 | while (*str++ != L'\0') 103 | len++; 104 | 105 | return len; 106 | } 107 | 108 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 109 | { 110 | if (status) { 111 | puts(message); 112 | puts(L":"); 113 | puth(status, 16); 114 | puts(L"\r\n"); 115 | } 116 | 117 | return !status; 118 | } 119 | 120 | void assert(unsigned long long status, unsigned short *message) 121 | { 122 | if (!check_warn_error(status, message)) 123 | while (1); 124 | } 125 | -------------------------------------------------------------------------------- /040_evt_timer_blocking/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned long long strlen(unsigned short *str) 99 | { 100 | unsigned long long len = 0; 101 | 102 | while (*str++ != L'\0') 103 | len++; 104 | 105 | return len; 106 | } 107 | 108 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 109 | { 110 | if (status) { 111 | puts(message); 112 | puts(L":"); 113 | puth(status, 16); 114 | puts(L"\r\n"); 115 | } 116 | 117 | return !status; 118 | } 119 | 120 | void assert(unsigned long long status, unsigned short *message) 121 | { 122 | if (!check_warn_error(status, message)) 123 | while (1); 124 | } 125 | -------------------------------------------------------------------------------- /038_start_bzImage_options/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned long long strlen(unsigned short *str) 99 | { 100 | unsigned long long len = 0; 101 | 102 | while (*str++ != L'\0') 103 | len++; 104 | 105 | return len; 106 | } 107 | 108 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 109 | { 110 | if (status) { 111 | puts(message); 112 | puts(L":"); 113 | puth(status, 16); 114 | puts(L"\r\n"); 115 | } 116 | 117 | return !status; 118 | } 119 | 120 | void assert(unsigned long long status, unsigned short *message) 121 | { 122 | if (!check_warn_error(status, message)) 123 | while (1); 124 | } 125 | -------------------------------------------------------------------------------- /041_evt_timer_nonblocking/common.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | 4 | #define MAX_STR_BUF 100 5 | 6 | void putc(unsigned short c) 7 | { 8 | unsigned short str[2] = L" "; 9 | str[0] = c; 10 | ST->ConOut->OutputString(ST->ConOut, str); 11 | } 12 | 13 | void puts(unsigned short *s) 14 | { 15 | ST->ConOut->OutputString(ST->ConOut, s); 16 | } 17 | 18 | void puth(unsigned long long val, unsigned char num_digits) 19 | { 20 | int i; 21 | unsigned short unicode_val; 22 | unsigned short str[MAX_STR_BUF]; 23 | 24 | for (i = num_digits - 1; i >= 0; i--) { 25 | unicode_val = (unsigned short)(val & 0x0f); 26 | if (unicode_val < 0xa) 27 | str[i] = L'0' + unicode_val; 28 | else 29 | str[i] = L'A' + (unicode_val - 0xa); 30 | val >>= 4; 31 | } 32 | str[num_digits] = L'\0'; 33 | 34 | puts(str); 35 | } 36 | 37 | unsigned short getc(void) 38 | { 39 | struct EFI_INPUT_KEY key; 40 | unsigned long long waitidx; 41 | 42 | ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), 43 | &waitidx); 44 | while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key)); 45 | 46 | return (key.UnicodeChar) ? key.UnicodeChar 47 | : (key.ScanCode + SC_OFS); 48 | } 49 | 50 | unsigned int gets(unsigned short *buf, unsigned int buf_size) 51 | { 52 | unsigned int i; 53 | 54 | for (i = 0; i < buf_size - 1;) { 55 | buf[i] = getc(); 56 | putc(buf[i]); 57 | if (buf[i] == L'\r') { 58 | putc(L'\n'); 59 | break; 60 | } 61 | i++; 62 | } 63 | buf[i] = L'\0'; 64 | 65 | return i; 66 | } 67 | 68 | int strcmp(const unsigned short *s1, const unsigned short *s2) 69 | { 70 | char is_equal = 1; 71 | 72 | for (; (*s1 != L'\0') && (*s2 != L'\0'); s1++, s2++) { 73 | if (*s1 != *s2) { 74 | is_equal = 0; 75 | break; 76 | } 77 | } 78 | 79 | if (is_equal) { 80 | if (*s1 != L'\0') { 81 | return 1; 82 | } else if (*s2 != L'\0') { 83 | return -1; 84 | } else { 85 | return 0; 86 | } 87 | } else { 88 | return (int)(*s1 - *s2); 89 | } 90 | } 91 | 92 | void strncpy(unsigned short *dst, unsigned short *src, unsigned long long n) 93 | { 94 | while (n--) 95 | *dst++ = *src++; 96 | } 97 | 98 | unsigned long long strlen(unsigned short *str) 99 | { 100 | unsigned long long len = 0; 101 | 102 | while (*str++ != L'\0') 103 | len++; 104 | 105 | return len; 106 | } 107 | 108 | unsigned char check_warn_error(unsigned long long status, unsigned short *message) 109 | { 110 | if (status) { 111 | puts(message); 112 | puts(L":"); 113 | puth(status, 16); 114 | puts(L"\r\n"); 115 | } 116 | 117 | return !status; 118 | } 119 | 120 | void assert(unsigned long long status, unsigned short *message) 121 | { 122 | if (!check_warn_error(status, message)) 123 | while (1); 124 | } 125 | -------------------------------------------------------------------------------- /050_bs_malloc/shell.c: -------------------------------------------------------------------------------- 1 | #include "efi.h" 2 | #include "common.h" 3 | #include "file.h" 4 | #include "graphics.h" 5 | #include "shell.h" 6 | #include "gui.h" 7 | 8 | #define MAX_COMMAND_LEN 100 9 | #define MAX_IMG_BUF 4194304 /* 4MB */ 10 | 11 | unsigned char img_buf[MAX_IMG_BUF]; 12 | 13 | void dialogue_get_filename(int idx) 14 | { 15 | int i; 16 | 17 | ST->ConOut->ClearScreen(ST->ConOut); 18 | 19 | puts(L"New File Name: "); 20 | for (i = 0; i < MAX_FILE_NAME_LEN; i++) { 21 | file_list[idx].name[i] = getc(); 22 | if (file_list[idx].name[i] != L'\r') 23 | putc(file_list[idx].name[i]); 24 | else 25 | break; 26 | } 27 | file_list[idx].name[i] = L'\0'; 28 | } 29 | 30 | void pstat(void) 31 | { 32 | unsigned long long status; 33 | struct EFI_SIMPLE_POINTER_STATE s; 34 | unsigned long long waitidx; 35 | 36 | SPP->Reset(SPP, FALSE); 37 | 38 | while (1) { 39 | ST->BootServices->WaitForEvent(1, &(SPP->WaitForInput), 40 | &waitidx); 41 | status = SPP->GetState(SPP, &s); 42 | if (!status) { 43 | puth(s.RelativeMovementX, 8); 44 | puts(L" "); 45 | puth(s.RelativeMovementY, 8); 46 | puts(L" "); 47 | puth(s.RelativeMovementZ, 8); 48 | puts(L" "); 49 | puth(s.LeftButton, 1); 50 | puts(L" "); 51 | puth(s.RightButton, 1); 52 | puts(L"\r\n"); 53 | } 54 | } 55 | } 56 | 57 | int ls(void) 58 | { 59 | unsigned long long status; 60 | struct EFI_FILE_PROTOCOL *root; 61 | unsigned long long buf_size; 62 | unsigned char file_buf[MAX_FILE_BUF]; 63 | struct EFI_FILE_INFO *file_info; 64 | int idx = 0; 65 | int file_num; 66 | 67 | status = SFSP->OpenVolume(SFSP, &root); 68 | assert(status, L"SFSP->OpenVolume"); 69 | 70 | while (1) { 71 | buf_size = MAX_FILE_BUF; 72 | status = root->Read(root, &buf_size, (void *)file_buf); 73 | assert(status, L"root->Read"); 74 | if (!buf_size) break; 75 | 76 | file_info = (struct EFI_FILE_INFO *)file_buf; 77 | strncpy(file_list[idx].name, file_info->FileName, 78 | MAX_FILE_NAME_LEN - 1); 79 | file_list[idx].name[MAX_FILE_NAME_LEN - 1] = L'\0'; 80 | puts(file_list[idx].name); 81 | puts(L" "); 82 | 83 | idx++; 84 | } 85 | puts(L"\r\n"); 86 | file_num = idx; 87 | 88 | root->Close(root); 89 | 90 | return file_num; 91 | } 92 | 93 | void cat(unsigned short *file_name) 94 | { 95 | unsigned long long status; 96 | struct EFI_FILE_PROTOCOL *root; 97 | struct EFI_FILE_PROTOCOL *file; 98 | unsigned long long buf_size = MAX_FILE_BUF; 99 | unsigned short file_buf[MAX_FILE_BUF / 2]; 100 | 101 | status = SFSP->OpenVolume(SFSP, &root); 102 | assert(status, L"SFSP->OpenVolume"); 103 | 104 | status = root->Open(root, &file, file_name, EFI_FILE_MODE_READ, 0); 105 | assert(status, L"root->Open"); 106 | 107 | status = file->Read(file, &buf_size, (void *)file_buf); 108 | assert(status, L"file->Read"); 109 | 110 | puts(file_buf); 111 | 112 | file->Close(file); 113 | root->Close(root); 114 | } 115 | 116 | void edit(unsigned short *file_name) 117 | { 118 | unsigned long long status; 119 | struct EFI_FILE_PROTOCOL *root; 120 | struct EFI_FILE_PROTOCOL *file; 121 | unsigned long long buf_size = MAX_FILE_BUF; 122 | unsigned short file_buf[MAX_FILE_BUF / 2]; 123 | int i = 0; 124 | unsigned short ch; 125 | 126 | ST->ConOut->ClearScreen(ST->ConOut); 127 | 128 | while (TRUE) { 129 | ch = getc(); 130 | 131 | if (ch == SC_ESC) 132 | break; 133 | 134 | putc(ch); 135 | file_buf[i++] = ch; 136 | 137 | if (ch == L'\r') { 138 | putc(L'\n'); 139 | file_buf[i++] = L'\n'; 140 | } 141 | } 142 | file_buf[i] = L'\0'; 143 | 144 | status = SFSP->OpenVolume(SFSP, &root); 145 | assert(status, L"SFSP->OpenVolume"); 146 | 147 | status = root->Open(root, &file, file_name, 148 | EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | \ 149 | EFI_FILE_MODE_CREATE, 0); 150 | assert(status, L"root->Open"); 151 | 152 | status = file->Write(file, &buf_size, (void *)file_buf); 153 | assert(status, L"file->Write"); 154 | 155 | file->Flush(file); 156 | 157 | file->Close(file); 158 | root->Close(root); 159 | } 160 | 161 | void view(unsigned short *img_name) 162 | { 163 | unsigned long long buf_size = MAX_IMG_BUF; 164 | unsigned long long status; 165 | struct EFI_FILE_PROTOCOL *root; 166 | struct EFI_FILE_PROTOCOL *file; 167 | unsigned int vr = GOP->Mode->Info->VerticalResolution; 168 | unsigned int hr = GOP->Mode->Info->HorizontalResolution; 169 | 170 | status = SFSP->OpenVolume(SFSP, &root); 171 | assert(status, L"error: SFSP->OpenVolume"); 172 | 173 | status = root->Open(root, &file, img_name, EFI_FILE_MODE_READ, 174 | EFI_FILE_READ_ONLY); 175 | assert(status, L"error: root->Open"); 176 | 177 | status = file->Read(file, &buf_size, (void *)img_buf); 178 | if (check_warn_error(status, L"warning:file->Read")) 179 | blt(img_buf, hr, vr); 180 | 181 | while (getc() != SC_ESC); 182 | 183 | status = file->Close(file); 184 | status = root->Close(root); 185 | } 186 | 187 | void shell(void) 188 | { 189 | unsigned short com[MAX_COMMAND_LEN]; 190 | struct RECT r = {10, 10, 100, 200}; 191 | unsigned char is_exit = FALSE; 192 | 193 | while (!is_exit) { 194 | puts(L"poiOS> "); 195 | if (gets(com, MAX_COMMAND_LEN) <= 0) 196 | continue; 197 | 198 | if (!strcmp(L"hello", com)) 199 | puts(L"Hello UEFI!\r\n"); 200 | else if (!strcmp(L"rect", com)) 201 | draw_rect(r, white); 202 | else if (!strcmp(L"gui", com)) { 203 | gui(); 204 | ST->ConOut->ClearScreen(ST->ConOut); 205 | } else if (!strcmp(L"pstat", com)) 206 | pstat(); 207 | else if (!strcmp(L"ls", com)) 208 | ls(); 209 | else if (!strcmp(L"cat", com)) 210 | cat(L"abc"); 211 | else if (!strcmp(L"edit", com)) 212 | edit(L"abc"); 213 | else if (!strcmp(L"view", com)) { 214 | view(L"img"); 215 | ST->ConOut->ClearScreen(ST->ConOut); 216 | } else if (!strcmp(L"exit", com)) 217 | is_exit = TRUE; 218 | else 219 | puts(L"Command not found.\r\n"); 220 | } 221 | } 222 | --------------------------------------------------------------------------------