diff options
| author | Franklin Wei <frankhwei536@gmail.com> | 2015-03-01 14:20:47 -0500 |
|---|---|---|
| committer | Franklin Wei <frankhwei536@gmail.com> | 2015-03-01 14:20:47 -0500 |
| commit | c7252588ebb95f97631e9470778c69afa00c35b5 (patch) | |
| tree | 06d760878e18f6cddbe4305cddd4d5dfa74529f8 /include/arch/i686/drivers | |
| parent | b8f54e63d2b8f8007c580adf2a6034c98a0f2eaa (diff) | |
| download | kappa-c7252588ebb95f97631e9470778c69afa00c35b5.zip kappa-c7252588ebb95f97631e9470778c69afa00c35b5.tar.gz kappa-c7252588ebb95f97631e9470778c69afa00c35b5.tar.bz2 kappa-c7252588ebb95f97631e9470778c69afa00c35b5.tar.xz | |
Huge restructure
Diffstat (limited to 'include/arch/i686/drivers')
| -rw-r--r-- | include/arch/i686/drivers/gfx.h | 105 | ||||
| -rw-r--r-- | include/arch/i686/drivers/gfx_font.h | 4 | ||||
| -rw-r--r-- | include/arch/i686/drivers/pcspkr.h | 3 | ||||
| -rw-r--r-- | include/arch/i686/drivers/ps2_keymaps.h | 39 | ||||
| -rw-r--r-- | include/arch/i686/drivers/ps2kbd.h | 66 | ||||
| -rw-r--r-- | include/arch/i686/drivers/vgatext.h | 9 |
6 files changed, 226 insertions, 0 deletions
diff --git a/include/arch/i686/drivers/gfx.h b/include/arch/i686/drivers/gfx.h new file mode 100644 index 0000000..5e97100 --- /dev/null +++ b/include/arch/i686/drivers/gfx.h @@ -0,0 +1,105 @@ +#ifndef _GFX_H_ +#define _GFX_H_ + +#include <stdbool.h> +#include <stdint.h> + +enum vga_color_t { + VGA_BLACK = 0, + VGA_BLUE = 1, + VGA_GREEN = 2, + VGA_CYAN = 3, + VGA_RED = 4, + VGA_MAGENTA = 5, + VGA_BROWN = 6, + VGA_LIGHT_GRAY = 7, + VGA_DARK_GRAY = 8, + VGA_LIGHT_BLUE = 9, + VGA_LIGHT_GREEN = 10, + VGA_LIGHT_CYAN = 11, + VGA_LIGHT_RED = 12, + VGA_LIGHT_MAGENTA = 13, + VGA_LIGHT_BROWN = 14, + VGA_WHITE = 15 +}; + +#define VGA_WIDTH 80 +#define VGA_HEIGHT 25 + +#define VGA_MAKE_COLOR(fg, bg) (fg | bg << 4) +#define VGA_MAKE_ENTRY(ch, col) (((uint16_t)ch)|((uint16_t)col<<8)) +#define VGA_RGBPACK(r, g, b) ((r << 16)|(g << 8)|(b << 0)) + +#define GFX_WHITE 0xFFFFFF +#define GFX_BLACK 0x000000 + +struct vbe_info_t; + +bool gfx_init(struct vbe_info_t *vbe_mode_info); + +extern void (*gfx_drawpixel)(int x, int y); + +/* transparent background */ +void gfx_drawchar(int x, int y, int ch); + +/* fills the background with bgcolor */ +void gfx_drawchar_bg(int x, int y, int ch); + +void gfx_putchar(int ch); + +void gfx_puts(const char* str); + +/* this function can be different from resolution to resolution */ +extern void (*gfx_clear)(void); + +void gfx_reset(void); + +void gfx_set_foreground(uint32_t); + +uint32_t gfx_get_foreground(void); + +void gfx_set_background(uint32_t); + +uint32_t gfx_get_background(void); + +void (*gfx_hline)(int x1, int x2, int y); + +void (*gfx_vline)(int y1, int y2, int x); + +void gfx_fillrect(int x1, int y1, int w, int h); + +void gfx_drawline(int x1, int y1, int x2, int y2); + +/* these circle algorithms are very fast */ +void gfx_drawcircle(int cx, int cy, int rad); + +void gfx_fillcircle(int cx, int cy, int rad); + +void gfx_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); + +extern const uint16_t *gfx_width, *gfx_height; + +/* this is _BYTES_ per pixel, NOT BITS per pixel! */ +extern const uint8_t *gfx_bpp; + +struct bitmap_t { + unsigned int w, h; + unsigned int bpp; + uint8_t *data; +}; + +void gfx_bitmap(int x, int y, const struct bitmap_t*); + +void gfx_drawrect(int x, int y, int w, int h); + +void gfx_set_doublebuffer(bool); + +bool gfx_get_doublebuffer(void); + +/* don't call this wo/ double buffering! */ +void gfx_update(void); + +void gfx_putsxy(int, int, const char*); + +void gfx_putsxy_bg(int, int, const char*); +#endif diff --git a/include/arch/i686/drivers/gfx_font.h b/include/arch/i686/drivers/gfx_font.h new file mode 100644 index 0000000..f7db9d7 --- /dev/null +++ b/include/arch/i686/drivers/gfx_font.h @@ -0,0 +1,4 @@ +#include <stdint.h> +#define FONT_WIDTH 8 +#define FONT_HEIGHT 12 +extern const uint8_t gfx_font[][FONT_HEIGHT]; diff --git a/include/arch/i686/drivers/pcspkr.h b/include/arch/i686/drivers/pcspkr.h new file mode 100644 index 0000000..84e640f --- /dev/null +++ b/include/arch/i686/drivers/pcspkr.h @@ -0,0 +1,3 @@ +#include <stdint.h> + +void pcspkr_play(uint32_t freq); diff --git a/include/arch/i686/drivers/ps2_keymaps.h b/include/arch/i686/drivers/ps2_keymaps.h new file mode 100644 index 0000000..0e8ae26 --- /dev/null +++ b/include/arch/i686/drivers/ps2_keymaps.h @@ -0,0 +1,39 @@ +#include <stdint.h> + +#define EXTENDED_SCANCODE 0xE0 + +#define ERROR_KEY 0 +#define PRINTING_KEY 1 +#define SPECIAL_KEY 2 + +#define SPECIAL_NONE 0 +#define SPECIAL_SHIFT 1 +#define SPECIAL_CTRL 2 +#define SPECIAL_BKSP 3 +#define SPECIAL_ALT 4 +#define SPECIAL_GUI 5 +#define SPECIAL_NUMLOCK 6 +#define SPECIAL_CAPLOCK 7 +#define SPECIAL_SCRLLOCK 8 +#define SPECIAL_UPARROW 9 +#define SPECIAL_DNARROW 10 +#define SPECIAL_LFTARROW 11 +#define SPECIAL_RTARROW 12 +#define SPECIAL_ESC 13 +#define SPECIAL_F1 21 +#define SPECIAL_F2 22 +#define SPECIAL_F3 23 +#define SPECIAL_F4 24 +#define SPECIAL_F5 25 +#define SPECIAL_F6 26 +#define SPECIAL_F7 27 +#define SPECIAL_F8 28 +#define SPECIAL_F9 29 +#define SPECIAL_F10 30 +#define SPECIAL_F11 31 +#define SPECIAL_F12 32 + +extern uint8_t ps2_set1_scancodes[128]; +extern char ps2_set1_ascii[128]; +extern char ps2_set1_shift[128]; +extern uint8_t ps2_set1_special[128]; diff --git a/include/arch/i686/drivers/ps2kbd.h b/include/arch/i686/drivers/ps2kbd.h new file mode 100644 index 0000000..9e353ee --- /dev/null +++ b/include/arch/i686/drivers/ps2kbd.h @@ -0,0 +1,66 @@ +/* this is both a PS/2 keyboard AND a PS/2 MOUSE driver */ +#ifndef _PS2KBD_H_ +#define _PS2KBD_H_ + +#include <stdbool.h> +#include <stdint.h> + +#define PS2_SCROLL_LOCK (1 << 0) +#define PS2_NUM_LOCK (1 << 1) +#define PS2_CAPS_LOCK (1 << 2) + +#define BUTTON_UP (1 << 0) +#define BUTTON_LEFT (1 << 1) +#define BUTTON_DOWN (1 << 2) +#define BUTTON_RIGHT (1 << 3) + +#define MODIFIER_NONE 0 +#define MODIFIER_SHIFT (1 << 0) +#define MODIFIER_CTRL (1 << 1) +#define MODIFIER_ALT (1 << 2) + +struct ps2_specialkeys_t { + int shift :1; + int ctrl :1; + int bksp :1; + int alt :1; + int gui :1; + int numlock :1; + int capslock :1; + int scrllock :1; + int uparrow :1; + int downarrow :1; + int leftarrow :1; + int rightarrow :1; + int esc :1; + int f1 :1; + int f2 :1; + int f3 :1; + int f4 :1; + int f5 :1; + int f6 :1; + int f7 :1; + int f8 :1; + int f9 :1; + int f10 :1; + int f11 :1; + int f12 :1; +}; + +struct ps2_keyevent { + const struct ps2_specialkeys_t *special_keys; + char ascii; +}; + +/* returns which arrow keys are down */ +uint8_t ps2kbd_button_get(void); + +uint8_t ps2kbd_modifier_get(void); + +void ps2kbd_set_leds(uint8_t status); + +void ps2kbd_set_handler(void (*h)(const struct ps2_keyevent*)); + +void ps2kbd_init(void); + +#endif diff --git a/include/arch/i686/drivers/vgatext.h b/include/arch/i686/drivers/vgatext.h new file mode 100644 index 0000000..1cfe4c4 --- /dev/null +++ b/include/arch/i686/drivers/vgatext.h @@ -0,0 +1,9 @@ +#include <stdint.h> + +void vgatext_init(void); +void vgatext_clear(void); +void vgatext_set_color(uint8_t); +uint8_t vgatext_get_color(void); +void vgatext_putchar_at(int ch, uint8_t color, int x, int y); +void vgatext_putchar(int ch); +void vgatext_puts(const char*); |