-
-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[metal] Start exploring graphical video modes for VGA console #637
Conversation
- Factor __invert_memory() into two routines, to make it easier for other libc routines to create their own negative address mappings - Tweak __invert_memory() to map only the usable memory as given in the 0xe820 memory map, and no more - Arrange for VGA console initialization to map video memory separately into virtual memory (in case needed) - Rename libc/vga/vga-init.S to libc/vga/rlinit-vga.S, to reduce confusion as to the module's purpose
This should hopefully help us adapt the VGA console code, to work with video modes other than 80 × 25 × 16 text.
If the user holds down one of the Shift keys at boot time, the program will dump a list of all usable VESA VBE video modes on the VGA console.
from VESA video mode list
Video mode switching works. Character output, not so much. (The tty code still thinks it is writing text mode characters.)
Hello @tkchia,
Wow, super nice work, and great display!
I have just completed a text and graphics console emulator for Cosmopolitan, based on SDL, which will compile on Linux and macOS. I have used this to further some of the ideas discussed in #638. In particular, it includes a glyph drawing function and memory-based font that will work for all the modes shown in your screenshot above. I will post that code shortly, which should allow you to rapidly get graphical console text output running in short order. Thank you! |
Hello @ghaerr, Thanks! I look forward to seeing what you have. |
Hello @ghaerr, Incidentally, have you sent a copyright assignment or copyright disclaimer e-mail to @jart yet (#616 (comment))? I think this will be needed to ultimately get your contributions included upstream. Thank you! |
Hello @tkchia,
Yes I have. However, seeing your progress on the VGA console in the past 10 days, I thought to at least post something that you might use ASAP, to allow you to continue making progress at full speed :)
Yes. In this particular case, the "console emulator" isn't actually a Cosmopolitan binary, as it uses the (fairly extensive and not-likely-easily ported) SDL library to allow for graphical display and proper emulation of 32bpp, 24bpp and 16bpp framebuffer formats, and possibly to be used in the Cosmopolitan test suite for upcoming graphical library routines. I am not sure how @jart wants things like this organized. Thank you! |
in that video mode output on the headers line change EDIT: alternatively you could place (centered)
NOTE: there are no extended text modes in there? (80x50, 256 color (8bpp), 132x50, etc) |
Hello @paulwratt,
I think I will leave that as an exercise for whoever is interested. 🙂
Strangely no, as far as I can tell. There are also no (directly supported) extended text modes on the actual (non-VM) PC which I am testing with. Mode Thank you! |
OK — the user can now select which video mode to switch to, after pressing the ⇧ Shift key at startup. I also added a quick test routine to have the protected mode code draw a glyph (in two different colours) in the middle of the screen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm loving watching the progress unfold so quickly on this. You're doing fabulous work. You're making Cosmopolitan a true operating system!
_rlinit_vesa: | ||
push %es | ||
pushw $0 | ||
testb $0b00000011,0x0417 # read keyboard shift state (as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've re-enabled the Wiki feature on this repository. Knowledge like a magic shift key for VGA config would be a good thing to have documented there! Put anything on the wiki you want!
// @return CF = 0 if we decided to set a new video mode, CF = 1 otherwise | ||
|
||
.real | ||
.code16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[high level optional suggestion] You are so good at writing real mode code. But is there no other way? Is it possible to control this stuff from long mode using i/o ports? Surely there's got to be some i/o ports that are generally well-supported and well-defined on x86-64 PCs and servers. Because it'd be nice to have more stuff written in C if possible rather than depending on BIOS interfaces if we don't have to. Our support vector is 2006+ so if a consensus exists after that year for i/o ports let's use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jart,
This is (still) beyond my capability at the moment, I am afraid, if it is possible. That is, I have not quite found a simple way to reliably switch modes, without going through VESA (in the case of legacy BIOS boot) or EFI GOP (in the case of UEFI boot). I suspect that at least some parts of the mode switching must be done differently for different graphics cards.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. I'm sure as the work evolves it'll attract more people who can help us!
@@ -58,9 +52,194 @@ ssize_t sys_writev_vga(struct Fd *fd, const struct iovec *iov, int iovlen) { | |||
return wrote; | |||
} | |||
|
|||
static void _vga_init_test(void *vid_buf, unsigned char vid_type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like code we'll probably want to TODO move into examples/ soon. This isn't needed for production code, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jart : yes, it is not really needed. Thank you!
To do:
Edit 2022-09-26: in addition:
__invert_memory()
into two routines, to make it easier for otherlibc
routines to create their own negative address mappings__invert_memory()
to map only the usable memory as given in the0xe820
memory map, and no morelibc/vga/vga-init.S
tolibc/vga/rlinit-vga.S
, to reduce confusion as to the module's purpose