kernel
Loading...
Searching...
No Matches
mg.h
Go to the documentation of this file.
1#ifndef X86_MATANEL_GRAPHICAL_H
2#define X86_MATANEL_GRAPHICAL_H
3
4/*++
5
6Module Name:
7
8 mg.h
9
10Purpose:
11
12 This module contains the header files & prototypes required for graphical interfaces. - Note that this only contains a very basic driver, advanced drivers should be loaded dynamically.
13
14Author:
15
16 slep (Matanel) 2025.
17
18Revision History:
19
20--*/
21
22
23#include <stdint.h>
24#include <stdbool.h>
25#include "stdarg_myos.h"
26#include "efi.h"
27#include "behavior.h"
28
30#define COLOR_RED 0xFFFF0000
31#define COLOR_GREEN 0xFF00FF00
32#define COLOR_BLUE 0xFF0000FF
33#define COLOR_WHITE 0xFFFFFFFF
34#define COLOR_BLACK 0xFF000000
35#define COLOR_YELLOW 0xFFFFFF00
36#define COLOR_CYAN 0xFF00FFFF
37#define COLOR_MAGENTA 0xFFFF00FF
38#define COLOR_GRAY 0xFF808080
39#define COLOR_DARK_GRAY 0xFF404040
40#define COLOR_LIGHT_GRAY 0xFFD3D3D3
41#define COLOR_ORANGE 0xFFFFA500
42#define COLOR_BROWN 0xFFA52A2A
43#define COLOR_PURPLE 0xFF800080
44#define COLOR_PINK 0xFFFFC0CB
45#define COLOR_LIME 0xFF32CD32
46#define COLOR_NAVY 0xFF000080
47#define COLOR_TEAL 0xFF008080
48#define COLOR_OLIVE 0xFF808000
49
50/*
51void __attribute__((format(printf, 2, 3)))
52gop_printf(uint32_t color, const char* fmt, ...);
53*/
54
55#ifdef DISABLE_GOP
56static inline void __gop_mark_used(void* dummy, ...) {
57 (void)dummy; /* silence unused-param warning for the first arg */
58}
59
60/* no-op gop_printf that still marks variables as used */
61#define gop_printf(color, fmt, ...) \
62 do { \
63 (void)(color); \
64 (void)(fmt); \
65 __gop_mark_used(NULL, ##__VA_ARGS__); \
66 } while (0)
67#else
68void __attribute__((format(printf, 2, 3)))
69gop_printf(uint32_t color, const char* fmt, ...);
70#endif
71
72
73void gop_clear_screen(GOP_PARAMS* gop, uint32_t color);
74
75
76int ksnprintf(char* buf, size_t bufsize, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
77int kstrcmp(const char* s1, const char* s2);
78int kstrncmp(const char* s1, const char* s2, size_t length);
79size_t kstrlen(const char* str);
80char* kstrcpy(char* dst, const char* src);
81// Gurantees null termination.
82char* kstrncpy(char* dst, const char* src, size_t n);
83char* kstrtok_r(char* str, const char* delim, char** save_ptr);
84char* kstrncat(char* dest, const char* src, size_t max_len);
85
86static
87void*
88kmemchr(const void* buf, int c, size_t n)
89{
90 const unsigned char* p = (const unsigned char*)buf;
91 unsigned char uc = (unsigned char)c;
92
93 for (size_t i = 0; i < n; ++i) {
94 if (p[i] == uc) {
95 return (void*)(p + i);
96 }
97 }
98 return NULL;
99}
100
101
104
105#endif
struct _GOP_PARAMS GOP_PARAMS
char * kstrncat(char *dest, const char *src, size_t max_len)
Concatenates src onto dest, up to max_len total bytes in dest.
Definition gop.c:314
size_t kstrlen(const char *str)
Definition gop.c:342
void gop_printf(uint32_t color, const char *fmt,...)
Definition gop.c:633
char * kstrtok_r(char *str, const char *delim, char **save_ptr)
Definition gop.c:440
char * kstrcpy(char *dst, const char *src)
Definition gop.c:353
char * kstrncpy(char *dst, const char *src, size_t n)
Definition gop.c:365
int kstrncmp(const char *s1, const char *s2, size_t length)
Definition gop.c:602
int kstrcmp(const char *s1, const char *s2)
Definition gop.c:593
void MgAcquireExclusiveGopOwnerShip(void)
Definition gop.c:726
int ksnprintf(char *buf, size_t bufsize, const char *fmt,...) __attribute__((format(printf
void MgReleaseExclusiveGopOwnerShip(void)
Definition gop.c:738
void const char * fmt
Definition mg.h:69
void const char void gop_clear_screen(GOP_PARAMS *gop, uint32_t color)
Definition gop.c:225
typedef __attribute__
Definition fat32.h:64