aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/graphics
diff options
context:
space:
mode:
authorMarvin Borner2020-05-06 19:04:05 +0200
committerMarvin Borner2020-05-06 19:04:05 +0200
commitd94ffac4a584dc7a4f6f2ec567b8caab05ce9253 (patch)
tree559cd596a0a407d4b40c1d12d3c6a0686494da16 /src/kernel/graphics
parent1a8563a05608b5b5e27eada44cf4790926001c68 (diff)
New build parameters and shared includes
This changes many files but I've just applied some replace commands.. So - nothing special!
Diffstat (limited to 'src/kernel/graphics')
-rw-r--r--src/kernel/graphics/vesa.c74
-rw-r--r--src/kernel/graphics/vesa.h114
2 files changed, 91 insertions, 97 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index cf31d76..176b46f 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -1,10 +1,10 @@
-#include <kernel/graphics/vesa.h>
-#include <kernel/fs/load.h>
-#include <kernel/system.h>
-#include <kernel/lib/stdlib.h>
-#include <kernel/lib/stdio.h>
-#include <kernel/memory/alloc.h>
-#include <kernel/memory/paging.h>
+#include <graphics/vesa.h>
+#include <fs/load.h>
+#include <system.h>
+#include <lib/stdlib.h>
+#include <lib/stdio.h>
+#include <memory/alloc.h>
+#include <memory/paging.h>
void vbe_error()
{
@@ -25,7 +25,7 @@ void vbe_set_mode(unsigned short mode)
vbe_error();
}
-uint16_t *vbe_get_modes()
+u16 *vbe_get_modes()
{
char *info_address = (char *)0x7E00;
strcpy(info_address, "VBE2");
@@ -44,19 +44,19 @@ uint16_t *vbe_get_modes()
vbe_error();
// Get number of modes
- uint16_t *mode_ptr = (uint16_t *)info->video_modes;
- size_t number_modes = 1;
- for (uint16_t *p = mode_ptr; *p != 0xFFFF; p++)
+ u16 *mode_ptr = (u16 *)info->video_modes;
+ u32 number_modes = 1;
+ for (u16 *p = mode_ptr; *p != 0xFFFF; p++)
number_modes++;
- uint16_t *ret = (uint16_t *)kmalloc(sizeof(uint16_t) * number_modes);
- for (size_t i = 0; i < number_modes; i++)
- ret[i] = ((uint16_t *)info->video_modes)[i];
+ u16 *ret = (u16 *)kmalloc(sizeof(u16) * number_modes);
+ for (u32 i = 0; i < number_modes; i++)
+ ret[i] = ((u16 *)info->video_modes)[i];
return ret;
}
-struct vbe_mode_info *vbe_get_mode_info(uint16_t mode)
+struct vbe_mode_info *vbe_get_mode_info(u16 mode)
{
regs16_t regs;
regs.ax = 0x4F01;
@@ -81,21 +81,15 @@ struct vbe_mode_info *vbe_get_mode_info(uint16_t mode)
return ret;
}
-uint32_t fb_write(struct fs_node *node, uint32_t offset, uint32_t size, uint8_t *buffer)
-{
- log("FB WRITE!");
- return 0;
-}
-
void set_optimal_resolution()
{
log("Switching to graphics mode");
log("Trying to detect available modes");
- uint16_t *video_modes = vbe_get_modes();
+ u16 *video_modes = vbe_get_modes();
- uint16_t highest = 0;
+ u16 highest = 0;
- for (uint16_t *mode = video_modes; *mode != 0xFFFF; mode++) {
+ for (u16 *mode = video_modes; *mode != 0xFFFF; mode++) {
struct vbe_mode_info *mode_info = vbe_get_mode_info(*mode);
if (mode_info == 0 || (mode_info->attributes & 0x90) != 0x90 ||
@@ -141,8 +135,8 @@ void set_optimal_resolution()
271, 270, 269, // 320x200
};
- for (size_t i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) {
- mode_info = vbe_get_mode_info((uint16_t)modes[i]);
+ for (u32 i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) {
+ mode_info = vbe_get_mode_info((u16)modes[i]);
if (mode_info == 0 || (mode_info->attributes & 0x90) != 0x90 ||
(mode_info->memory_model != 4 && mode_info->memory_model != 6)) {
kfree(mode_info);
@@ -151,7 +145,7 @@ void set_optimal_resolution()
if ((mode_info->width > vbe_width ||
(mode_info->width == vbe_width && (mode_info->bpp >> 3) > vbe_bpl))) {
- highest = (uint16_t)modes[i];
+ highest = (u16)modes[i];
vbe_width = mode_info->width;
vbe_height = mode_info->height;
vbe_pitch = mode_info->pitch;
@@ -170,10 +164,10 @@ void set_optimal_resolution()
vbe_set_mode(highest);
- uint32_t fb_size = vbe_width * vbe_height * vbe_bpl;
+ u32 fb_size = vbe_width * vbe_height * vbe_bpl;
/* cursor_buffer = kmalloc(fb_size); */
- for (uint32_t z = 0; z < fb_size; z += PAGE_S) {
- paging_map_user(paging_root_directory, (uint32_t)fb + z, (uint32_t)fb + z);
+ for (u32 z = 0; z < fb_size; z += PAGE_S) {
+ paging_map_user(paging_root_directory, (u32)fb + z, (u32)fb + z);
}
/* dev_make("fb", NULL, (write)fb_write); */
@@ -200,12 +194,12 @@ void set_optimal_resolution()
log("Using mode: (0x%x) %dx%dx%d", highest, vbe_width, vbe_height, vbe_bpl << 3);
}
-const uint32_t default_text_color = vesa_white;
-const uint32_t default_background_color = vesa_black;
-uint32_t terminal_color[3] = { 0xab, 0xb2, 0xbf };
-uint32_t terminal_background[3] = { 0x1d, 0x1f, 0x24 };
-uint16_t terminal_x = 0;
-uint16_t terminal_y = 0;
+const u32 default_text_color = vesa_white;
+const u32 default_background_color = vesa_black;
+u32 terminal_color[3] = { 0xab, 0xb2, 0xbf };
+u32 terminal_background[3] = { 0x1d, 0x1f, 0x24 };
+u16 terminal_x = 0;
+u16 terminal_y = 0;
int font_width;
int font_height;
@@ -215,16 +209,16 @@ void vesa_set_font(int height)
font_height = height;
}
-void vesa_set_pixel(uint16_t x, uint16_t y, const uint32_t color[3])
+void vesa_set_pixel(u16 x, u16 y, const u32 color[3])
{
- uint8_t pos = (uint8_t)(x * vbe_bpl + y * vbe_pitch);
+ u8 pos = (u8)(x * vbe_bpl + y * vbe_pitch);
char *draw = (char *)&fb[pos];
draw[pos] = (char)color[2];
draw[pos + 1] = (char)color[1];
draw[pos + 2] = (char)color[0];
}
-void vesa_draw_rectangle(int x1, int y1, int x2, int y2, const uint32_t color[3])
+void vesa_draw_rectangle(int x1, int y1, int x2, int y2, const u32 color[3])
{
int pos1 = x1 * vbe_bpl + y1 * vbe_pitch;
char *draw = (char *)&fb[pos1];
@@ -251,7 +245,7 @@ void vesa_draw_char(char ch)
if (ch >= ' ') {
int pos = terminal_x * vbe_bpl + terminal_y * vbe_pitch;
char *draw = (char *)&fb[pos];
- uint16_t bitmap = 0;
+ u16 bitmap = 0;
for (int cy = 0; cy <= font_height; cy++) {
if (font_height == 16)
diff --git a/src/kernel/graphics/vesa.h b/src/kernel/graphics/vesa.h
index cdbd45a..c557e95 100644
--- a/src/kernel/graphics/vesa.h
+++ b/src/kernel/graphics/vesa.h
@@ -2,7 +2,7 @@
#define MELVIX_VESA_H
#include <stdint.h>
-#include <kernel/system.h>
+#include <system.h>
/**
* The CPUs response to the 0x4F00 call
@@ -10,15 +10,15 @@
*/
struct vbe_info {
char signature[4];
- uint16_t version;
- uint32_t oem;
- uint32_t capabilities;
- uint32_t video_modes;
- uint16_t video_memory;
- uint16_t software_rev;
- uint32_t vendor;
- uint32_t product_name;
- uint32_t product_rev;
+ u16 version;
+ u32 oem;
+ u32 capabilities;
+ u32 video_modes;
+ u16 video_memory;
+ u16 software_rev;
+ u32 vendor;
+ u32 product_name;
+ u32 product_rev;
char reserved[222];
char oem_data[256];
} __attribute__((packed));
@@ -28,51 +28,51 @@ struct vbe_info {
* Used to get information about a specific video mode code
*/
struct vbe_mode_info_all {
- uint16_t attributes;
- uint8_t window_a;
- uint8_t window_b;
- uint16_t granularity;
- uint16_t window_size;
- uint16_t segment_a;
- uint16_t segment_b;
- uint32_t win_func_ptr;
- uint16_t pitch;
- uint16_t width;
- uint16_t height;
- uint8_t w_char;
- uint8_t y_char;
- uint8_t planes;
- uint8_t bpp;
- uint8_t banks;
- uint8_t memory_model;
- uint8_t bank_size;
- uint8_t image_pages;
- uint8_t reserved0;
-
- uint8_t red_mask;
- uint8_t red_position;
- uint8_t green_mask;
- uint8_t green_position;
- uint8_t blue_mask;
- uint8_t blue_position;
- uint8_t reserved_mask;
- uint8_t reserved_position;
- uint8_t direct_color_attributes;
-
- uint32_t framebuffer;
- uint32_t off_screen_mem_off;
- uint16_t off_screen_mem_size;
- uint8_t reserved1[206];
+ u16 attributes;
+ u8 window_a;
+ u8 window_b;
+ u16 granularity;
+ u16 window_size;
+ u16 segment_a;
+ u16 segment_b;
+ u32 win_func_ptr;
+ u16 pitch;
+ u16 width;
+ u16 height;
+ u8 w_char;
+ u8 y_char;
+ u8 planes;
+ u8 bpp;
+ u8 banks;
+ u8 memory_model;
+ u8 bank_size;
+ u8 image_pages;
+ u8 reserved0;
+
+ u8 red_mask;
+ u8 red_position;
+ u8 green_mask;
+ u8 green_position;
+ u8 blue_mask;
+ u8 blue_position;
+ u8 reserved_mask;
+ u8 reserved_position;
+ u8 direct_color_attributes;
+
+ u32 framebuffer;
+ u32 off_screen_mem_off;
+ u16 off_screen_mem_size;
+ u8 reserved1[206];
} __attribute__((packed));
struct vbe_mode_info {
- uint16_t attributes;
- uint16_t pitch;
- uint16_t width;
- uint16_t height;
- uint8_t bpp;
- uint8_t memory_model;
- uint32_t framebuffer;
+ u16 attributes;
+ u16 pitch;
+ u16 width;
+ u16 height;
+ u8 bpp;
+ u8 memory_model;
+ u32 framebuffer;
} __attribute__((packed));
/**
@@ -129,7 +129,7 @@ void vesa_draw_cursor(int x, int y);
* Sets the color using a rgb number
* @param color The color
*/
-void vesa_set_color(uint32_t color);
+void vesa_set_color(u32 color);
/**
* An enum with vesa colors
@@ -157,12 +157,12 @@ enum vesa_color {
/**
* The default text color
*/
-const uint32_t default_text_color;
+const u32 default_text_color;
/**
* The current text color (as normalized array)
*/
-uint32_t terminal_color[3];
+u32 terminal_color[3];
/**
* The current input
@@ -197,8 +197,8 @@ int vbe_bpl;
/**
* The framebuffer interface
*/
-uint8_t *fb;
+u8 *fb;
-uint8_t *cursor_buffer;
+u8 *cursor_buffer;
#endif \ No newline at end of file