diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-14 11:06:13 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-14 11:06:13 +0200 |
commit | 2c79240cc66dd2a116056662def9bdc165b2b3e7 (patch) | |
tree | da262ee59e3e1bf74538a64b97c7965f85649f76 | |
parent | bc9530b1b439752fdf340f8d13ded049f678660e (diff) | |
download | abaos-2c79240cc66dd2a116056662def9bdc165b2b3e7.tar.gz abaos-2c79240cc66dd2a116056662def9bdc165b2b3e7.tar.bz2 |
playing with addresses and seing the CRT index port number now in port8_read
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | src/kernel.c | 5 | ||||
-rw-r--r-- | src/port.asm | 21 | ||||
-rw-r--r-- | src/port.c | 5 | ||||
-rw-r--r-- | src/vga.c | 34 |
5 files changed, 60 insertions, 14 deletions
@@ -14,7 +14,7 @@ ndisasm -b16 -o7c00h -a image.bin | less objdump -M intel -d kernel.o | less gcc -m32 -ffreestanding -c -o kernel.o kernel.c -ld -o kernel.bin -Ttext 0x8000 kernel.o -m elf_i386 --oformat binary +ld -o kernel.bin -Ttext 0x8400 kernel.o -m elf_i386 --oformat binary objdump -M intel -d kernel.bin | less # oformat: objdump -i lists tons of formats @@ -37,6 +37,13 @@ Booting from 0000:7c00 Next at t=14040244 (0) [0x000000007c00] 0000:7c00 (unk. ctxt): mov ax, 0x0000 ; b80000 +C entry: +break 0x8400 + +disassemble kernel in 32-bit mode +ndisasm -b32 -o8400h -a kernel.bin | less + + links ----- diff --git a/src/kernel.c b/src/kernel.c index 91ed26b..d5db426 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -27,10 +27,7 @@ void entry( void ) } vga_put_char_at( &vga, x_pos, y_pos, '.' ); vga_put_newline( &vga ); - - vga_put_hex( &vga, 4711 ); - vga_put_newline( &vga ); - + //~ vga_set_color( &vga, VGA_COLOR_WHITE ); //~ vga_set_background_color( &vga, VGA_COLOR_RED ); //~ vga_clear_screen( &vga ); diff --git a/src/port.asm b/src/port.asm index 34d1f78..c7a2b85 100644 --- a/src/port.asm +++ b/src/port.asm @@ -1,18 +1,33 @@ [bits 32] global port8_write +global port8_read +; void port8_write( port8_t *port, uint8_t data ); port8_write: + push ebp + mov ebp, esp mov edx, [ebp+16] mov eax, (edx) +; mov eax, [epb+8] ; mov dx, [ebp+8] ; out ax, dl + leave ret - +; uint8_t port8_read( port8_t *port ) +port8_read: + push ebp + mov ebp, esp + mov edx, [ebp+8] + mov eax, [edx] + leave + ret + ;~ void port8_init( port8_t *port, uint16_t number ) +; __asm__ volatile("inb %1, %0" : "=a" (result) : "Nd" (_port)); ;~ global _myfunc ;~ _myfunc: push ebp @@ -23,3 +38,7 @@ port8_write: ;~ leave ; mov esp,ebp / pop ebp ;~ ret ; __asm__ volatile("outb %0, %1" : : "a" (_data), "Nd" (_port)); + +;~ { + ;~ return 0; +;~ } @@ -4,8 +4,3 @@ void port8_init( port8_t *port, uint16_t number ) { port->number = number; } - -uint8_t port8_read( port8_t *port ) -{ - return 0; -} @@ -53,12 +53,41 @@ void vga_set_cursor( vga_t *vga, const int x, const int y ) void vga_set_cursor_from_hardware( vga_t *vga ) { + // value of port we want to see later in assembly + uint16_t n = vga->crtc_index_port.number; + vga_put_hex( vga, n ); + vga_put_newline( vga ); + + // the address of the vga structure + uintptr_t uip = (uintptr_t)( (void *)vga ); + vga_put_hex( vga, uip ); + vga_put_newline( vga ); + + // the address of the port structure inside the vga structure + uintptr_t uip2 = (uintptr_t)( (void *)&vga->crtc_index_port ); + vga_put_hex( vga, uip2 ); + vga_put_newline( vga ); + + // the address of the number membger in the port structure inside the vga structure + // must be the same as uip2 by C99 + uintptr_t uip3 = (uintptr_t)( (void *)&vga->crtc_index_port.number ); + vga_put_hex( vga, uip3 ); + vga_put_newline( vga ); + + uint8_t data = port8_read( &(vga->crtc_index_port ) ); + vga_put_hex( vga, data ); + vga_put_newline( vga ); +//~ unsigned short offset; + //~ out(0x3D4, 14); + //~ offset = in(0x3D5) << 8; + //~ out(0x3D4, 15); + //~ offset |= in(0x3D5); } void vga_set_cursor_on_hardware( vga_t *vga ) { uint16_t hw_cursor_pos = vga->cursor_x + vga->cursor_y * vga->res_x; - + port8_write( &vga->crtc_index_port, 15 ); port8_write( &vga->crtc_index_port, hw_cursor_pos & 0xff ); port8_write( &vga->crtc_index_port, 14 ); @@ -164,8 +193,7 @@ void vga_put_hex( vga_t *vga, const uint32_t v ) { char buf[9]; - strlcpy( buf, "0x", 9 ); - vga_put_string( vga, (const char *)buf ); + vga_put_string( vga, "0x" ); itoa( v, (char *)buf, 16 ); vga_put_string( vga, (const char *)buf ); } |