Kevin O'Connor | e7cc764 | 2009-10-04 10:05:16 -0400 | [diff] [blame^] | 1 | // Paravirtualization support. |
| 2 | // |
| 3 | // Copyright (C) 2009 Red Hat Inc. |
| 4 | // |
| 5 | // Authors: |
| 6 | // Gleb Natapov <gnatapov@redhat.com> |
| 7 | // |
| 8 | // This file may be distributed under the terms of the GNU LGPLv3 license. |
| 9 | |
| 10 | #include "config.h" |
| 11 | #include "ioport.h" |
| 12 | #include "paravirt.h" |
| 13 | |
| 14 | int qemu_cfg_present; |
| 15 | |
| 16 | static void |
| 17 | qemu_cfg_select(u16 f) |
| 18 | { |
| 19 | outw(f, PORT_QEMU_CFG_CTL); |
| 20 | } |
| 21 | |
| 22 | static void |
| 23 | qemu_cfg_read(u8 *buf, int len) |
| 24 | { |
| 25 | while (len--) |
| 26 | *(buf++) = inb(PORT_QEMU_CFG_DATA); |
| 27 | } |
| 28 | |
| 29 | static void |
| 30 | qemu_cfg_read_entry(void *buf, int e, int len) |
| 31 | { |
| 32 | qemu_cfg_select(e); |
| 33 | qemu_cfg_read(buf, len); |
| 34 | } |
| 35 | |
| 36 | void qemu_cfg_port_probe(void) |
| 37 | { |
| 38 | char *sig = "QEMU"; |
| 39 | int i; |
| 40 | |
| 41 | if (CONFIG_COREBOOT) |
| 42 | return; |
| 43 | |
| 44 | qemu_cfg_present = 1; |
| 45 | |
| 46 | qemu_cfg_select(QEMU_CFG_SIGNATURE); |
| 47 | |
| 48 | for (i = 0; i < 4; i++) |
| 49 | if (inb(PORT_QEMU_CFG_DATA) != sig[i]) { |
| 50 | qemu_cfg_present = 0; |
| 51 | break; |
| 52 | } |
| 53 | dprintf(4, "qemu_cfg_present=%d\n", qemu_cfg_present); |
| 54 | } |
| 55 | |
| 56 | void qemu_cfg_get_uuid(u8 *uuid) |
| 57 | { |
| 58 | if (!qemu_cfg_present) |
| 59 | return; |
| 60 | |
| 61 | qemu_cfg_read_entry(uuid, QEMU_CFG_UUID, 16); |
| 62 | } |
| 63 | |
| 64 | int qemu_cfg_show_boot_menu(void) |
| 65 | { |
| 66 | u16 v; |
| 67 | if (!qemu_cfg_present) |
| 68 | return 1; |
| 69 | |
| 70 | qemu_cfg_read_entry(&v, QEMU_CFG_BOOT_MENU, sizeof(v)); |
| 71 | |
| 72 | return v; |
| 73 | } |
| 74 | |