wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
Albert ARIBAUD | 60fbc8d | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 3 | * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se> |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4 | * |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | * Based on msbios.c from rolo 1.6: |
| 26 | *---------------------------------------------------------------------- |
| 27 | * (C) Copyright 2000 |
| 28 | * Sysgo Real-Time Solutions GmbH |
| 29 | * Klein-Winternheim, Germany |
| 30 | *---------------------------------------------------------------------- |
| 31 | */ |
| 32 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 33 | #include "bios.h" |
| 34 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 35 | /* |
| 36 | * During it's initialization phase, before switching to protected |
| 37 | * mode, the Linux Kernel makes a few BIOS calls. This won't work |
| 38 | * if the board does not have a BIOS. |
| 39 | * |
| 40 | * This is a very minimalisic BIOS that supplies just enough |
| 41 | * functionality to keep the Linux Kernel happy. It is NOT |
| 42 | * a general purpose replacement for a real BIOS !! |
| 43 | */ |
| 44 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 45 | .section .bios, "ax" |
| 46 | .code16 |
| 47 | .org 0 |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | /* a call to f000:0 should warmboot */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 49 | jmp realmode_reset |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 50 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 51 | .globl rm_int00 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 52 | .hidden rm_int00 |
| 53 | .type rm_int00, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 54 | rm_int00: |
| 55 | pushw $0 |
| 56 | jmp any_interrupt16 |
| 57 | .globl rm_int01 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 58 | .hidden rm_int01 |
| 59 | .type rm_int01, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 60 | rm_int01: |
| 61 | pushw $1 |
| 62 | jmp any_interrupt16 |
| 63 | .globl rm_int02 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 64 | .hidden rm_int02 |
| 65 | .type rm_int02, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 66 | rm_int02: |
| 67 | pushw $2 |
| 68 | jmp any_interrupt16 |
| 69 | .globl rm_int03 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 70 | .hidden rm_int03 |
| 71 | .type rm_int03, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 72 | rm_int03: |
| 73 | pushw $3 |
| 74 | jmp any_interrupt16 |
| 75 | .globl rm_int04 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 76 | .hidden rm_int04 |
| 77 | .type rm_int04, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 78 | rm_int04: |
| 79 | pushw $4 |
| 80 | jmp any_interrupt16 |
| 81 | .globl rm_int05 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 82 | .hidden rm_int05 |
| 83 | .type rm_int05, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 84 | rm_int05: |
| 85 | pushw $5 |
| 86 | jmp any_interrupt16 |
| 87 | .globl rm_int06 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 88 | .hidden rm_int06 |
| 89 | .type rm_int06, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 90 | rm_int06: |
| 91 | pushw $6 |
| 92 | jmp any_interrupt16 |
| 93 | .globl rm_int07 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 94 | .hidden rm_int07 |
| 95 | .type rm_int07, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 96 | rm_int07: |
| 97 | pushw $7 |
| 98 | jmp any_interrupt16 |
| 99 | .globl rm_int08 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 100 | .hidden rm_int08 |
| 101 | .type rm_int08, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 102 | rm_int08: |
| 103 | pushw $8 |
| 104 | jmp any_interrupt16 |
| 105 | .globl rm_int09 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 106 | .hidden rm_int09 |
| 107 | .type rm_int09, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 108 | rm_int09: |
| 109 | pushw $9 |
| 110 | jmp any_interrupt16 |
| 111 | .globl rm_int0a |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 112 | .hidden rm_int0a |
| 113 | .type rm_int0a, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 114 | rm_int0a: |
| 115 | pushw $10 |
| 116 | jmp any_interrupt16 |
| 117 | .globl rm_int0b |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 118 | .hidden rm_int0b |
| 119 | .type rm_int0b, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 120 | rm_int0b: |
| 121 | pushw $11 |
| 122 | jmp any_interrupt16 |
| 123 | .globl rm_int0c |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 124 | .hidden rm_int0c |
| 125 | .type rm_int0c, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 126 | rm_int0c: |
| 127 | pushw $12 |
| 128 | jmp any_interrupt16 |
| 129 | .globl rm_int0d |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 130 | .hidden rm_int0d |
| 131 | .type rm_int0d, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 132 | rm_int0d: |
| 133 | pushw $13 |
| 134 | jmp any_interrupt16 |
| 135 | .globl rm_int0e |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 136 | .hidden rm_int0e |
| 137 | .type rm_int0e, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 138 | rm_int0e: |
| 139 | pushw $14 |
| 140 | jmp any_interrupt16 |
| 141 | .globl rm_int0f |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 142 | .hidden rm_int0f |
| 143 | .type rm_int0f, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 144 | rm_int0f: |
| 145 | pushw $15 |
| 146 | jmp any_interrupt16 |
| 147 | .globl rm_int10 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 148 | .hidden rm_int10 |
| 149 | .type rm_int10, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 150 | rm_int10: |
| 151 | pushw $16 |
| 152 | jmp any_interrupt16 |
| 153 | .globl rm_int11 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 154 | .hidden rm_int11 |
| 155 | .type rm_int11, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 156 | rm_int11: |
| 157 | pushw $17 |
| 158 | jmp any_interrupt16 |
| 159 | .globl rm_int12 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 160 | .hidden rm_int12 |
| 161 | .type rm_int12, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 162 | rm_int12: |
| 163 | pushw $18 |
| 164 | jmp any_interrupt16 |
| 165 | .globl rm_int13 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 166 | .hidden rm_int13 |
| 167 | .type rm_int13, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 168 | rm_int13: |
| 169 | pushw $19 |
| 170 | jmp any_interrupt16 |
| 171 | .globl rm_int14 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 172 | .hidden rm_int14 |
| 173 | .type rm_int14, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 174 | rm_int14: |
| 175 | pushw $20 |
| 176 | jmp any_interrupt16 |
| 177 | .globl rm_int15 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 178 | .hidden rm_int15 |
| 179 | .type rm_int15, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 180 | rm_int15: |
| 181 | pushw $21 |
| 182 | jmp any_interrupt16 |
| 183 | .globl rm_int16 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 184 | .hidden rm_int16 |
| 185 | .type rm_int16, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 186 | rm_int16: |
| 187 | pushw $22 |
| 188 | jmp any_interrupt16 |
| 189 | .globl rm_int17 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 190 | .hidden rm_int17 |
| 191 | .type rm_int17, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 192 | rm_int17: |
| 193 | pushw $23 |
| 194 | jmp any_interrupt16 |
| 195 | .globl rm_int18 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 196 | .hidden rm_int18 |
| 197 | .type rm_int18, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 198 | rm_int18: |
| 199 | pushw $24 |
| 200 | jmp any_interrupt16 |
| 201 | .globl rm_int19 |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 202 | .hidden rm_int19 |
| 203 | .type rm_int19, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 204 | rm_int19: |
| 205 | pushw $25 |
| 206 | jmp any_interrupt16 |
| 207 | .globl rm_int1a |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 208 | .hidden rm_int1a |
| 209 | .type rm_int1a, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 210 | rm_int1a: |
| 211 | pushw $26 |
| 212 | jmp any_interrupt16 |
| 213 | .globl rm_int1b |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 214 | .hidden rm_int1b |
| 215 | .type rm_int1b, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 216 | rm_int1b: |
| 217 | pushw $27 |
| 218 | jmp any_interrupt16 |
| 219 | .globl rm_int1c |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 220 | .hidden rm_int1c |
| 221 | .type rm_int1c, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 222 | rm_int1c: |
| 223 | pushw $28 |
| 224 | jmp any_interrupt16 |
| 225 | .globl rm_int1d |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 226 | .hidden rm_int1d |
| 227 | .type rm_int1d, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 228 | rm_int1d: |
| 229 | pushw $29 |
| 230 | jmp any_interrupt16 |
| 231 | .globl rm_int1e |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 232 | .hidden rm_int1e |
| 233 | .type rm_int1e, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 234 | rm_int1e: |
| 235 | pushw $30 |
| 236 | jmp any_interrupt16 |
| 237 | .globl rm_int1f |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 238 | .hidden rm_int1f |
| 239 | .type rm_int1f, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 240 | rm_int1f: |
| 241 | pushw $31 |
| 242 | jmp any_interrupt16 |
| 243 | .globl rm_def_int |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 244 | .hidden rm_def_int |
| 245 | .type rm_def_int, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 246 | rm_def_int: |
| 247 | iret |
| 248 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 249 | /* |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 250 | * All interrupt jumptable entries jump to here after pushing the |
| 251 | * interrupt vector number onto the stack. |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 252 | */ |
| 253 | any_interrupt16: |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 254 | MAKE_BIOS_STACK |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 255 | |
| 256 | gs movw OFFS_VECTOR(%bp), %ax |
| 257 | cmpw $0x10, %ax |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 258 | je Lint_10h |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 259 | cmpw $0x11, %ax |
| 260 | je Lint_11h |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 261 | cmpw $0x12, %ax |
| 262 | je Lint_12h |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 263 | cmpw $0x13, %ax |
| 264 | je Lint_13h |
| 265 | cmpw $0x15, %ax |
| 266 | je Lint_15h |
| 267 | cmpw $0x16, %ax |
| 268 | je Lint_16h |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 269 | cmpw $0x1a, %ax |
| 270 | je Lint_1ah |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 271 | movw $0xffff, %ax |
| 272 | jmp Lout |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 273 | Lint_10h: |
| 274 | /* VGA BIOS services */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 275 | call bios_10h |
| 276 | jmp Lout |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 277 | Lint_11h: |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 278 | call bios_11h |
| 279 | jmp Lout |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 280 | Lint_12h: |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 281 | call bios_12h |
| 282 | jmp Lout |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 283 | Lint_13h: |
| 284 | /* BIOS disk services */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 285 | call bios_13h |
| 286 | jmp Lout |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 287 | Lint_15h: |
| 288 | /* Misc. BIOS services */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 289 | call bios_15h |
| 290 | jmp Lout |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 291 | Lint_16h: |
| 292 | /* keyboard services */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 293 | call bios_16h |
| 294 | jmp Lout |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 295 | Lint_1ah: |
| 296 | /* PCI bios */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 297 | call bios_1ah |
| 298 | jmp Lout |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 299 | Lout: |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 300 | cmpw $0, %ax |
| 301 | je Lhandeled |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 302 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 303 | /* |
| 304 | * Insert code for unhandeled INTs here. |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 305 | * |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 306 | * ROLO prints a message to the console we could do that but then |
| 307 | * we're in 16bit mode so we'll have to get back into 32bit mode |
| 308 | * to use the console I/O routines (if we do this we should make |
| 309 | * int 0x10 and int 0x16 work as well) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 310 | */ |
| 311 | Lhandeled: |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 312 | RESTORE_CALLERS_STACK |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 313 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 314 | /* dump vector number */ |
| 315 | addw $2,%sp |
| 316 | |
| 317 | /* return from interrupt */ |
| 318 | iret |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 319 | |
| 320 | /* |
| 321 | ************************************************************ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 322 | * BIOS interrupt 10h -- VGA services |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 323 | ************************************************************ |
| 324 | */ |
| 325 | bios_10h: |
| 326 | gs movw OFFS_AX(%bp), %ax |
| 327 | shrw $8, %ax |
| 328 | cmpw $0x3, %ax |
| 329 | je Lcur_pos |
| 330 | cmpw $0xf, %ax |
| 331 | je Lvid_state |
| 332 | cmpw $0x12, %ax |
| 333 | je Lvid_cfg |
| 334 | movw $0xffff, %ax |
| 335 | ret |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 336 | Lcur_pos: |
| 337 | /* Read Cursor Position and Size */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 338 | gs movw $0, OFFS_CX(%bp) |
| 339 | gs movw $0, OFFS_DX(%bp) |
| 340 | xorw %ax, %ax |
| 341 | ret |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 342 | Lvid_state: |
| 343 | /* Get Video State - 80 columns, 80x25, 16 colors */ |
| 344 | gs movw $(80 << 8|0x03), OFFS_AX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 345 | gs movw $0, OFFS_BX(%bp) |
| 346 | xorw %ax, %ax |
| 347 | ret |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 348 | Lvid_cfg: |
| 349 | /* Video Subsystem Configuration (EGA/VGA) - indicate CGA/MDA/HGA */ |
| 350 | gs movw $0x10, OFFS_BX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 351 | xorw %ax, %ax |
| 352 | ret |
| 353 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 354 | /* |
| 355 | ************************************************************ |
| 356 | * BIOS interrupt 11h -- Equipment determination |
| 357 | ************************************************************ |
| 358 | */ |
| 359 | |
| 360 | bios_11h: |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 361 | cs movw bios_equipment, %ax |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 362 | gs movw %ax, OFFS_AX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 363 | xorw %ax, %ax |
| 364 | ret |
| 365 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 366 | /* |
| 367 | ************************************************************ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 368 | * BIOS interrupt 12h -- Get Memory Size |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 369 | ************************************************************ |
| 370 | */ |
| 371 | bios_12h: |
| 372 | cs movw ram_in_64kb_chunks, %ax |
| 373 | cmpw $0xa, %ax |
| 374 | ja b12_more_than_640k |
| 375 | shlw $6, %ax |
| 376 | jmp b12_return |
| 377 | b12_more_than_640k: |
| 378 | movw $0x280, %ax |
| 379 | b12_return: |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 380 | /* return number of kilobytes in ax */ |
| 381 | gs movw %ax, OFFS_AX(%bp) |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 382 | |
| 383 | gs movw OFFS_FLAGS(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 384 | |
| 385 | /* clear carry -- function succeeded */ |
| 386 | andw $0xfffe, %ax |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 387 | gs movw %ax, OFFS_FLAGS(%bp) |
| 388 | |
| 389 | xorw %ax, %ax |
| 390 | ret |
| 391 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 392 | /* |
| 393 | ************************************************************ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 394 | * BIOS interrupt 13h -- Disk services |
| 395 | ************************************************************ |
| 396 | */ |
| 397 | bios_13h: |
| 398 | gs movw OFFS_AX(%bp), %ax |
| 399 | shrw $8, %ax |
| 400 | cmpw $0x15, %ax |
| 401 | je Lfunc_15h |
| 402 | movw $0xffff, %ax |
| 403 | ret |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 404 | Lfunc_15h: |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 405 | gs movw OFFS_AX(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 406 | |
| 407 | /* return AH=0->drive not present */ |
| 408 | andw $0x00ff, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 409 | gs movw %ax, OFFS_AX(%bp) |
| 410 | xorw %ax, %ax |
| 411 | ret |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 412 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 413 | /* |
| 414 | *********************************************************** |
| 415 | * BIOS interrupt 15h -- Miscellaneous services |
| 416 | *********************************************************** |
| 417 | */ |
| 418 | bios_15h: |
| 419 | gs movw OFFS_AX(%bp), %ax |
| 420 | shrw $8, %ax |
| 421 | cmpw $0xc0, %ax |
| 422 | je Lfunc_c0h |
| 423 | cmpw $0xe8, %ax |
| 424 | je Lfunc_e8h |
| 425 | cmpw $0x88, %ax |
| 426 | je Lfunc_88h |
| 427 | movw $0xffff, %ax |
| 428 | ret |
| 429 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 430 | Lfunc_c0h: |
| 431 | /* Return System Configuration Parameters (PS2 only) */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 432 | gs movw OFFS_FLAGS(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 433 | |
| 434 | /* return carry -- function not supported */ |
| 435 | orw $1, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 436 | gs movw %ax, OFFS_FLAGS(%bp) |
| 437 | xorw %ax, %ax |
| 438 | ret |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 439 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 440 | Lfunc_e8h: |
| 441 | gs movw OFFS_AX(%bp), %ax |
| 442 | andw $0xff, %ax |
| 443 | cmpw $1, %ax |
| 444 | je Lfunc_e801h |
| 445 | gs movw OFFS_FLAGS(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 446 | |
| 447 | /* return carry -- function not supported */ |
| 448 | orw $1, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 449 | gs movw %ax, OFFS_FLAGS(%bp) |
| 450 | xorw %ax, %ax |
| 451 | ret |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 452 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 453 | Lfunc_e801h: |
| 454 | /* Get memory size for >64M Configurations */ |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 455 | cs movw ram_in_64kb_chunks, %ax |
| 456 | cmpw $0x100, %ax |
| 457 | ja e801_more_than_16mb |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 458 | |
| 459 | /* multiply by 64 */ |
| 460 | shlw $6, %ax |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 461 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 462 | /* 1st meg does not count */ |
| 463 | subw $0x400, %ax |
| 464 | |
| 465 | /* return memory size between 1M and 16M in 1kb chunks in AX and CX */ |
| 466 | gs movw %ax, OFFS_AX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 467 | gs movw %ax, OFFS_CX(%bp) |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 468 | |
| 469 | /* set BX and DX to 0*/ |
| 470 | gs movw $0, OFFS_BX(%bp) |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 471 | gs movw $0, OFFS_DX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 472 | gs movw OFFS_FLAGS(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 473 | |
| 474 | /* clear carry -- function succeeded */ |
| 475 | andw $0xfffe, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 476 | gs movw %ax, OFFS_FLAGS(%bp) |
| 477 | xorw %ax, %ax |
| 478 | ret |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 479 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 480 | e801_more_than_16mb: |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 481 | /* subtract 16MB */ |
| 482 | subw $0x100, %ax |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 483 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 484 | /* return 0x3c00 (16MB-1MB) in AX and CX */ |
| 485 | gs movw $0x3c00, OFFS_AX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 486 | gs movw $0x3c00, OFFS_CX(%bp) |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 487 | |
| 488 | /* set BX and DX to number of 64kb chunks above 16MB */ |
| 489 | gs movw %ax, OFFS_BX(%bp) |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 490 | gs movw %ax, OFFS_DX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 491 | |
| 492 | gs movw OFFS_FLAGS(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 493 | |
| 494 | /* clear carry -- function succeeded */ |
| 495 | andw $0xfffe, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 496 | gs movw %ax, OFFS_FLAGS(%bp) |
| 497 | xorw %ax, %ax |
| 498 | ret |
| 499 | |
| 500 | Lfunc_88h: |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 501 | cs movw ram_in_64kb_chunks, %ax |
| 502 | cmpw $0x100, %ax |
| 503 | jna b88_not_more_than16 |
| 504 | movw $0x100, %ax |
| 505 | b88_not_more_than16: |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 506 | shlw $6, %ax |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 507 | |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 508 | /* 1st meg does not count */ |
| 509 | subw $0x400, %ax |
| 510 | |
| 511 | /* return number of kilobytes between 16MB and 16MB in ax */ |
| 512 | gs movw %ax, OFFS_AX(%bp) |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 513 | |
| 514 | gs movw OFFS_FLAGS(%bp), %ax |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 515 | |
| 516 | /* clear carry -- function succeeded */ |
| 517 | andw $0xfffe, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 518 | gs movw %ax, OFFS_FLAGS(%bp) |
| 519 | |
| 520 | xorw %ax, %ax |
| 521 | ret |
| 522 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 523 | /* |
| 524 | ************************************************************ |
| 525 | * BIOS interrupt 16h -- keyboard services |
| 526 | ************************************************************ |
| 527 | */ |
| 528 | bios_16h: |
| 529 | gs movw OFFS_AX(%bp), %ax |
| 530 | shrw $8, %ax |
| 531 | cmpw $0x03, %ax |
| 532 | je Lfunc_03h |
| 533 | movw $0xffff, %ax |
| 534 | ret |
| 535 | Lfunc_03h: |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 536 | /* do nothing -- function not supported */ |
| 537 | xorw %ax, %ax |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 538 | ret |
| 539 | |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 540 | /* |
| 541 | ************************************************************ |
| 542 | * BIOS interrupt 1ah -- PCI bios |
| 543 | ************************************************************ |
| 544 | */ |
| 545 | bios_1ah: |
| 546 | gs movw OFFS_AX(%bp), %ax |
| 547 | cmpb $0xb1, %ah |
| 548 | je Lfunc_b1h |
| 549 | movw $0xffff, %ax |
| 550 | ret |
| 551 | Lfunc_b1h: |
| 552 | call realmode_pci_bios |
Graeme Russ | 6dda131 | 2011-12-19 20:00:40 +1100 | [diff] [blame] | 553 | |
| 554 | /* do nothing -- function not supported */ |
| 555 | xorw %ax, %ax |
wdenk | abda5ca | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 556 | ret |
| 557 | |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 558 | |
| 559 | .globl ram_in_64kb_chunks |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 560 | .hidden ram_in_64kb_chunks |
| 561 | .type ram_in_64kb_chunks, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 562 | ram_in_64kb_chunks: |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 563 | .word 0 |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 564 | |
| 565 | .globl bios_equipment |
Graeme Russ | 1aafcc9 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 566 | .hidden bios_equipment |
| 567 | .type bios_equipment, @function |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 568 | bios_equipment: |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 569 | .word 0 |