bios: No new line at EOF nit fix
[linux-2.6/x86.git] / tools / kvm / bios / int10-real.S
blob279392074b7affced68384025371580dd96ed45b
1 /*
2  * IRQ 0x10 handler
3  */
5 #include <kvm/bios.h>
6 #include <kvm/assembly.h>
8 /*
9  * NOTES:
10  * ======
11  * 1) The code is supposed to enter with CS somewhere in BDA_START area so prepare real mode
12  *    interrupt table properly (if you screw it up -- there is no way to restore
13  *    anything, the code is NOT PORTABLE by any means, it's BIOS after all)
14  *
15  * 2) We switch to own stack which is BIOS_STACK_SIZE bytes long saving all caller's
16  *    data we clobber. The stack is not that deep so mask interrupts at entry and dont
17  *    use 'push' too much
18  */
20         .org 0
21         .code16gcc
23 .macro stack_bios seg
24         mov %ss, %\seg:(ss_old)
25         mov %sp, %\seg:(sp_old)
26         mov %si, %\seg:(stack_clobber)
27         mov $BIOS_STACK_SEG, %si
28         mov %si, %ss
29         mov $BIOS_STACK_SIZE, %sp
30         mov %\seg:(stack_clobber), %si
31 .endm
33 .macro stack_norm seg
34         mov %\seg:(ss_old), %ss
35         mov %\seg:(sp_old), %sp
36 .endm
38 .macro opcode_switch ocode, label
39         test \label, %ah
40         je \label
41 .endm
44  * int 10 - video - write character and advance cursor (tty write)
45  *      ah = 0eh
46  *      al = character
47  *      bh = display page (alpha modes)
48  *      bl = foreground color (graphics modes)
49  *
50  * We ignore bx settings
51  */
52 ENTRY(___int10)
53         cli
54         opcode_switch $0x0e, putchar
55         jmp out
58  * put char in AL at current cursor and
59  * increment cursor position
60  */
61 putchar:
62         stack_bios cs
64         push %fs
65         push %bx
67         mov $VIDEO_BASE_SEG, %bx
68         mov %bx, %fs
69         mov %cs:(cursor), %bx
70         mov %al, %fs:(%bx)
71         inc %bx
72         test $VIDEO_SIZE, %bx
73         jb putchar_new
74         xor %bx, %bx
75 putchar_new:
76         mov %bx, %fs:(cursor)
78         pop %bx
79         pop %fs
81         stack_norm cs
82 out:
83         sti
84         IRET
86  * private IRQ data
87  */
88 cursor:         .word 0
91  * must be last in this file
92  */
93         __ALIGN
94 ss_old:         .word 0
95 sp_old:         .word 0
96 stack_clobber:  .word 0
97 ENTRY_END(___int10_end)