1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #include "text_protocol.h" 19 #include <stdio.h> 20 output_string(struct EfiSimpleTextOutputProtocol * self,char16_t * string)21EfiStatus output_string(struct EfiSimpleTextOutputProtocol *self, 22 char16_t *string) { 23 char buffer[512]; 24 size_t i = 0; 25 while (string[i]) { 26 size_t j = 0; 27 for (j = 0; j < sizeof(buffer) - 1 && string[i + j]; j++) { 28 buffer[j] = string[i + j]; 29 } 30 i += j; 31 buffer[j] = 0; 32 33 printf("%s", reinterpret_cast<const char *>(buffer)); 34 } 35 return SUCCESS; 36 } 37 get_text_output_protocol()38EfiSimpleTextOutputProtocol get_text_output_protocol() { 39 EfiSimpleTextOutputProtocol console_out; 40 console_out.output_string = output_string; 41 return console_out; 42 }