diff --git a/servers/video/vga/vga.c b/servers/video/vga/vga.c index 44de3629..43b78548 100644 --- a/servers/video/vga/vga.c +++ b/servers/video/vga/vga.c @@ -163,7 +163,13 @@ static void vga_font_set(uint8_t *font_data, unsigned int length) system_port_out_uint8_t_pause(VGA_GRAPHIC_REGISTER, 0x06); system_port_out_uint8_t_pause(VGA_GRAPHIC_DATA, 0x00); - memory_copy(graphic_video_memory, font_data, length); + // The VGA hardware always reserves 32 bytes for each font, so we can't just copy the data to video memory as-is; + // we need to skip n bytes per character unless we use an 8x32 font. + int bytes_per_character = length / 256; + for (int i = 0; i < 256; i++) + { + memory_copy(graphic_video_memory + (i * 32), &font_data[i * bytes_per_character], bytes_per_character); + } // First, the sequencer. // Synchronous reset. @@ -286,6 +292,8 @@ static void handle_connection(ipc_structure_type *ipc_structure) { vga_palette_set_entry(index, &text_palette[index]); } + + vga_font_set(font_8x8, sizeof(font_8x8)); } else if (video_mode->mode_type == VIDEO_MODE_TYPE_GRAPHIC && video_mode->depth == 8) diff --git a/servers/video/vga/vgalib.asm b/servers/video/vga/vgalib.asm index 13e84638..dec5be5a 100644 --- a/servers/video/vga/vgalib.asm +++ b/servers/video/vga/vgalib.asm @@ -1,13 +1,10 @@ ; Abstract: x86 assembly-level VGA helper functions ; Author: Johan Thim (Thank you for your great help!) ; -; © Copyright 1999-2000 chaos development -; © Copyright 2013 chaos development -; © Copyright 2015-2016 chaos development +; © Copyright 1999 chaos development ; FIXME: Rewrite this in C! -extern font_8x8 extern graphic_video_memory global vga_set_mode @@ -41,23 +38,6 @@ mode_table: dd mode_320x200x256 dd mode_640x480x16 dd mode_640x400x256 -mode_t_table: db 0 - db 1 - db 0 - db 0 -mode_t_len equ $ - mode_t_table - -font_ptr dd 0 -font_bytes db 0 -vga_buff dd miff - -; FIXME: for some reason, the VGA server won't start if this is put into the -; BSS section. - -;section .bss - -miff times 300 db 0 - section .text vga_set_mode: push ebp @@ -68,17 +48,9 @@ vga_set_mode: push ebp mov esi, [mode_table + eax * 4] push eax call setmode + add esp,4 - pop eax - cmp byte [mode_t_table + eax], 1 - jne .no_font - - mov dword [font_ptr], font_8x8 - mov byte [font_bytes], 8 - - call loadfont - -.no_font: popa + popa pop ebp ret @@ -146,96 +118,3 @@ setmode: mov dx,3c2h ; misc addr out dx,al ret - -loadfont: cld - mov edi, [vga_buff] - - mov dx,3ceh ; graphics - mov al,5 ; write mode reg - out dx,al - inc dx - in al,dx - stosb - and al,0fch - xchg al,ah - mov al,5 - dec dx - out dx,ax - - mov al,6 ; misc reg - out dx,al - inc dx - in al,dx - stosb - and al,0f1h - or al,4 - xchg al,ah - mov al,6 - dec dx - out dx,ax - - mov dx,3c4h ; sequencer port - mov al,2 ; map mask reg - out dx,al - inc dx - in al,dx - stosb - - dec dx - mov ax,402h - out dx,ax - - mov al,4 ; memory selector reg - out dx,al - inc dx - in al,dx - stosb - or al,4 - xchg al,ah - mov al,4 - dec dx - out dx,ax - - mov esi, [font_ptr] - mov edi, [graphic_video_memory] - - xor ecx,ecx - mov ebx,ecx - -.1: mov cl,[font_bytes] - rep movsb - - mov cl,32 - sub cl,[font_bytes] - xor eax,eax - rep stosb - - dec bl ; 256 chars - jnz .1 - - mov esi,[vga_buff] - - mov dx,3ceh - lodsb - xchg al,ah - mov al,5 - out dx,ax - - lodsb - xchg al,ah - mov al,6 - out dx,ax - - mov dx,3c4h - lodsb - xchg al,ah - mov al,2 - out dx,ax - - lodsb - xchg al,ah - mov al,4 - out dx,ax - - ret - diff --git a/storm/x86/port.c b/storm/x86/port.c index d8ecd5be..8323262e 100644 --- a/storm/x86/port.c +++ b/storm/x86/port.c @@ -25,6 +25,8 @@ #include #include +#define DELAY_PORT 0x80 + // Linked list over allocated I/O regions. port_range_type *port_list = NULL; @@ -133,7 +135,7 @@ return_type port_range_register(unsigned int start, unsigned int ports, char *de } // If the TSS is too small, expand it. - if (current_tss->iomap_size < BIT_IN_BYTES(start + ports - 1)) + if (current_tss->iomap_size < BIT_IN_BYTES(MAX_OF_TWO(start + ports - 1, DELAY_PORT))) { int old_iomap_size = current_tss->iomap_size; storm_tss_type *old_tss = current_tss; @@ -151,7 +153,7 @@ return_type port_range_register(unsigned int start, unsigned int ports, char *de current_tss->iomap_size = BIT_IN_BYTES(start + ports); memory_set_uint8_t(current_tss->iomap + old_iomap_size, 0xFF, current_tss->iomap_size - old_iomap_size); DEBUG_MESSAGE(DEBUG, "Clearing %u bytes", current_tss->iomap_size - old_iomap_size) - + thread_unlink(old_tss->thread_id); current_tss_node = thread_link(current_tss); @@ -188,6 +190,10 @@ return_type port_range_register(unsigned int start, unsigned int ports, char *de BIT_CLEAR(current_tss->iomap[port / 8], port % 8); } + // Also make sure all processes working with I/O can use the delay port, since it's sometimes needed when dealing + // with ISA hardware. + BIT_CLEAR(current_tss->iomap[DELAY_PORT / 8], DELAY_PORT % 8); + // Since this thread has got a new TSS, we have to check if it is an IRQ handler. If so, we must update the TSS pointer. for (index = 0; index < IRQ_LEVELS; index++) { @@ -265,7 +271,7 @@ void port_range_free_all(thread_id_type thread_id) // FIXME: This algorithm feels a little sub-optimal... or is it just me? // FIXME: Don't repeat a lot of the code from port_range_unregister, but rather use a common helper method that // both of these methods can call to perform the actual work. - + // Loop until we find no more matches. while (TRUE) {