Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2009-2010 coresystems GmbH |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
Stefan Reinauer | 6c641ee | 2009-09-23 21:52:45 +0000 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <device/pci.h> |
| 22 | #include <string.h> |
| 23 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 24 | #include <arch/io.h> |
Stefan Reinauer | 42dc721 | 2009-10-24 00:47:07 +0000 | [diff] [blame] | 25 | #include <arch/registers.h> |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 26 | #include <console/console.h> |
Libra Li | c143693 | 2009-12-23 19:16:47 +0000 | [diff] [blame] | 27 | #include <arch/interrupt.h> |
| 28 | |
Stefan Reinauer | 074356e | 2009-10-25 19:50:47 +0000 | [diff] [blame] | 29 | #define REALMODE_BASE ((void *)0x600) |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 30 | |
| 31 | struct realmode_idt { |
| 32 | u16 offset, cs; |
| 33 | }; |
| 34 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 35 | void x86_exception(struct eregs *info); |
| 36 | |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 37 | /* From x86_asm.S */ |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 38 | extern unsigned char __idt_handler, __idt_handler_size; |
| 39 | extern unsigned char __realmode_code, __realmode_code_size; |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 40 | extern unsigned char __realmode_call, __realmode_interrupt; |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 41 | |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 42 | void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx, |
| 43 | u32 esi, u32 edi) __attribute__((regparm(0))) = (void *)&__realmode_call; |
| 44 | |
| 45 | void (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx, u32 edx, |
| 46 | u32 esi, u32 edi) __attribute__((regparm(0))) = (void *)&__realmode_interrupt; |
| 47 | |
| 48 | #define FAKE_MEMORY_SIZE (1024*1024) // only 1MB |
| 49 | #define INITIAL_EBDA_SEGMENT 0xF600 |
| 50 | #define INITIAL_EBDA_SIZE 0x400 |
| 51 | |
| 52 | static void setup_bda(void) |
| 53 | { |
| 54 | /* clear BIOS DATA AREA */ |
| 55 | memset((void *)0x400, 0, 0x200); |
| 56 | |
| 57 | write16(0x413, FAKE_MEMORY_SIZE / 1024); |
| 58 | write16(0x40e, INITIAL_EBDA_SEGMENT); |
| 59 | |
| 60 | /* Set up EBDA */ |
| 61 | memset((void *)(INITIAL_EBDA_SEGMENT << 4), 0, INITIAL_EBDA_SIZE); |
| 62 | write16((INITIAL_EBDA_SEGMENT << 4) + 0x0, INITIAL_EBDA_SIZE / 1024); |
| 63 | } |
| 64 | |
| 65 | static void setup_rombios(void) |
| 66 | { |
| 67 | const char date[] = "06/11/99"; |
| 68 | memcpy((void *)0xffff5, &date, 8); |
| 69 | |
| 70 | const char ident[] = "PCI_ISA"; |
| 71 | memcpy((void *)0xfffd9, &ident, 7); |
| 72 | |
| 73 | /* system model: IBM-AT */ |
| 74 | write8(0xffffe, 0xfc); |
| 75 | } |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 76 | |
| 77 | int (*intXX_handler[256])(struct eregs *regs) = { NULL }; |
| 78 | |
| 79 | static int intXX_exception_handler(struct eregs *regs) |
| 80 | { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 81 | printk(BIOS_INFO, "Oops, exception %d while executing option rom\n", |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 82 | regs->vector); |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 83 | #if 0 |
| 84 | // Odd: The i945GM VGA oprom chokes on a pushl %eax and will |
| 85 | // die with an exception #6 if we run the coreboot exception |
| 86 | // handler. Just continue, as it executes fine. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 87 | x86_exception(regs); // Call coreboot exception handler |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 88 | #endif |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 89 | |
| 90 | return 0; // Never returns? |
| 91 | } |
| 92 | |
| 93 | static int intXX_unknown_handler(struct eregs *regs) |
| 94 | { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 95 | printk(BIOS_INFO, "Unsupported software interrupt #0x%x\n", |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 96 | regs->vector); |
| 97 | |
| 98 | return -1; |
| 99 | } |
| 100 | |
Libra Li | c143693 | 2009-12-23 19:16:47 +0000 | [diff] [blame] | 101 | /* setup interrupt handlers for mainboard */ |
| 102 | void mainboard_interrupt_handlers(int intXX, void *intXX_func) |
| 103 | { |
| 104 | intXX_handler[intXX] = intXX_func; |
| 105 | } |
| 106 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 107 | int int12_handler(struct eregs *regs); |
| 108 | int int15_handler(struct eregs *regs); |
| 109 | int int1a_handler(struct eregs *regs); |
| 110 | |
| 111 | static void setup_interrupt_handlers(void) |
| 112 | { |
| 113 | int i; |
| 114 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 115 | /* The first 16 intXX functions are not BIOS services, |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 116 | * but the CPU-generated exceptions ("hardware interrupts") |
| 117 | */ |
| 118 | for (i = 0; i < 0x10; i++) |
| 119 | intXX_handler[i] = &intXX_exception_handler; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 120 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 121 | /* Mark all other intXX calls as unknown first */ |
| 122 | for (i = 0x10; i < 0x100; i++) |
Libra Li | c143693 | 2009-12-23 19:16:47 +0000 | [diff] [blame] | 123 | { |
| 124 | /* If the mainboard_interrupt_handler isn't called first. |
| 125 | */ |
| 126 | if(!intXX_handler[i]) |
| 127 | { |
| 128 | /* Now set the default functions that are actually |
| 129 | * needed to initialize the option roms. This is very |
| 130 | * slick, as it allows us to implement mainboard specific |
| 131 | * interrupt handlers, such as the int15 |
| 132 | */ |
| 133 | switch (i) { |
| 134 | case 0x12: |
| 135 | intXX_handler[0x12] = &int12_handler; |
| 136 | break; |
| 137 | case 0x15: |
| 138 | intXX_handler[0x15] = &int15_handler; |
| 139 | break; |
| 140 | case 0x1a: |
| 141 | intXX_handler[0x1a] = &int1a_handler; |
| 142 | break; |
| 143 | default: |
| 144 | intXX_handler[i] = &intXX_unknown_handler; |
| 145 | break; |
| 146 | } |
| 147 | } |
| 148 | } |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | static void write_idt_stub(void *target, u8 intnum) |
| 152 | { |
| 153 | unsigned char *codeptr; |
| 154 | codeptr = (unsigned char *) target; |
| 155 | memcpy(codeptr, &__idt_handler, (size_t)&__idt_handler_size); |
| 156 | codeptr[3] = intnum; /* modify int# in the code stub. */ |
| 157 | } |
| 158 | |
| 159 | static void setup_realmode_idt(void) |
| 160 | { |
| 161 | struct realmode_idt *idts = (struct realmode_idt *) 0; |
| 162 | int i; |
| 163 | |
| 164 | /* Copy IDT stub code for each interrupt. This might seem wasteful |
| 165 | * but it is really simple |
| 166 | */ |
| 167 | for (i = 0; i < 256; i++) { |
| 168 | idts[i].cs = 0; |
| 169 | idts[i].offset = 0x1000 + (i * (u32)&__idt_handler_size); |
| 170 | write_idt_stub((void *)((u32 )idts[i].offset), i); |
| 171 | } |
| 172 | |
| 173 | /* Many option ROMs use the hard coded interrupt entry points in the |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 174 | * system bios. So install them at the known locations. |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 175 | */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 176 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 177 | /* int42 is the relocated int10 */ |
Stefan Reinauer | 714e2a1 | 2010-04-24 23:15:23 +0000 | [diff] [blame] | 178 | write_idt_stub((void *)0xff065, 0x42); |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 179 | /* BIOS Int 11 Handler F000:F84D */ |
| 180 | write_idt_stub((void *)0xff84d, 0x11); |
| 181 | /* BIOS Int 12 Handler F000:F841 */ |
| 182 | write_idt_stub((void *)0xff841, 0x12); |
| 183 | /* BIOS Int 13 Handler F000:EC59 */ |
| 184 | write_idt_stub((void *)0xfec59, 0x13); |
| 185 | /* BIOS Int 14 Handler F000:E739 */ |
| 186 | write_idt_stub((void *)0xfe739, 0x14); |
| 187 | /* BIOS Int 15 Handler F000:F859 */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 188 | write_idt_stub((void *)0xff859, 0x15); |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 189 | /* BIOS Int 16 Handler F000:E82E */ |
| 190 | write_idt_stub((void *)0xfe82e, 0x16); |
| 191 | /* BIOS Int 17 Handler F000:EFD2 */ |
| 192 | write_idt_stub((void *)0xfefd2, 0x17); |
| 193 | /* ROM BIOS Int 1A Handler F000:FE6E */ |
| 194 | write_idt_stub((void *)0xffe6e, 0x1a); |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | void run_bios(struct device *dev, unsigned long addr) |
| 198 | { |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 199 | u32 num_dev = (dev->bus->secondary << 8) | dev->path.pci.devfn; |
| 200 | |
| 201 | /* Set up BIOS Data Area */ |
| 202 | setup_bda(); |
| 203 | |
| 204 | /* Set up some legacy information in the F segment */ |
| 205 | setup_rombios(); |
Libra Li | c143693 | 2009-12-23 19:16:47 +0000 | [diff] [blame] | 206 | |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 207 | /* Set up C interrupt handlers */ |
| 208 | setup_interrupt_handlers(); |
| 209 | |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 210 | /* Set up real-mode IDT */ |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 211 | setup_realmode_idt(); |
| 212 | |
| 213 | memcpy(REALMODE_BASE, &__realmode_code, (size_t)&__realmode_code_size); |
| 214 | printk(BIOS_SPEW, "Real mode stub @%p: %d bytes\n", REALMODE_BASE, |
| 215 | (u32)&__realmode_code_size); |
| 216 | |
| 217 | printk(BIOS_DEBUG, "Calling Option ROM...\n"); |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 218 | /* TODO ES:DI Pointer to System BIOS PnP Installation Check Structure */ |
| 219 | /* Option ROM entry point is at OPROM start + 3 */ |
| 220 | realmode_call(addr + 0x0003, num_dev, 0xffff, 0x0000, 0xffff, 0x0, 0x0); |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 221 | printk(BIOS_DEBUG, "... Option ROM returned.\n"); |
| 222 | } |
| 223 | |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 224 | #if defined(CONFIG_GEODE_VSA) && CONFIG_GEODE_VSA |
| 225 | #include <cpu/amd/lxdef.h> |
| 226 | #include <cpu/amd/vr.h> |
| 227 | #include <cbfs.h> |
| 228 | |
| 229 | #define VSA2_BUFFER 0x60000 |
| 230 | #define VSA2_ENTRY_POINT 0x60020 |
| 231 | |
| 232 | // TODO move to a header file. |
| 233 | void do_vsmbios(void); |
| 234 | |
| 235 | /* VSA virtual register helper */ |
| 236 | static u32 VSA_vrRead(u16 classIndex) |
| 237 | { |
| 238 | u32 eax, ebx, ecx, edx; |
| 239 | asm volatile ( |
| 240 | "movw $0x0AC1C, %%dx\n" |
| 241 | "orl $0x0FC530000, %%eax\n" |
| 242 | "outl %%eax, %%dx\n" |
| 243 | "addb $2, %%dl\n" |
| 244 | "inw %%dx, %%ax\n" |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 245 | : "=a" (eax), "=b"(ebx), "=c"(ecx), "=d"(edx) |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 246 | : "a"(classIndex) |
| 247 | ); |
| 248 | |
| 249 | return eax; |
| 250 | } |
| 251 | |
| 252 | void do_vsmbios(void) |
| 253 | { |
| 254 | printk(BIOS_DEBUG, "Preparing for VSA...\n"); |
| 255 | |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 256 | /* Set up C interrupt handlers */ |
| 257 | setup_interrupt_handlers(); |
| 258 | |
| 259 | /* Setting up realmode IDT */ |
| 260 | setup_realmode_idt(); |
| 261 | |
| 262 | memcpy(REALMODE_BASE, &__realmode_code, (size_t)&__realmode_code_size); |
| 263 | printk(BIOS_SPEW, "VSA: Real mode stub @%p: %d bytes\n", REALMODE_BASE, |
| 264 | (u32)&__realmode_code_size); |
| 265 | |
| 266 | if ((unsigned int)cbfs_load_stage("vsa") != VSA2_ENTRY_POINT) { |
| 267 | printk(BIOS_ERR, "Failed to load VSA.\n"); |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | unsigned char *buf = (unsigned char *)VSA2_BUFFER; |
| 272 | printk(BIOS_DEBUG, "VSA: Buffer @%p *[0k]=%02x\n", buf, buf[0]); |
| 273 | printk(BIOS_DEBUG, "VSA: Signature *[0x20-0x23] is %02x:%02x:%02x:%02x\n", |
| 274 | buf[0x20], buf[0x21], buf[0x22], buf[0x23]); |
| 275 | |
| 276 | /* Check for code to emit POST code at start of VSA. */ |
| 277 | if ((buf[0x20] != 0xb0) || (buf[0x21] != 0x10) || |
| 278 | (buf[0x22] != 0xe6) || (buf[0x23] != 0x80)) { |
| 279 | printk(BIOS_WARNING, "VSA: Signature incorrect. Install failed.\n"); |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | printk(BIOS_DEBUG, "Calling VSA module...\n"); |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 284 | |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 285 | /* ECX gets SMM, EDX gets SYSMEM */ |
Stefan Reinauer | 841af5e | 2010-05-11 15:39:20 +0000 | [diff] [blame^] | 286 | realmode_call(VSA2_ENTRY_POINT, 0x0, 0x0, MSR_GLIU0_SMM, |
| 287 | MSR_GLIU0_SYSMEM, 0x0, 0x0); |
| 288 | |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 289 | printk(BIOS_DEBUG, "... VSA module returned.\n"); |
| 290 | |
| 291 | /* Restart timer 1 */ |
| 292 | outb(0x56, 0x43); |
| 293 | outb(0x12, 0x41); |
| 294 | |
| 295 | /* Check that VSA is running OK */ |
| 296 | if (VSA_vrRead(SIGNATURE) == VSA2_SIGNATURE) |
| 297 | printk(BIOS_DEBUG, "VSM: VSA2 VR signature verified.\n"); |
| 298 | else |
| 299 | printk(BIOS_ERR, "VSM: VSA2 VR signature not valid. Install failed.\n"); |
| 300 | } |
| 301 | #endif |
| 302 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 303 | /* interrupt_handler() is called from assembler code only, |
Stefan Reinauer | 9839cbd | 2010-04-21 20:06:10 +0000 | [diff] [blame] | 304 | * so there is no use in putting the prototype into a header file. |
| 305 | */ |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 306 | int __attribute__((regparm(0))) interrupt_handler(u32 intnumber, |
| 307 | u32 gsfs, u32 dses, |
| 308 | u32 edi, u32 esi, |
| 309 | u32 ebp, u32 esp, |
| 310 | u32 ebx, u32 edx, |
| 311 | u32 ecx, u32 eax, |
Uwe Hermann | 312673c | 2009-10-27 21:49:33 +0000 | [diff] [blame] | 312 | u32 cs_ip, u16 stackflags); |
| 313 | |
| 314 | int __attribute__((regparm(0))) interrupt_handler(u32 intnumber, |
| 315 | u32 gsfs, u32 dses, |
| 316 | u32 edi, u32 esi, |
| 317 | u32 ebp, u32 esp, |
| 318 | u32 ebx, u32 edx, |
| 319 | u32 ecx, u32 eax, |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 320 | u32 cs_ip, u16 stackflags) |
| 321 | { |
| 322 | u32 ip; |
| 323 | u32 cs; |
| 324 | u32 flags; |
| 325 | int ret = -1; |
| 326 | struct eregs reg_info; |
| 327 | |
| 328 | ip = cs_ip & 0xffff; |
| 329 | cs = cs_ip >> 16; |
| 330 | flags = stackflags; |
| 331 | |
| 332 | printk(BIOS_DEBUG, "oprom: INT# 0x%x\n", intnumber); |
| 333 | printk(BIOS_DEBUG, "oprom: eax: %08x ebx: %08x ecx: %08x edx: %08x\n", |
| 334 | eax, ebx, ecx, edx); |
| 335 | printk(BIOS_DEBUG, "oprom: ebp: %08x esp: %08x edi: %08x esi: %08x\n", |
| 336 | ebp, esp, edi, esi); |
| 337 | printk(BIOS_DEBUG, "oprom: ip: %04x cs: %04x flags: %08x\n", |
| 338 | ip, cs, flags); |
| 339 | |
| 340 | // Fetch arguments from the stack and put them into |
| 341 | // a structure that we want to pass on to our sub interrupt |
| 342 | // handlers. |
| 343 | reg_info = (struct eregs) { |
| 344 | .eax=eax, |
| 345 | .ecx=ecx, |
| 346 | .edx=edx, |
| 347 | .ebx=ebx, |
| 348 | .esp=esp, |
| 349 | .ebp=ebp, |
| 350 | .esi=esi, |
| 351 | .edi=edi, |
| 352 | .vector=intnumber, |
| 353 | .error_code=0, // ?? |
| 354 | .eip=ip, |
| 355 | .cs=cs, |
| 356 | .eflags=flags // ?? |
| 357 | }; |
| 358 | |
| 359 | // Call the interrupt handler for this int# |
| 360 | ret = intXX_handler[intnumber](®_info); |
| 361 | |
| 362 | // Put registers back on the stack. The assembler code |
| 363 | // will later pop them. |
| 364 | // What happens here is that we force (volatile!) changing |
| 365 | // the values of the parameters of this function. We do this |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 366 | // because we know that they stay alive on the stack after |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 367 | // we leave this function. Don't say this is bollocks. |
| 368 | *(volatile u32 *)&eax = reg_info.eax; |
| 369 | *(volatile u32 *)&ecx = reg_info.ecx; |
| 370 | *(volatile u32 *)&edx = reg_info.edx; |
| 371 | *(volatile u32 *)&ebx = reg_info.ebx; |
| 372 | *(volatile u32 *)&esi = reg_info.esi; |
| 373 | *(volatile u32 *)&edi = reg_info.edi; |
| 374 | flags = reg_info.eflags; |
| 375 | |
| 376 | /* Pass errors back to our caller via the CARRY flag */ |
| 377 | if (ret) { |
Stefan Reinauer | f75b19a | 2010-04-22 18:15:32 +0000 | [diff] [blame] | 378 | printk(BIOS_DEBUG,"int%02x call returned error.\n", intnumber); |
Stefan Reinauer | 38cd29e | 2009-08-11 21:28:25 +0000 | [diff] [blame] | 379 | flags |= 1; // error: set carry |
| 380 | }else{ |
| 381 | flags &= ~1; // no error: clear carry |
| 382 | } |
| 383 | *(volatile u16 *)&stackflags = flags; |
| 384 | |
| 385 | return ret; |
| 386 | } |
| 387 | |