From patchwork Fri Apr 26 18:19:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 240017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84B682C0115 for ; Sat, 27 Apr 2013 05:23:49 +1000 (EST) Received: from localhost ([::1]:34413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnKv-0000g3-To for incoming@patchwork.ozlabs.org; Fri, 26 Apr 2013 14:25:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnFE-0007o5-A6 for qemu-devel@nongnu.org; Fri, 26 Apr 2013 14:19:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVnF9-0004CR-UD for qemu-devel@nongnu.org; Fri, 26 Apr 2013 14:19:40 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38722 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnF9-0004BS-HC; Fri, 26 Apr 2013 14:19:35 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6B5CA5E00020A; Fri, 26 Apr 2013 20:19:34 +0200 (CEST) From: Alexander Graf To: qemu-ppc@nongnu.org Date: Fri, 26 Apr 2013 20:19:17 +0200 Message-Id: <1367000373-7972-9-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1367000373-7972-1-git-send-email-agraf@suse.de> References: <1367000373-7972-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PATCH 08/24] S390: ccw firmware: Add glue header X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Like all great programs, we have to call between different functions in different object files. And all of them need a common ground of defines. Provide a file that provides these defines. Signed-off-by: Alexander Graf --- pc-bios/s390-ccw/s390-ccw.h | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 131 insertions(+), 0 deletions(-) create mode 100644 pc-bios/s390-ccw/s390-ccw.h diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h new file mode 100644 index 0000000..a03dbaf --- /dev/null +++ b/pc-bios/s390-ccw/s390-ccw.h @@ -0,0 +1,131 @@ +/* + * S390 CCW boot loader + * + * Copyright (c) 2013 Alexander Graf + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#ifndef S390_CCW_H +#define S390_CCW_H + +/* #define DEBUG */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef unsigned long ulong; +typedef long size_t; +typedef int bool; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef unsigned char __u8; +typedef unsigned short __u16; +typedef unsigned int __u32; +typedef unsigned long long __u64; + +#define true 1 +#define false 0 +#define PAGE_SIZE 4096 + +#ifndef EIO +#define EIO 1 +#endif +#ifndef EBUSY +#define EBUSY 2 +#endif +#ifndef NULL +#define NULL 0 +#endif + +#include "cio.h" + +/* main.c */ +void virtio_panic(const char *string); + +/* sclp-ascii.c */ +void sclp_print(const char *string); +void sclp_setup(void); + +/* virtio.c */ +unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, + ulong subchan_id, void *load_addr); +bool virtio_is_blk(struct subchannel_id schid); +void virtio_setup_block(struct subchannel_id schid); +int virtio_read(ulong sector, void *load_addr); + +/* bootmap.c */ +int zipl_load(void); + +static inline void *memset(void *s, int c, size_t n) +{ + int i; + unsigned char *p = s; + + for (i = 0; i < n; i++) { + p[i] = c; + } + + return s; +} + +static inline void fill_hex(char *out, unsigned char val) +{ + const char hex[] = "0123456789abcdef"; + + out[0] = hex[(val >> 4) & 0xf]; + out[1] = hex[val & 0xf]; +} + +static inline void print_int(const char *desc, u64 addr) +{ + unsigned char *addr_c = (unsigned char*)&addr; + char out[] = ": 0xffffffffffffffff\n"; + unsigned int i; + + for (i = 0; i < sizeof(addr); i++) { + fill_hex(&out[4 + (i*2)], addr_c[i]); + } + + sclp_print(desc); + sclp_print(out); +} + +static inline void debug_print_int(const char *desc, u64 addr) +{ +#ifdef DEBUG + print_int(desc, addr); +#endif +} + +static inline void debug_print_addr(const char *desc, void *p) +{ +#ifdef DEBUG + debug_print_int(desc, (unsigned int)(unsigned long)p); +#endif +} + +/*********************************************** + * Hypercall functions * + ***********************************************/ + +#define KVM_S390_VIRTIO_NOTIFY 0 +#define KVM_S390_VIRTIO_RESET 1 +#define KVM_S390_VIRTIO_SET_STATUS 2 +#define KVM_S390_VIRTIO_CCW_NOTIFY 3 + +static inline void yield(void) +{ + asm volatile ("diag 0,0,0x44" + : : + : "memory", "cc"); +} + +#define SECTOR_SIZE 512 + +#endif /* S390_CCW_H */