File indexing completed on 2025-05-11 08:24:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include <bsp.h>
0037
0038 #include <efi.h>
0039 #include <efilib.h>
0040
0041 #include <rtems/bspIo.h>
0042
0043 #include <efistop.h>
0044
0045 #include <stdio.h>
0046 #include <string.h>
0047
0048 #ifdef BSP_USE_EFI_BOOT_SERVICES
0049
0050 static void
0051 print_stop_info(SIMPLE_TEXT_OUTPUT_INTERFACE* stop);
0052
0053 void
0054 efi_init_text_output(int hint)
0055 {
0056 int maxval = ST->ConOut->Mode->MaxMode - 1;
0057 int curval = ST->ConOut->Mode->Mode;
0058 ST->ConOut->Reset(ST->ConOut, true);
0059 if (hint != -1) {
0060
0061 ST->ConOut->SetMode(ST->ConOut, hint);
0062 }
0063 else if (strcmp(BSP_EFI_SIMPLE_TEXT_OUTPUT_MODE_VALUE, "MAX") == 0) {
0064 ST->ConOut->SetMode(ST->ConOut, maxval);
0065 }
0066 else if (strcmp(BSP_EFI_SIMPLE_TEXT_OUTPUT_MODE_VALUE, "AUTO") == 0) {
0067 ST->ConOut->SetMode(ST->ConOut, curval);
0068 }
0069 else {
0070 ST->ConOut->SetMode(ST->ConOut, atoi(BSP_EFI_SIMPLE_TEXT_OUTPUT_MODE_VALUE));
0071 }
0072 ST->ConOut->EnableCursor(ST->ConOut, TRUE);
0073 print_stop_info(ST->ConOut);
0074 ST->ConOut->ClearScreen(ST->ConOut);
0075 }
0076
0077 void
0078 efi_text_output_char(char c)
0079 {
0080 EFI_STATUS status;
0081 char tocpy[2];
0082 tocpy[0] = c;
0083 tocpy[1] = 0;
0084 CHAR16 str[2];
0085 cpy8to16(tocpy, str, 2);
0086 status = ST->ConOut->TestString(ST->ConOut, str);
0087 if (EFI_ERROR(status))
0088 str[0] = '?';
0089 ST->ConOut->OutputString(ST->ConOut, str);
0090 }
0091
0092 static void
0093 print_stop_info(SIMPLE_TEXT_OUTPUT_INTERFACE* stop)
0094 {
0095 EFI_STATUS status;
0096 int max_mode = stop->Mode->MaxMode;
0097 int current_mode = stop->Mode->Mode;
0098 printf("RTEMS: text output: current mode: %d, max mode: %d\n", current_mode, (max_mode - 1));
0099 UINTN columns = 0;
0100 UINTN rows = 0;
0101 for (int i = 0; i < max_mode; i++) {
0102 if (current_mode == i)
0103 printf(" -> ");
0104 else
0105 printf(" ");
0106 status = stop->QueryMode(stop, i, &columns, &rows);
0107 if (EFI_ERROR(status))
0108 printf("%d. mode: error: can't obtain column x row values.\n", i);
0109 else {
0110 printf("%d. mode: %ld * %ld\n", i, columns, rows);
0111 }
0112 }
0113 }
0114
0115 #endif