diff options
| author | Aleksa Vuckovic <aleksav013@gmail.com> | 2022-08-03 21:28:15 +0200 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksav013@gmail.com> | 2022-08-03 21:28:15 +0200 |
| commit | d4349352a57eb00ce411b4c0542d3207357aecbe (patch) | |
| tree | 5bf1883ce59cfefedb2e8873e203b381cb7573f3 /include | |
| parent | c0a8113ba0b7cd6984cc685ec63f79bef3bc9899 (diff) | |
drawing lines to fb
Diffstat (limited to 'include')
| -rw-r--r-- | include/debug.h | 11 | ||||
| -rw-r--r-- | include/graphics.h | 32 | ||||
| -rw-r--r-- | include/multiboot2.h | 40 |
3 files changed, 83 insertions, 0 deletions
diff --git a/include/debug.h b/include/debug.h new file mode 100644 index 0000000..1c53148 --- /dev/null +++ b/include/debug.h @@ -0,0 +1,11 @@ +#ifndef DEBUG_H +#define DEBUG_H + +#include <stdint.h> + +void bochs_breakpoint(void); +void put_in_r8(uint64_t value); +void put_in_r9(uint64_t value); +void put_in_r10(uint64_t value); + +#endif diff --git a/include/graphics.h b/include/graphics.h new file mode 100644 index 0000000..d00e8d8 --- /dev/null +++ b/include/graphics.h @@ -0,0 +1,32 @@ +#ifndef GRAPHICS_H +#define GRAPHICS_H + +#include <stdint.h> + +struct fb_t { + uint64_t addr; + uint32_t pitch; + uint32_t width; + uint32_t height; + uint8_t bpp; + uint8_t type; +} __attribute__((packed, aligned(8))); +typedef struct fb_t fb_t; + +extern fb_t fb; + +#define RED 0x00ff0000 +#define GREEN 0x0000ff00 +#define BLUE 0x000000ff +#define YELLOW 0x00ffff00 +#define PURPLE 0x00ff00ff +#define WHITE 0x00ffffff +#define BLACK 0x00000000 + +uint64_t* pixel_offset(fb_t fb, uint32_t x, uint32_t y); +void fb_draw_pixel(fb_t fb, uint32_t x, uint32_t y, uint32_t col); +void fb_draw_line_low(fb_t fb, uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, uint32_t col); +void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t col); +void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t col); + +#endif diff --git a/include/multiboot2.h b/include/multiboot2.h new file mode 100644 index 0000000..f22fd8e --- /dev/null +++ b/include/multiboot2.h @@ -0,0 +1,40 @@ +#ifndef MULTIBOOT2_H +#define MULTIBOOT2_H + +#include <stdint.h> + +struct mb2_tag_header { + uint32_t type; + uint32_t size; +} __attribute__((packed, aligned(8))); +typedef struct mb2_tag_header mb2_tag_header; + +struct mb2_tag_fb { + uint32_t type; + uint32_t size; + uint64_t framebuffer_addr; + uint32_t framebuffer_pitch; + uint32_t framebuffer_width; + uint32_t framebuffer_height; + uint8_t framebuffer_bpp; + uint8_t framebuffer_type; +} __attribute__((packed, aligned(8))); +typedef struct mb2_tag_fb mb2_tag_fb; + +// multiboot2 magic check +#define MB2_MAGIC 0x36D76289 + +// multiboot2 tag +#define MB2_TAG_END 0 +#define MB2_TAG_CMDLINE 1 +#define MB2_TAG_BOOTLOADER 2 +#define MB2_TAG_MODULES 3 +#define MB2_TAG_MEM 4 +#define MB2_TAG_BIOS 5 +#define MB2_TAG_MMAP 6 +#define MB2_TAG_VBE 7 +#define MB2_TAG_FB 8 + +void init_fb(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic); + +#endif |
