0.0.2d: Added BGA support, graphics!
This commit is contained in:
@ -36,12 +36,13 @@ typedef struct {
|
||||
uint32_t p_align;
|
||||
} Elf32_Phdr;
|
||||
|
||||
//typedef int (*elf_entry_t)(int, char**);
|
||||
typedef int (*elf_entry_t)(void);
|
||||
|
||||
typedef struct {
|
||||
elf_entry_t entry_point;
|
||||
} elf_executable_t;
|
||||
|
||||
elf_executable_t* load_elf32(void* elf_data);
|
||||
int load_elf32(void* elf_data, elf_executable_t** ptr);
|
||||
|
||||
#endif
|
||||
|
||||
26
include/drivers/graphics/vga.h
Normal file
26
include/drivers/graphics/vga.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _VGA_GRAPHICS_H
|
||||
#define _VGA_GRAPHICS_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
struct bga_framebuffer
|
||||
{
|
||||
volatile uint8_t* addr;
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
uint32_t pitch; /* bytes per scanline */
|
||||
uint32_t bpp;
|
||||
};
|
||||
|
||||
|
||||
void bga_defaults(void);
|
||||
void bga_set_video_mode(uint32_t width, uint32_t height, uint32_t bit_depth);
|
||||
|
||||
void bga_putpixel(uint32_t x, uint32_t y, uint32_t color);
|
||||
|
||||
|
||||
void bga_drawline(int x0, int y0, int x1, int y1, uint32_t color);
|
||||
|
||||
#endif
|
||||
@ -44,4 +44,6 @@ int32_t ide_write48(uint8_t drive, uint64_t lba, uint8_t sector_count, const voi
|
||||
int32_t read_sector(uint64_t lba, void* buffer);
|
||||
int32_t write_sector(uint64_t lba, const void* buffer);
|
||||
|
||||
int get_sector_size(uint8_t drive);
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
//#ifndef _ESPRESSO_KERNEL_FS_H
|
||||
#if 0
|
||||
#define _ESPRESSO_KERNEL_FS_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#define EKFS_FILENAME_MAX_LEN 64
|
||||
|
||||
enum {
|
||||
EKFS_E_FILETOOSMALL = -16;
|
||||
};
|
||||
|
||||
struct ekfs_inode {
|
||||
char i_name[EKFS_FILENAME_MAX_LEN];
|
||||
|
||||
uint64_t i_start; /* LBA48 */
|
||||
size_t i_len; /* rounded up to the nearest multiple of 512 */
|
||||
} __attribute__((packed));
|
||||
|
||||
struct ekfs_ops {
|
||||
int (*read)(struct ekfs_file*, void*, size_t);
|
||||
int (*write)(struct ekfs_file*, void*, size_t);
|
||||
};
|
||||
|
||||
struct ekfs_file {
|
||||
struct ekfs_inode* f_inode;
|
||||
|
||||
size_t f_offset;
|
||||
size_t f_refcount;
|
||||
|
||||
struct ekfs_ops f_ops;
|
||||
};
|
||||
|
||||
|
||||
int ekfs_read(struct ekfs_file* __f, void* __b, size_t __l);
|
||||
|
||||
#endif
|
||||
@ -4,7 +4,32 @@
|
||||
#include <types.h>
|
||||
|
||||
|
||||
#define MAX_FDS 64
|
||||
|
||||
struct file;
|
||||
|
||||
struct inode {
|
||||
size_t size;
|
||||
int permissions;
|
||||
/* | | */
|
||||
/* \/ FS-specific \/ */
|
||||
union {
|
||||
void* fs_data;
|
||||
void* private_data;
|
||||
};
|
||||
};
|
||||
|
||||
struct file_ops {
|
||||
int (*read)(struct file*, char*, size_t);
|
||||
int (*write)(struct file*, const char*, size_t);
|
||||
};
|
||||
|
||||
struct file {
|
||||
struct inode* f_inode;
|
||||
size_t f_offset;
|
||||
size_t f_refcount;
|
||||
const struct file_ops* f_ops;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -13,5 +13,7 @@ static inline int div_round_up(int a, int b)
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
int abs(int x);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -4,11 +4,14 @@
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <fs/vfs.h>
|
||||
|
||||
#include <processes.h>
|
||||
#include <sync.h>
|
||||
|
||||
|
||||
#define TTY_BUFFER_SIZE 4096
|
||||
#define TTY_RAW_BUFFER_SIZE 16
|
||||
#define MAX_TTYS 8 /* to make things easy, might change later */
|
||||
|
||||
#define TTY_ECHO 0x10 /* 0b00010000 */
|
||||
@ -16,7 +19,9 @@
|
||||
#define TTY_ACTIVE 0x01 /* 0b00000001 */
|
||||
|
||||
#define TTY_CANONICAL 0x40 /* 0b01000000 */
|
||||
#define TTY_RAW 0x04 /* 0b00000100 */
|
||||
|
||||
#define TTY_ADDCHAR_ALWAYS 0x02 /* 0b00000010 */
|
||||
|
||||
#define TTY_NULL 0x80 /* 0b10000000 --- used to end the list of tty_t structs in the ttys array */
|
||||
|
||||
@ -44,7 +49,17 @@ typedef struct tty_t {
|
||||
bool canonical;
|
||||
bool line_ready;
|
||||
|
||||
/* for raw mode */
|
||||
char raw_buf[TTY_RAW_BUFFER_SIZE];
|
||||
size_t raw_head;
|
||||
size_t raw_tail;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
size_t user_input_start;
|
||||
size_t user_input_end;
|
||||
|
||||
struct file_ops f_ops;
|
||||
|
||||
pid_t foreground_pgid; /* not used yet */
|
||||
} tty_t;
|
||||
@ -60,9 +75,14 @@ int init_tty(void);
|
||||
ssize_t tty_read(tty_t* tty, char* buf, size_t count);
|
||||
ssize_t tty_read_active(char* buf, size_t count);
|
||||
|
||||
char tty_get_char(void);
|
||||
|
||||
tty_t* get_active_tty(void);
|
||||
tty_t* tty_get_active(void);
|
||||
|
||||
void tty_and_flags(tty_t* tty, uint32_t flags);
|
||||
uint32_t tty_get_flags(tty_t* tty);
|
||||
|
||||
tty_t* make_tty(uint32_t flags);
|
||||
|
||||
void tty_receive_char(char c, uint32_t kbd_mod);
|
||||
|
||||
@ -10,11 +10,23 @@ static inline uint32_t inl(uint16_t port)
|
||||
return rv;
|
||||
}
|
||||
|
||||
static inline uint16_t inw(uint16_t port)
|
||||
{
|
||||
uint16_t rv;
|
||||
asm volatile ("inw %%dx, %%ax" : "=a" (rv) : "dN" (port));
|
||||
return rv;
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void outl(uint16_t port, uint32_t data)
|
||||
{
|
||||
asm volatile ("outl %%eax, %%dx" : : "dN" (port), "a" (data));
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void outw(uint16_t port, uint16_t val)
|
||||
{
|
||||
asm volatile ( "outw %0, %1" : : "a"(val), "Nd"(port) : "memory");
|
||||
}
|
||||
|
||||
static inline __attribute__((always_inline)) void outb(uint16_t port, uint8_t val)
|
||||
{
|
||||
asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
|
||||
|
||||
@ -17,11 +17,6 @@ char* strdup(const char* s);
|
||||
char* strtok(char* str, const char* delim);
|
||||
char* strchr(const char* s, int c);
|
||||
|
||||
/* these functions are NOT in the standard C library */
|
||||
int num_strchr(const char* s, int c);
|
||||
char* strnlstrip(const char* __s);
|
||||
void strlnstripip(char* s);
|
||||
|
||||
void lowers(char* str);
|
||||
void uppers(char* str);
|
||||
|
||||
@ -35,4 +30,11 @@ int atoi(const char *str);
|
||||
long atol(const char *str);
|
||||
double atof(const char *str);
|
||||
|
||||
/* these functions are NOT in the standard C library */
|
||||
int num_strchr(const char* s, int c);
|
||||
char* strnlstrip(const char* __s);
|
||||
void strlnstripip(char* s);
|
||||
char** split(const char* str, char delim);
|
||||
void free_split(char** parts);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user