2009-05-07 05:35:59 +02:00
|
|
|
// Rom layout and bios assembler to C interface.
|
|
|
|
//
|
2013-12-03 17:50:49 +01:00
|
|
|
// Copyright (C) 2009-2013 Kevin O'Connor <kevin@koconnor.net>
|
2009-05-07 05:35:59 +02:00
|
|
|
//
|
|
|
|
// This file may be distributed under the terms of the GNU LGPLv3 license.
|
|
|
|
|
|
|
|
|
2013-12-01 01:16:15 +01:00
|
|
|
#include "asm-offsets.h" // BREGS_*
|
2011-12-19 06:07:55 +01:00
|
|
|
#include "config.h" // CONFIG_*
|
2009-05-07 05:35:59 +02:00
|
|
|
#include "entryfuncs.S" // ENTRY_*
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
* Rom Header
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
.section .rom.header
|
2014-06-03 18:28:58 +02:00
|
|
|
.code16
|
2009-05-07 05:35:59 +02:00
|
|
|
.global _rom_header, _rom_header_size, _rom_header_checksum
|
|
|
|
_rom_header:
|
|
|
|
.word 0xaa55
|
|
|
|
_rom_header_size:
|
|
|
|
.byte 0
|
|
|
|
_rom_header_entry:
|
|
|
|
jmp _optionrom_entry
|
|
|
|
_rom_header_checksum:
|
2010-01-01 18:53:32 +01:00
|
|
|
.byte 0
|
|
|
|
_rom_header_other:
|
2011-12-19 06:07:55 +01:00
|
|
|
.space 17
|
|
|
|
_rom_header_pcidata:
|
|
|
|
#if CONFIG_VGA_PCI == 1
|
|
|
|
.word rom_pci_data
|
|
|
|
#else
|
|
|
|
.word 0
|
|
|
|
#endif
|
|
|
|
_rom_header_pnpdata:
|
|
|
|
.word 0
|
2011-12-24 05:01:48 +01:00
|
|
|
_rom_header_other2:
|
|
|
|
.word 0
|
|
|
|
_rom_header_signature:
|
|
|
|
.asciz "IBM"
|
2009-05-07 05:35:59 +02:00
|
|
|
|
2019-03-08 11:42:25 +01:00
|
|
|
#if CONFIG_VGA_ATI
|
|
|
|
#include "ati-tables.S"
|
|
|
|
#endif
|
2009-05-07 05:35:59 +02:00
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
* Entry points
|
|
|
|
****************************************************************/
|
|
|
|
|
2014-02-06 04:47:29 +01:00
|
|
|
// This macro implements a call while avoiding instructions
|
|
|
|
// that old versions of x86emu have problems with.
|
|
|
|
.macro VGA_CALLL cfunc
|
2015-04-09 23:15:23 +02:00
|
|
|
#if CONFIG_VGA_FIXUP_ASM
|
2015-04-09 23:20:16 +02:00
|
|
|
pushw %ax
|
2014-02-06 04:47:29 +01:00
|
|
|
callw \cfunc
|
2015-04-09 23:15:23 +02:00
|
|
|
#else
|
|
|
|
calll \cfunc
|
|
|
|
#endif
|
2014-02-06 04:47:29 +01:00
|
|
|
.endm
|
|
|
|
|
|
|
|
// This macro is the same as ENTRY_ARG except VGA_CALLL is used.
|
2013-11-30 18:52:44 +01:00
|
|
|
.macro ENTRY_ARG_VGA cfunc
|
|
|
|
cli
|
|
|
|
cld
|
|
|
|
PUSHBREGS
|
|
|
|
movw %ss, %ax // Move %ss to %ds
|
|
|
|
movw %ax, %ds
|
|
|
|
movl %esp, %ebx // Backup %esp, then zero high bits
|
|
|
|
movzwl %sp, %esp
|
|
|
|
movl %esp, %eax // First arg is pointer to struct bregs
|
2014-02-06 04:47:29 +01:00
|
|
|
VGA_CALLL \cfunc
|
2013-11-30 18:52:44 +01:00
|
|
|
movl %ebx, %esp // Restore %esp (including high bits)
|
|
|
|
POPBREGS
|
|
|
|
.endm
|
|
|
|
|
2012-01-21 17:53:44 +01:00
|
|
|
DECLFUNC entry_104f05
|
|
|
|
entry_104f05:
|
2013-11-30 18:52:44 +01:00
|
|
|
ENTRY_ARG_VGA vbe_104f05
|
2012-01-21 17:53:44 +01:00
|
|
|
lretw
|
|
|
|
|
2009-05-07 05:35:59 +02:00
|
|
|
DECLFUNC _optionrom_entry
|
|
|
|
_optionrom_entry:
|
2013-11-30 18:52:44 +01:00
|
|
|
ENTRY_ARG_VGA vga_post
|
2009-05-07 05:35:59 +02:00
|
|
|
lretw
|
|
|
|
|
2009-05-17 05:31:27 +02:00
|
|
|
DECLFUNC entry_10
|
|
|
|
entry_10:
|
2013-11-30 18:52:44 +01:00
|
|
|
ENTRY_ARG_VGA handle_10
|
2009-05-17 05:31:27 +02:00
|
|
|
iretw
|
2013-12-01 01:16:15 +01:00
|
|
|
|
2015-03-17 16:37:25 +01:00
|
|
|
#define VGA_CUSTOM_BDA_FLAGS 0xb9
|
|
|
|
#define BF_EXTRA_STACK 0x40
|
|
|
|
|
2013-12-01 01:16:15 +01:00
|
|
|
// Entry point using extra stack
|
|
|
|
DECLFUNC entry_10_extrastack
|
|
|
|
entry_10_extrastack:
|
|
|
|
cli
|
|
|
|
cld
|
2015-03-17 16:37:25 +01:00
|
|
|
pushw %ds
|
2013-12-01 01:16:15 +01:00
|
|
|
pushl %eax
|
2015-03-17 16:37:25 +01:00
|
|
|
|
|
|
|
movw $SEG_BDA, %ax // Check if extra stack is enabled
|
|
|
|
movw %ax, %ds
|
|
|
|
testb $BF_EXTRA_STACK, VGA_CUSTOM_BDA_FLAGS
|
|
|
|
jz 1f
|
|
|
|
|
|
|
|
movw %cs:ExtraStackSeg, %ds // Set %ds:%eax to space on ExtraStack
|
2014-11-05 15:05:36 +01:00
|
|
|
movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-16), %eax
|
2014-10-21 08:23:02 +02:00
|
|
|
SAVEBREGS_POP_DSEAX // Save registers on extra stack
|
2014-11-05 15:05:36 +01:00
|
|
|
movl %esp, PUSHBREGS_size+8(%eax)
|
|
|
|
movw %ss, PUSHBREGS_size+12(%eax)
|
2013-12-09 23:27:54 +01:00
|
|
|
popl BREGS_code(%eax)
|
|
|
|
popw BREGS_flags(%eax)
|
2013-12-01 01:16:15 +01:00
|
|
|
|
|
|
|
movw %ds, %dx // Setup %ss/%esp and call function
|
|
|
|
movw %dx, %ss
|
|
|
|
movl %eax, %esp
|
2014-02-06 04:47:29 +01:00
|
|
|
VGA_CALLL handle_10
|
2013-12-01 01:16:15 +01:00
|
|
|
|
|
|
|
movl %esp, %eax // Restore registers and return
|
2014-11-05 15:05:36 +01:00
|
|
|
movw PUSHBREGS_size+12(%eax), %ss
|
|
|
|
movl PUSHBREGS_size+8(%eax), %esp
|
2013-12-01 01:16:15 +01:00
|
|
|
popl %edx
|
|
|
|
popw %dx
|
|
|
|
pushw BREGS_flags(%eax)
|
|
|
|
pushl BREGS_code(%eax)
|
2014-10-21 08:23:02 +02:00
|
|
|
RESTOREBREGS_DSEAX
|
2013-12-01 01:16:15 +01:00
|
|
|
iretw
|
2014-10-18 04:15:42 +02:00
|
|
|
|
2015-03-17 16:37:25 +01:00
|
|
|
1: // Use regular entry point if the extra stack is disabled
|
|
|
|
popl %eax
|
|
|
|
popw %ds
|
|
|
|
jmp entry_10
|
|
|
|
|
2014-10-18 04:15:42 +02:00
|
|
|
// Timer irq handling
|
|
|
|
DECLFUNC entry_timer_hook
|
|
|
|
entry_timer_hook:
|
|
|
|
ENTRY handle_timer_hook
|
|
|
|
ljmpw *%cs:Timer_Hook_Resume
|
|
|
|
|
|
|
|
// Timer irq handling on extra stack
|
|
|
|
DECLFUNC entry_timer_hook_extrastack
|
|
|
|
entry_timer_hook_extrastack:
|
|
|
|
cli
|
|
|
|
cld
|
|
|
|
pushw %ds // Set %ds:%eax to space on ExtraStack
|
|
|
|
pushl %eax
|
|
|
|
movw %cs:ExtraStackSeg, %ds
|
2014-11-05 15:05:36 +01:00
|
|
|
movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-8), %eax
|
2014-10-18 04:15:42 +02:00
|
|
|
SAVEBREGS_POP_DSEAX
|
2014-11-05 15:05:36 +01:00
|
|
|
movl %esp, PUSHBREGS_size(%eax)
|
|
|
|
movw %ss, PUSHBREGS_size+4(%eax)
|
2014-10-18 04:15:42 +02:00
|
|
|
|
|
|
|
movw %ds, %dx // Setup %ss/%esp and call function
|
|
|
|
movw %dx, %ss
|
|
|
|
movl %eax, %esp
|
|
|
|
calll handle_timer_hook
|
|
|
|
|
|
|
|
movl %esp, %eax // Restore registers and return
|
2014-11-05 15:05:36 +01:00
|
|
|
movw PUSHBREGS_size+4(%eax), %ss
|
|
|
|
movl PUSHBREGS_size(%eax), %esp
|
2014-10-18 04:15:42 +02:00
|
|
|
RESTOREBREGS_DSEAX
|
|
|
|
ljmpw *%cs:Timer_Hook_Resume
|