Skip to content

Commit

Permalink
Drivers #126
Browse files Browse the repository at this point in the history
  • Loading branch information
double-fault committed Jan 1, 2017
1 parent 9f43ddb commit f9b5aa2
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 66 deletions.
7 changes: 2 additions & 5 deletions include/platform/pc/drv/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @struct device_driver:
* Prototype for a device
* driver. Used to initalize
* a driver, and unintalize
* a driver.
* a driver, and unintalize
* a driver.
*/
struct device_driver_t
{
Expand Down Expand Up @@ -37,9 +37,6 @@ extern bool device_initalized(int index);
/*
* Drivers
*/
extern struct device_driver_t pit_driver;
extern struct device_driver_t kbd_driver;
extern struct device_driver_t video_driver;
extern struct device_driver_t *drivers[];

#endif /*_ARCH_DRV_DRIVER_H_*/
Expand Down
12 changes: 7 additions & 5 deletions include/platform/pc/drv/pit/pit.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
#include <stdbool.h>

/*
* Operation Control Words
* Commands Available for
* Operation Control Words
* Commands Available for
* the PIT.
*/
//START
#define I386_PIT_OCW_BINCOUNT_BINARY 0x0 //0
#define I386_PIT_OCW_BINCOUNT_BCD 0x1 //1

#define I386_PIT_OCW_MODE_TERMINALCOUNT 0x0 //0000
#define I386_PIT_OCW_MODE_TERMINALCOUNT 0x0 //0000
#define I386_PIT_OCW_MODE_ONESHOT 0x2 //0010
#define I386_PIT_OCW_MODE_RATEGEN 0x4 //0100
#define I386_PIT_OCW_MODE_SQUAREWAVEGEN 0x6 //0110
#define I386_PIT_OCW_MODE_SOFTWARETRIG 0x8 //1000

#define I386_PIT_OCW_RL_LATCH 0 //000000
#define I386_PIT_OCW_RL_LATCH 0 //000000
#define I386_PIT_OCW_RL_LSBONLY 0x10 //010000
#define I386_PIT_OCW_RL_MSBONLY 0x20 //100000
#define I386_PIT_OCW_RL_DATA 0x30 //110000
Expand All @@ -45,7 +45,9 @@
extern volatile uint32_t pit_ticks;

extern int init_pit();
extern int uninit_pit();
extern int uninit_pit();

extern struct device_driver_t pit_driver;

#endif /*_DRV_PIT_H_*/

Expand Down
14 changes: 8 additions & 6 deletions include/platform/pc/drv/ps2/kbd/kbd.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,33 +85,35 @@ extern bool led_light(bool scroll, bool num, bool caps);
struct
kbd_info_t
{
struct
struct
{
bool num_lock;
bool caps_lock;
bool scroll_lock;
}led;

struct
{
bool shift;
bool alt;
bool ctrl;
}spec_keys;

struct
{
bool bat_test;
}tests;

uint8_t scancode;
bool is_shift;
bool is_enter;
bool is_caps;
uint32_t current_kbd_layout_index;
int key;

};

};

extern struct device_driver_t kbd_driver;

extern volatile struct kbd_info_t kbd_info;

Expand Down
16 changes: 9 additions & 7 deletions include/platform/pc/drv/video/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@


extern size_t video_driver_width;
extern size_t video_driver_height;
extern size_t video_driver_height;
extern char* video_driver_name;
extern char* video_driver_mode;
extern char* video_driver_fullname;
extern char* video_driver_fullname;

extern struct device_driver_t video_driver;



Expand All @@ -30,16 +32,16 @@ typedef void(*put_pixel_t)(int32_t x, int32_t y, rgb_t rgb);
* Prototype for a video
* driver. used as a basis
* for what video driver the
* current running OS Is
* current running OS Is
* running
*/

struct video_driver_t
{
enum
{
GRAPHICS_MODE,
TEXT_MODE
GRAPHICS_MODE,
TEXT_MODE
}mode;

uint8_t fg;
Expand All @@ -60,11 +62,11 @@ struct video_driver_t
int w;
int h;
}res;

uint16_t status;
char* name;
};


extern struct video_driver_t *video_drivers[];

#endif /*ARCH_DRV_VIDEO_H_*/
Expand Down
35 changes: 5 additions & 30 deletions platform/pc/drv/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
**/

#include <stdint.h>
#include <stddef.h>
Expand All @@ -30,33 +30,8 @@
#include <misc/status_codes.h>
#include <assertk.h>

//Timer Driver Handler
struct device_driver_t pit_driver =
{
.name = "8253 Programmable Interval Timer",
.init = &init_pit,
.uninit = &uninit_pit,
.version = "8253"
};

//Keyboard Driver Handler
struct device_driver_t kbd_driver =
{
.name = "8042 Keyboard PS/2 Driver",
.init = &init_kbd,
.uninit = &uninit_kbd,
.version = "8042"
};

//Video Driver Handler
struct device_driver_t video_driver =
{
.name = "Video Driver",
.version = "STATUS_VERSION_NA"
};

//All Drivers
struct device_driver_t *drivers[] =
//All Drivers
struct device_driver_t *drivers[] =
{
&pit_driver,
&kbd_driver,
Expand All @@ -77,7 +52,7 @@ void setup_driver_handler(void)
video_driver.init = video_drivers[VGA_VIDEO_DRIVER_INDEX]->init;
video_driver.uninit = video_drivers[VGA_VIDEO_DRIVER_INDEX]->uninit;
video_driver.status = video_drivers[VGA_VIDEO_DRIVER_INDEX]->status;

init_all_drivers();
}

Expand Down
23 changes: 16 additions & 7 deletions platform/pc/drv/pit/pit.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
Expand All @@ -28,13 +28,22 @@
#include <drv/pit/pit.h>
#include <io/io.h>
#include <stdint.h>
#include <stddef.h>
#include <stddef.h>

//Timer Driver Handler
struct device_driver_t pit_driver =
{
.name = "8253 Programmable Interval Timer",
.init = &init_pit,
.uninit = &uninit_pit,
.version = "8253"
};


volatile uint32_t pit_ticks = 0;

/*
* @function send_pit_command:
* @function send_pit_command:
* Sends Operation Command Word
* to PIT.
*/
Expand All @@ -44,7 +53,7 @@ static void send_pit_command(uint8_t cmd)
}

/*
* @function send_pit_command:
* @function send_pit_command:
* Sends Messages to Counter
* 0 of PIT's Internal Registers.
*/
Expand All @@ -54,7 +63,7 @@ static void send_msg_counter_0(uint8_t cmd)
}

/*
* @function send_pit_command:
* @function send_pit_command:
* Initalizes the PIT Intenally
* with the number of IRQ's per
* second specified.
Expand All @@ -66,7 +75,7 @@ static void pit_phase(int htz)
//the IRQ Should fire
int divisor = 1193180 / htz;

send_pit_command( I386_PIT_OCW_BINCOUNT_BINARY |
send_pit_command( I386_PIT_OCW_BINCOUNT_BINARY |
I386_PIT_OCW_MODE_SQUAREWAVEGEN |
I386_PIT_OCW_RL_DATA |
I386_PIT_OCW_SCO_COUNTER_0);
Expand Down Expand Up @@ -102,7 +111,7 @@ static void pit_handler(int_regs *r)
if(r){};
pit_ticks++;
if (pit_ticks % IRQ_SEC_HIT == 0)
if(pit_handler_nest()!=0)
if(pit_handler_nest()!=0)
panik("PIT Handler Nest Exception");
}

Expand Down
9 changes: 9 additions & 0 deletions platform/pc/drv/ps2/kbd/kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ extern volatile bool TERMINAL_MODE;
extern volatile bool __get_char_set;
extern volatile char __get_char_chr;

//Keyboard Driver Handler
struct device_driver_t kbd_driver =
{
.name = "8042 Keyboard PS/2 Driver",
.init = &init_kbd,
.uninit = &uninit_kbd,
.version = "8042"
};


/*
* @function key_press:
Expand Down
25 changes: 19 additions & 6 deletions platform/pc/drv/video/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,35 @@
** along with BoneOS. If not, see <http://www.gnu.org/licenses/>.
**
** @main_author : Amanuel Bogale
**
**
** @contributors:
** Amanuel Bogale <amanuel2> : start
**/
**/

#include <drv/video/video.h>
#include <drv/video/VGA/vga.h>
#include <drv/video/VGA/vga.h>
#include <misc/status_codes.h>
#include <drv/driver.h>
#include <assertk.h>
#include <stdint.h>
#include <stddef.h>

//Video Driver Handler
struct device_driver_t video_driver =
{
.name = "Video Driver",
.version = "STATUS_VERSION_NA"
};

size_t video_driver_width = 80;
size_t video_driver_height = 25;
size_t video_driver_height = 25;
char* video_driver_name = "VGA";
char* video_driver_mode = "TEXTMODE";
char* video_driver_fullname = "VGA_TEXTMODE_80_x_25";
char* video_driver_fullname = "VGA_TEXTMODE_80_x_25";


struct video_driver_t *video_drivers[] =
struct video_driver_t *video_drivers[] =
{
&vga_driver,
0
Expand Down

0 comments on commit f9b5aa2

Please sign in to comment.