#include #include #include #define SD_WIDTH 720 #define SD_HEIGHT 480 #define HD_WIDTH 1280 #define HD_HEIGHT 720 #define FULL_HD_WIDTH 1920 #define FULL_HD_HEIGHT 1080 #define QHD_WIDTH 2560 #define QHD_HEIGHT 1440 #define FULL_HD_PLUS_WIDTH 2280 #define FULL_HD_PLUS_HEIGHT 1080 #define HD_PLUS_WIDTH 1600 #define HD_PLUS_HEIGHT 720 #define BLACK_COLOR 0x000000 #define WHITE_COLOR 0xFFFFFF #define RED_COLOR 0xFF0000 #define GREEN_COLOR 0x00FF00 #define BLUE_COLOR 0x0000FF void kernel_main(void){ struct memory_video video_memory; struct video_card card; //black pixel for video // pixel preto para o vídeo video_memory.black = 0x0000000; //white pixel for video // pixel branco para o vídeo video_memory.white = 0xFFFFFF; //red pixel for video // pixel vermelho para o vídeo video_memory.red = 0xFF0000; //green pixel for video // pixel verde para o vídeo video_memory.green = 0x00FF00; //blue pixel for video // pixel azul para o vídeo video_memory.blue = 0x0000FF; //video card of width for video width management //cartão de largura do vídeo para o gerenciamento de largura vídeo card.width = FULL_HD_PLUS_WIDTH; //video card of height for video height managemente //cartão de altura do vídeo para o gerenciamento de altura do vídeo card.height = FULL_HD_PLUS_HEIGHT; //black card for black pixel management //cartão preto para o gerenciamento do pixel preto card.black = 0x000000; //white card for white pixel management //cartão branco para o gerenciamento do pixel branco card.white = 0xFFFFFF; //red card for red pixel management //cartão vermelho para o gerenciamento do pixel vermelho card.red = 0xFF0000; //green card for green pixel management //cartão verde para o gerenciamento do pixel verde card.green = 0x00FF00; //blue card for blue pixel management //cartão azul para o gerenciamento do pixel azul card.blue = 0x0000FF; //put_pixel for black card from the hardware //put_pixel para o cartão preto do hardware put_pixel(card.black, 10, 20); //put_pixel for white card from the hardware //put_pixel para o cartão branco do hardware put_pixel(card.white, 11, 20); //put_pixel for red card from the hardware //put_pixel para o cartão vermelho do hardware put_pixel(card.red, 12, 20); //put_pixel for green card from the hardware //put_pixel para o cartão verde do hardware put_pixel(card.green, 13, 20); //put-pixel for blue card from the hardware //put_pixel para o cartão azul do hardware put_pixel(card.blue, 14, 20); //resolutiom card for pixel management of 1920x1080 //cartão de resolução para o gerenciamento do pixel de 1920x1080 card_resolution.one = 1080; //resolution card for pixel management of 2560x1440 //cartão de resolução para o gerenciamento de pixel de 2560x1440 card_resolution.two = 1440; //resolition card for pixel management of 1280x720 //cartão de resolução para o gerenciamento de pixel de 1280x720 card_resolution.three = 720; //resolution card for pixel management of 720x480 //cartão de resolução para o gerenciamento de pixel de 720x480 card_resolution.four = 480; } void put_pixel(uint32_t color, uint32_t x, uint32_t y){ if (x >= WIDTH || y >= HEIGHT){ return; } uint32_t offset = (y * WIDTH) + x; framebuffer[offset] = color; } struct video_card{ //width card // cartão de largura uint32_t card_width; //height card // cartão de altura uint32_t card_height; //black card // cartão preto uint32_t card_black; //white card // cartão branco uint32_t card_white; //red card // cartão vermelho uint32_t card_red; //green card // cartão verde uint32_t card_green; //blue card // cartão azul uint32_t card_blue; } struct video_memory_color{ //black color // cor preta uint32_t black; //white color // cor branca uint32_t white; //red color // cor vermelha uint32_t red; //green color // cor verde uint32_t green; //blue color // cor azul uint32_t blue; } struct video_resolution_card{ //resolution card for full HD // cartão de resolução para o full HD uint32_t card_resolution_one; //resolution card for quad HD // cartão de resolução para o quad HD uint32_t card_resolution_two; //resolution card for High Definition // cartão de resolução para alta definição uint32_t card_resolution_three; //resolution card for standard definition // cartão de resolução para a definição padrão uint32_t card_resolution_four; } typedef struct { UINT32 MaxMode; UINT32 Mode; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode; UINTN SizeOfInfo; EFI_PHYSICAL_ADDRESS FrameBufferBase; UINTN FrameBufferSize; }EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE; void TextForNumber(){ } if (gop NULL || gop->Mode NULL || gop->Mode->Info NULL){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0C); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"ERROR"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Gop Not Inicialized"); } else{ UINT32 witdh = gop->Mode->Info->HorizontalResolution; UINT32 height = gop->Mode->Info->VerticalResolution; if (width = 2560 && height = 1440){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS") SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Quad HD Resolution of 2560x1440 Idetified"); }else if (width = 1920 && height = 1080){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Full HD Resolution of 1920x1080 identified"); }else if (width = 2280 && height = 1080){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Full HD+ Resolution of 2280x1080 identified"); }else if (width = 1280 && height = 720){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::High Definition Resulution of 1280x720 identified"); }else if (width = 1600 && height = 720){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::High Definition Plus Resolution of 1600x720 identified"); }else if (width = 720 && height 480){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0E); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"BELOW_SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Standard Definition Resolution of 720x480 identified"); }else{ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0C); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"ERROR"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Unknown Resolution"); } } if (gop = NULL && gop->Mode = NULL && gop->Mode->Info = NULL){ EFI_GRAPHICS_PIXEL_FORMAT format = gop->Mode->Info->PixelFormat; if (format = PixelRedGreenBlueReserved8BitPerColor) { SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::High Quality of Color Identified"); }else if (format = PixelRedGreenBlueReserved8BitPerColor){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0A); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"SUCCESS"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::High Quality Color of 32 Bytes Identified"); }else if (format = PixelBitMask){ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0E); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"\t\t\t\t--------WARNING--------"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"\t\t\t\tAchieving This Level of Color qualitity requires bit-level decoding; without it, the color quality would suffer."); }else{ SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0C); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"ERROR"); SystemTable->ConOut->OutputString(SystemTable->ConOut, 0x0F); SystemTable->ConOut->OutputString(SystemTable->ConOut, L"::Unknown Color Quality"); } } EFI_PHYSICAL_ADDRESS vram = gop->Mode->FrameBufferBase; UINTN vram_size = gop->Mode->FrameBufferSize; memset((void*)vram, 0x00, vram_size); UINTN pixel_of_offset = (x * (y + height)) * 4; if (pixel_of_offset >= gop->Mode->FrameBufferSize){ }else{ volatile uint32_t* pixel_ptr = (uint32_t*)(gop->Mode->FrameBufferBase + pixel_of_offset); *pixel_ptr = 0x00FF0000; } UINTN memory_size = video_card->Mode->FrameBufferSize; EFI_PHYSICAL_ADDRESS memory_base = video_card->Mode->FrameBufferBase; typedef struct { UINT8 Red; UINT8 Green; UINT8 Blue; UINT8 Reserved; }EFI_GRAPHICS_OUTPUT_BLT_PIXEL; EFI_GRAPHICS_OUTPUT_BLT_PIXEL RedColor = {.Red = 255, .Green = 0, Blue = 0, .Reserved = 0}; EFI_GRAPHICS_OUTPUT_BLT_PIXEL GreenColor = {.Red = 0, .Green = 255, Blue = 0, .Reserved = 0}; EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlueColor = {.Red = 0, .Green = 0, .Blue = 255, .Reserved = 0}; EFI_GRAPHICS_OUTPUT_BLT_PIXEL BlackColor = {.Red = 0, .Green = 0, .Blue = 0, .Reserved = 0}; EFI_GRAPHICS_OUTPUT_BLT_PIXEL WhiteColor = {.Red = 255, .Green = 255, .Blue = 255, .Reserved = 0}; void pixel_art(UINTN x, UINTN y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color){ UINT32 width = video_card->Mode->Info->HorizontalResolution; UINT32 height = video_card->Mode->Info->VerticalResolution; EFI_PHYSICAL_ADDRESS vram_base = video_card->Mode->FrameBufferBase; UINTN offset = (x + (y * width)) * 4; if (offset >= video_card->Mode->Info->PixelFormat == PixelRedGreenBlue8BitPerPixel){ return; } if (video_card->Mode->Info->PixelFormat == PixelRedGreenBlue8BitPerColor){ UINT8 *target_pixel = (UINT8*)(vram_base + offset); target_pixel[0] = color.red; target_pixel[1] = color.green; target_pixel[2] = color.blue; target_pixel[3] = color.reserved; }else if (video_card->Mode->Info->PixelFormat == PixelRedGreenBlue8BitPerColor){ UINT8 *target_pixel = (UINT8*)(vram_base + offset); target_pixel[0] = color.red; target_pixel[1] = color.green; target_pixel[2] = color.blue; target_pixel[3] = color.reserved; } }