VGA tty initialization should not run outside of bare metal mode (#614)

This commit is contained in:
tkchia 2022-09-14 06:27:19 +08:00 committed by GitHub
parent 945699694e
commit 6a3330d7c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@
#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/fd.internal.h"
#include "libc/calls/struct/iovec.h" #include "libc/calls/struct/iovec.h"
#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/struct/iovec.internal.h"
#include "libc/dce.h"
#include "libc/vga/vga.internal.h" #include "libc/vga/vga.internal.h"
#include "libc/runtime/pc.internal.h" #include "libc/runtime/pc.internal.h"
#include "libc/str/str.h" #include "libc/str/str.h"
@ -58,6 +59,7 @@ ssize_t sys_writev_vga(struct Fd *fd, const struct iovec *iov, int iovlen) {
} }
__attribute__((__constructor__)) static textstartup void _vga_init(void) { __attribute__((__constructor__)) static textstartup void _vga_init(void) {
if (IsMetal()) {
void * const vid_buf = (void *)(BANE + 0xb8000ull); void * const vid_buf = (void *)(BANE + 0xb8000ull);
/* /*
* Get the initial cursor position from the BIOS data area. Also get * Get the initial cursor position from the BIOS data area. Also get
@ -73,9 +75,10 @@ __attribute__((__constructor__)) static textstartup void _vga_init(void) {
if (chr_ht_hi != 0 || chr_ht > 32) if (chr_ht_hi != 0 || chr_ht > 32)
chr_ht = 32; chr_ht = 32;
/* /*
* Initialize our tty structure from the current screen contents, current * Initialize our tty structure from the current screen contents,
* cursor position, & character height. * current cursor position, & character height.
*/ */
_StartTty(&_vga_tty, VGA_TTY_HEIGHT, VGA_TTY_WIDTH, pos.row, pos.col, _StartTty(&_vga_tty, VGA_TTY_HEIGHT, VGA_TTY_WIDTH, pos.row, pos.col,
chr_ht, vid_buf, vga_wcs); chr_ht, vid_buf, vga_wcs);
}
} }