Skip to content

Commit

Permalink
Add _fb_printStrAndNumber that uses cur_fb_line
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed Dec 27, 2023
1 parent 2521c2c commit 70da79a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/include/kernel/framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ typedef struct framebuffer_info {
uint32_t width;
uint32_t height;

uint32_t number_of_lines;
uint32_t number_of_rows;

uint64_t phys_address;
} framebuffer_info;

Expand All @@ -26,7 +29,8 @@ void _fb_put_pixel(uint32_t, uint32_t, uint32_t);

/*void map_framebuffer(struct multiboot_tag_framebuffer *);*/
void set_fb_data(struct multiboot_tag_framebuffer *);
void _fb_printStrAndNumber(const char*, uint64_t, size_t, size_t, uint32_t, uint32_t);
void _fb_printStrAndNumber(const char*, uint64_t, uint32_t, uint32_t);
void _fb_printStrAndNumberAt(const char*, uint64_t, size_t, size_t, uint32_t, uint32_t);

void get_framebuffer_mode(uint32_t* pixels_w, uint32_t* pixels_h, uint32_t* chars_w, uint32_t* chars_h);
void draw_logo(uint32_t start_x, uint32_t start_y);
Expand Down
14 changes: 12 additions & 2 deletions src/kernel/framebuffer/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,17 @@ void _fb_putchar(char symbol, size_t cx, size_t cy, uint32_t fg, uint32_t bg){
void _fb_printStr( const char *string, uint32_t fg, uint32_t bg ) {
_fb_printStrAt(string, 0, cur_fb_line, fg, bg);
cur_fb_line++;
// TODO: compute number of rows in a framebuffer, and check when last line has been reached
if ( cur_fb_line > framebuffer_data.number_of_lines ) {
pretty_log(Verbose, "Exceeding number of lines, cycling");
}
}

void _fb_printStrAndNumber(const char *string, uint64_t number, uint32_t fg, uint32_t bg) {
_fb_printStrAndNumberAt(string, number, 0, cur_fb_line, fg, bg);
cur_fb_line++;
if ( cur_fb_line > framebuffer_data.number_of_lines ) {
pretty_log(Verbose, "Exceeding number of lines, cycling");
}
}

void _fb_printStrAt( const char *string, size_t cx, size_t cy, uint32_t fg, uint32_t bg ){
Expand All @@ -173,7 +183,7 @@ void _fb_printStrAt( const char *string, size_t cx, size_t cy, uint32_t fg, uint
}
}

void _fb_printStrAndNumber(const char *string, uint64_t number, size_t cx, size_t cy, uint32_t fg, uint32_t bg){
void _fb_printStrAndNumberAt(const char *string, uint64_t number, size_t cx, size_t cy, uint32_t fg, uint32_t bg){
char buffer[30];

_getHexString(buffer, number, true);
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void kernel_start(unsigned long addr, unsigned long magic){
uint64_t unix_timestamp = read_rtc_time();

#if USE_FRAMEBUFFER == 1
_fb_printStrAndNumber("Epoch time: ", unix_timestamp, 0, 11, 0xf5c4f1, 0x000000);
_fb_printStrAndNumberAt("Epoch time: ", unix_timestamp, 0, 11, 0xf5c4f1, 0x000000);
#endif
init_scheduler();
char a = 'a';
Expand Down

0 comments on commit 70da79a

Please sign in to comment.