Initial support for EFI framebuffer
This commit is contained in:
parent
fb60724710
commit
9cbe2d458c
@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
|
|
||||||
/* HAL library routines forward references */
|
/* HAL library routines forward references */
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlClearScreen(VOID);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
XTSTATUS
|
XTSTATUS
|
||||||
HlComPortGetByte(IN PCPPORT Port,
|
HlComPortGetByte(IN PCPPORT Port,
|
||||||
@ -32,6 +36,12 @@ UCHAR
|
|||||||
HlComPortReadLsr(IN PCPPORT Port,
|
HlComPortReadLsr(IN PCPPORT Port,
|
||||||
IN UCHAR Byte);
|
IN UCHAR Byte);
|
||||||
|
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlDrawPixel(IN ULONG PosX,
|
||||||
|
IN ULONG PosY,
|
||||||
|
IN ULONG Color);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
XTSTATUS
|
XTSTATUS
|
||||||
HlInitializeComPort(IN OUT PCPPORT Port,
|
HlInitializeComPort(IN OUT PCPPORT Port,
|
||||||
@ -39,4 +49,8 @@ HlInitializeComPort(IN OUT PCPPORT Port,
|
|||||||
IN PUCHAR PortAddress,
|
IN PUCHAR PortAddress,
|
||||||
IN ULONG BaudRate);
|
IN ULONG BaudRate);
|
||||||
|
|
||||||
|
XTAPI
|
||||||
|
XTSTATUS
|
||||||
|
HlInitializeDisplay(VOID);
|
||||||
|
|
||||||
#endif /* __XTDK_HLFUNCS_H */
|
#endif /* __XTDK_HLFUNCS_H */
|
||||||
|
@ -98,4 +98,16 @@ typedef struct _CPPORT
|
|||||||
USHORT Flags;
|
USHORT Flags;
|
||||||
} CPPORT, *PCPPORT;
|
} CPPORT, *PCPPORT;
|
||||||
|
|
||||||
|
typedef struct _HAL_FRAMEBUFFER_DATA
|
||||||
|
{
|
||||||
|
BOOLEAN Initialized;
|
||||||
|
PULONG Address;
|
||||||
|
ULONG_PTR BufferSize;
|
||||||
|
UINT Width;
|
||||||
|
UINT Height;
|
||||||
|
UINT PixelsPerScanLine;
|
||||||
|
UINT BitsPerPixel;
|
||||||
|
UINT Pitch;
|
||||||
|
} HAL_FRAMEBUFFER_DATA, *PHAL_FRAMEBUFFER_DATA;
|
||||||
|
|
||||||
#endif /* __XTDK_HLTYPES_H */
|
#endif /* __XTDK_HLTYPES_H */
|
||||||
|
@ -9,6 +9,7 @@ include_directories(
|
|||||||
# Specify list of source code files
|
# Specify list of source code files
|
||||||
list(APPEND XTOSKRNL_SOURCE
|
list(APPEND XTOSKRNL_SOURCE
|
||||||
${XTOSKRNL_SOURCE_DIR}/hl/cport.c
|
${XTOSKRNL_SOURCE_DIR}/hl/cport.c
|
||||||
|
${XTOSKRNL_SOURCE_DIR}/hl/efifb.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/hl/${ARCH}/cpufunc.c
|
${XTOSKRNL_SOURCE_DIR}/hl/${ARCH}/cpufunc.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/ke/globals.c
|
${XTOSKRNL_SOURCE_DIR}/ke/globals.c
|
||||||
${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c
|
${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c
|
||||||
|
118
xtoskrnl/hl/efifb.c
Normal file
118
xtoskrnl/hl/efifb.c
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/**
|
||||||
|
* PROJECT: ExectOS
|
||||||
|
* COPYRIGHT: See COPYING.md in the top level directory
|
||||||
|
* FILE: xtoskrnl/hl/efifb.c
|
||||||
|
* DESCRIPTION: EFI framebuffer support
|
||||||
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xtos.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the screen by drawing a filled black box.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlClearScreen(VOID)
|
||||||
|
{
|
||||||
|
SIZE_T PositionX, PositionY;
|
||||||
|
|
||||||
|
/* Fill the screen with a black box */
|
||||||
|
for(PositionX = 0; PositionX < HlpFrameBufferData.Width; PositionX++)
|
||||||
|
{
|
||||||
|
for(PositionY = 0; PositionY < HlpFrameBufferData.Height; PositionY++)
|
||||||
|
{
|
||||||
|
HlDrawPixel(PositionX, PositionY, 0x00000000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a pixel on the screen at the given position and color.
|
||||||
|
*
|
||||||
|
* @param PositionX
|
||||||
|
* Supplies the X coordinate of the pixel.
|
||||||
|
*
|
||||||
|
* @param PositionY
|
||||||
|
* Supplies the Y coordinate of the pixel.
|
||||||
|
*
|
||||||
|
* @param Color
|
||||||
|
* Specifies the color of the pixel.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlDrawPixel(IN ULONG PositionX,
|
||||||
|
IN ULONG PositionY,
|
||||||
|
IN ULONG Color)
|
||||||
|
{
|
||||||
|
/* Make sure frame buffer is already initialized */
|
||||||
|
if(HlpFrameBufferData.Initialized == FALSE)
|
||||||
|
{
|
||||||
|
/* Unable to operate on non-initialized frame buffer */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure point is not offscreen */
|
||||||
|
if(PositionX >= HlpFrameBufferData.Width || PositionY >= HlpFrameBufferData.Height || Color > 0xFFFFFFFF)
|
||||||
|
{
|
||||||
|
/* Invalid pixel position or color given */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate the index of the pixel in the frame buffer memory using the provided x and y coordinates */
|
||||||
|
SIZE_T FrameBufferIndex = PositionY * HlpFrameBufferData.PixelsPerScanLine + PositionX;
|
||||||
|
|
||||||
|
/* Set the color of the pixel by writing to the corresponding memory location */
|
||||||
|
HlpFrameBufferData.Address[FrameBufferIndex] = Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes frame buffer display.
|
||||||
|
*
|
||||||
|
* @return This routine returns a status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
XTSTATUS
|
||||||
|
HlInitializeDisplay(VOID)
|
||||||
|
{
|
||||||
|
/* Check if display already initialized */
|
||||||
|
if(HlpFrameBufferData.Initialized)
|
||||||
|
{
|
||||||
|
/* Nothing to do */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if framebuffer initialized by bootloader */
|
||||||
|
if(!KeInitializationBlock->LoaderInformation.FrameBuffer.Initialized ||
|
||||||
|
!KeInitializationBlock->LoaderInformation.FrameBuffer.Address)
|
||||||
|
{
|
||||||
|
/* Display not initialized */
|
||||||
|
return STATUS_DEVICE_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save framebuffer information and mark display as initialized */
|
||||||
|
HlpFrameBufferData.Address = (PULONG)KeInitializationBlock->LoaderInformation.FrameBuffer.Address;
|
||||||
|
HlpFrameBufferData.Width = KeInitializationBlock->LoaderInformation.FrameBuffer.Width;
|
||||||
|
HlpFrameBufferData.Height = KeInitializationBlock->LoaderInformation.FrameBuffer.Height;
|
||||||
|
HlpFrameBufferData.BitsPerPixel = KeInitializationBlock->LoaderInformation.FrameBuffer.BitsPerPixel;
|
||||||
|
HlpFrameBufferData.PixelsPerScanLine = KeInitializationBlock->LoaderInformation.FrameBuffer.PixelsPerScanLine;
|
||||||
|
HlpFrameBufferData.Pitch = KeInitializationBlock->LoaderInformation.FrameBuffer.Pitch;
|
||||||
|
HlpFrameBufferData.Initialized = TRUE;
|
||||||
|
|
||||||
|
/* Clear screen */
|
||||||
|
HlClearScreen();
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
@ -12,6 +12,9 @@
|
|||||||
#include <xtos.h>
|
#include <xtos.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FrameBuffer information */
|
||||||
|
EXTERN HAL_FRAMEBUFFER_DATA HlpFrameBufferData;
|
||||||
|
|
||||||
/* Kernel initialization block passed by boot loader */
|
/* Kernel initialization block passed by boot loader */
|
||||||
EXTERN PKERNEL_INITIALIZATION_BLOCK KeInitializationBlock;
|
EXTERN PKERNEL_INITIALIZATION_BLOCK KeInitializationBlock;
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
#include <xtos.h>
|
#include <xtos.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FrameBuffer information */
|
||||||
|
HAL_FRAMEBUFFER_DATA HlpFrameBufferData;
|
||||||
|
|
||||||
/* Kernel initialization block passed by boot loader */
|
/* Kernel initialization block passed by boot loader */
|
||||||
PKERNEL_INITIALIZATION_BLOCK KeInitializationBlock;
|
PKERNEL_INITIALIZATION_BLOCK KeInitializationBlock;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user