URL
https://opencores.org/ocsvn/s80186/s80186/trunk
Subversion Repositories s80186
[/] [s80186/] [trunk/] [bios/] [entry.S] - Rev 2
Compare with Previous | Blame | View Log
// Copyright Jamie Iles, 2017//// This file is part of s80x86.//// s80x86 is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.//// s80x86 is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with s80x86. If not, see <http://www.gnu.org/licenses/>..code16.section .reset.text, "ax".globl _reset_reset:ljmp $0xf000, $_start.section .model, "a".byte 0xff.byte 0x00.section .entry.text, "ax".globl _start_start:// Wait for SDRAM to initializemov $0xfffc, %dxmov $1, %ax1:in (%dx), %axcmp $0x1, %axjne 1bmov %cs, %axmov %ax, %ssmov %ax, %dsmov %ax, %es// Clear bssmov $bss_start, %dimov $bss_end, %cxsub $bss_start, %cxmov $0, %alrep stosb// Initialize rw datamov $data_start, %dimov $data_end, %cxsub $data_start, %cxmov $_data_load, %sirep movsbmovw $stack_start, %spjmp root.section .databios_ss:.word 0xf000bios_sp:.word stack_start.section .bsssaved_ss:.word 0saved_sp:.word 0.section .text, "ax".globl irq_entryirq_entry:// Save current stack pointer, load BIOS stackmov %ss, %cs:saved_ssmov %sp, %cs:saved_spmov %cs:bios_ss, %ssmov %cs:bios_sp, %sp// Save registers, setup stack framepush %dspushamov %sp, %bppush %bp// Load flags from iret frame, store in callregsmov %cs:saved_ss, %dsmov %cs:saved_sp, %bxmov 0(%bx), %axmov 6(%bx), %bxmov %bx, 18(%bp)// Use SS as DS inside the BIOS for stack-local variables that are passed// by addressmov %ss, %bpmov %bp, %dscall *%ax// Discard regs pointer parameteradd $2, %spmov %sp, %bp// Write possibly updated flags to the iret framemov 18(%bp), %axmov %cs:saved_ss, %dsmov %cs:saved_sp, %bxmov %ax, 6(%bx)// Restore all regs apart from flags - the iret frame has been updated// alreadypopapop %ds// Restore the callers stackmov %cs:saved_ss, %ssmov %cs:saved_sp, %spadd $2, %spiret.macro int_handler vector, function.pushsection .rodata.vectors.align 4.word \vector.word \function.popsection.endmstub_irq:iretint_handler 0x1c, stub_irqtimer_irq:clipush %dspush %bxpush %axpush %dxmovw $0x40, %bxmov %bx, %dsmovw $0x6c, %bxadd $1, %ds:0(%bx)adc $0, %ds:2(%bx)int $0x1cmovb $0x20, %aloutb %al, $0x20pop %dxpop %axpop %bxpop %dsiretint_handler 0x08, timer_irq.pushsection ".bios_date", "a".ascii BIOS_BUILD_DATE.popsection
