[SOLVED] How do I get the base I/O port for text mode cursor
Posted: Sat Jan 28, 2017 12:03 pm
Hi, I wanted to move the text mode cursor, and I noticed that the wiki page on the subject says the following:
If I can find this information using the multiboot info struct, that would be very reassuring, but I'm having some trouble verifying if I've actually obtained the multiboot info struct.
Am I going about this the right way, or should I just assume that 0x3D4 is the magical "base port" like everyone else seems to be doing?
Here's my boot.s which is the bare bones tutorial boot.s but with one extra line added push %ebx:
so my kernel_main looks like this:
Interestingly enough, the wiki page on the BIOS data area says this:Also note that the base port (here assumed to be 0x3D4) should be read from the BIOS data area.
Every single "tutorial" I've found that moves the text mode cursor assumes the base port to be 0x3D4. There must be a good reason for that.The BDA is only partially standardized, and almost all the values stored there are completely obsolete and uninteresting. The following is a partial list. See the External Links references below for more detail.
If I can find this information using the multiboot info struct, that would be very reassuring, but I'm having some trouble verifying if I've actually obtained the multiboot info struct.
Am I going about this the right way, or should I just assume that 0x3D4 is the magical "base port" like everyone else seems to be doing?
Here's my boot.s which is the bare bones tutorial boot.s but with one extra line added push %ebx:
Code: Select all
# Declare constants for the multiboot header.
.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
# Declare a multiboot header
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
# establish a stack
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
# the entry point
.section .text
.global _start
.type _start, @function
_start:
# point the stack pointer to the top of the stack
mov $stack_top, %esp
# maybe one day I'll load a GDT here
# I suppose the multiboot info is here
push %ebx
# call kernel_main to begin the kernel stuff
call kernel_main
# halt, jump, loop, poop
cli
1: hlt
jmp 1b
.size _start, . - _start
Code: Select all
void kernel_main(multiboot_info_t* mbt) {
terminal_init();
/* access multiboot info */
}