Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1011
-gerrit
commit a9fa001c8423b9b3b9e944f482512b7fed1b3d84 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sun May 6 15:51:35 2012 +0300
SerialICE factoring: fix serialice-com build
Small fixes to build this and add back copyrights and most headers.
Change-Id: I201b8fce65d18f0737997ad43cf10c4fddaba8fe Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- qemu-0.15.x/serialice-com.c | 102 ++++++++++++++++++++++++++++++------------- 1 files changed, 72 insertions(+), 30 deletions(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c index 07ab293..67eb5a6 100644 --- a/qemu-0.15.x/serialice-com.c +++ b/qemu-0.15.x/serialice-com.c @@ -1,26 +1,77 @@ +/* + * QEMU PC System Emulator + * + * Copyright (c) 2009 coresystems GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* System includes */ +#include <stdlib.h> +#include <stdio.h> +#include <stdint.h> +#include <unistd.h> +#include <string.h> +#ifdef WIN32 +#include <windows.h> +#include <conio.h> +#else +#include <fcntl.h> +#include <termios.h> +#include <sys/ioctl.h> +#endif + +#include "console.h" +#include "serialice.h" +#include "sysemu.h" + +typedef struct { +#ifdef WIN32 + HANDLE fd; +#else + int fd; +#endif + DisplayState *ds; + char *buffer; + char *command; +} SerialICEState; + +extern SerialICEState *s;
uint32_t serialice_io_read_wrapper(uint16_t port, unsigned int size) { - uint32_t ret; switch (size) { case 1: sprintf(s->command, "*ri%04x.b", port); // command read back: "\n00" (3 characters) serialice_command(s->command, 3); - ret = (uint8_t) strtoul(s->buffer + 1, (char **)NULL, 16); - return ret; + return (uint8_t) strtoul(s->buffer + 1, (char **)NULL, 16); case 2: sprintf(s->command, "*ri%04x.w", port); // command read back: "\n0000" (5 characters) serialice_command(s->command, 5); - ret = (uint16_t) strtoul(s->buffer + 1, (char **)NULL, 16); - return ret; + return (uint16_t) strtoul(s->buffer + 1, (char **)NULL, 16); case 4: sprintf(s->command, "*ri%04x.l", port); // command read back: "\n00000000" (9 characters) serialice_command(s->command, 9); - ret = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); - return ret; + return strtoul(s->buffer + 1, (char **)NULL, 16); default: printf("WARNING: unknown read access size %d @%08x\n", size, port); return -1; @@ -31,11 +82,11 @@ void serialice_io_write_wrapper(uint16_t port, unsigned int size, uint32_t data) { switch (size) { case 1: - sprintf(s->command, "*wi%04x.b=%02x", port, data); + sprintf(s->command, "*wi%04x.b=%02x", port, (uint8_t) data); serialice_command(s->command, 0); return; case 2: - sprintf(s->command, "*wi%04x.w=%04x", port, data); + sprintf(s->command, "*wi%04x.w=%04x", port, (uint16_t) data); serialice_command(s->command, 0); return; case 4: @@ -50,27 +101,22 @@ void serialice_io_write_wrapper(uint16_t port, unsigned int size, uint32_t data)
uint32_t serialice_load_wrapper(uint32_t addr, unsigned int size) { - uint32_t ret; switch (size) { case 1: - uint8_t ret; sprintf(s->command, "*rm%08x.b", addr); // command read back: "\n00" (3 characters) serialice_command(s->command, 3); - ret = (uint8_t) strtoul(s->buffer + 1, (char **)NULL, 16); - return ret; + return (uint8_t) strtoul(s->buffer + 1, (char **)NULL, 16); case 2: sprintf(s->command, "*rm%08x.w", addr); // command read back: "\n0000" (5 characters) serialice_command(s->command, 5); - ret = (uint16_t) strtoul(s->buffer + 1, (char **)NULL, 16); - return ret; + return (uint16_t) strtoul(s->buffer + 1, (char **)NULL, 16); case 4: sprintf(s->command, "*rm%08x.l", addr); // command read back: "\n00000000" (9 characters) serialice_command(s->command, 9); - ret = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); - return ret; + return (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); default: printf("WARNING: unknown read access size %d @%08x\n", size, addr); } @@ -81,11 +127,11 @@ void serialice_store_wrapper(uint32_t addr, unsigned int size, uint32_t data) { switch (size) { case 1: - sprintf(s->command, "*wm%08x.b=%02x", addr, data); + sprintf(s->command, "*wm%08x.b=%02x", addr, (uint8_t) data); serialice_command(s->command, 0); break; case 2: - sprintf(s->command, "*wm%08x.w=%04x", addr, data); + sprintf(s->command, "*wm%08x.w=%04x", addr, (uint16_t) data); serialice_command(s->command, 0); break; case 4: @@ -101,13 +147,11 @@ void serialice_rdmsr_wrapper(uint32_t addr, uint32_t key, uint32_t * hi, uint32_t * lo) { sprintf(s->command, "*rc%08x.%08x", addr, key); - // command read back: "\n00000000.00000000" (18 characters) serialice_command(s->command, 18); - s->buffer[9] = 0; // . -> \0 - hi = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); - lo = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16); + *hi = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); + *lo = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16); }
void serialice_wrmsr_wrapper(uint32_t addr, uint32_t key, @@ -117,19 +161,17 @@ void serialice_wrmsr_wrapper(uint32_t addr, uint32_t key, serialice_command(s->command, 0); }
-void serialice_cpuid_wrapper(uint32_t eax, uint32_t ecx, cpuid_regs_t ret) +void serialice_cpuid_wrapper(uint32_t eax, uint32_t ecx, cpuid_regs_t * ret) { sprintf(s->command, "*ci%08x.%08x", eax, ecx); - // command read back: "\n000006f2.00000000.00001234.12340324" // (36 characters) serialice_command(s->command, 36); - s->buffer[9] = 0; // . -> \0 s->buffer[18] = 0; // . -> \0 s->buffer[27] = 0; // . -> \0 - ret.eax = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); - ret.ebx = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16); - ret.ecx = (uint32_t) strtoul(s->buffer + 19, (char **)NULL, 16); - ret.edx = (uint32_t) strtoul(s->buffer + 28, (char **)NULL, 16); + ret->eax = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16); + ret->ebx = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16); + ret->ecx = (uint32_t) strtoul(s->buffer + 19, (char **)NULL, 16); + ret->edx = (uint32_t) strtoul(s->buffer + 28, (char **)NULL, 16); }