From bb756eebdac6fd24e8919e2c43f7d2c8c4091f59 Mon Sep 17 00:00:00 2001 From: RajithaY Date: Tue, 25 Apr 2017 03:31:15 -0700 Subject: Adding qemu as a submodule of KVMFORNFV This Patch includes the changes to add qemu as a submodule to kvmfornfv repo and make use of the updated latest qemu for the execution of all testcase Change-Id: I1280af507a857675c7f81d30c95255635667bdd7 Signed-off-by:RajithaY --- qemu/roms/SLOF/lib/libnvram/Makefile | 53 --- qemu/roms/SLOF/lib/libnvram/envvar.c | 243 ----------- qemu/roms/SLOF/lib/libnvram/libnvram.code | 274 ------------- qemu/roms/SLOF/lib/libnvram/libnvram.in | 42 -- qemu/roms/SLOF/lib/libnvram/nvram.c | 650 ------------------------------ qemu/roms/SLOF/lib/libnvram/nvram.h | 75 ---- 6 files changed, 1337 deletions(-) delete mode 100644 qemu/roms/SLOF/lib/libnvram/Makefile delete mode 100644 qemu/roms/SLOF/lib/libnvram/envvar.c delete mode 100644 qemu/roms/SLOF/lib/libnvram/libnvram.code delete mode 100644 qemu/roms/SLOF/lib/libnvram/libnvram.in delete mode 100644 qemu/roms/SLOF/lib/libnvram/nvram.c delete mode 100644 qemu/roms/SLOF/lib/libnvram/nvram.h (limited to 'qemu/roms/SLOF/lib/libnvram') diff --git a/qemu/roms/SLOF/lib/libnvram/Makefile b/qemu/roms/SLOF/lib/libnvram/Makefile deleted file mode 100644 index d4e9a617e..000000000 --- a/qemu/roms/SLOF/lib/libnvram/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - -SRCS = nvram.c envvar.c - -TOPCMNDIR ?= ../.. - -include $(TOPCMNDIR)/make.rules - -ASFLAGS = $(FLAG) $(RELEASE) $(CPUARCHDEF) -Wa,-mregnames -CPPFLAGS = -I../libc/include $(CPUARCHDEF) $(FLAG) \ - -I$(INCLBRDDIR) -I$(INCLCMNDIR)/$(CPUARCH) -I. -I../../include -LDFLAGS = -nostdlib - -TARGET = ../libnvram.a - -all: $(TARGET) - -OBJS = $(SRCS:%.c=%.o) - -$(TARGET): $(OBJS) - $(AR) -rc $@ $(OBJS) - $(RANLIB) $@ - - -clean: - $(RM) $(TARGET) $(OBJS) - -distclean: clean - $(RM) Makefile.dep - - -# Rules for creating the dependency file: -depend: - $(RM) Makefile.dep - $(MAKE) Makefile.dep - -Makefile.dep: Makefile - $(CC) -MM $(CPPFLAGS) $(CFLAGS) $(SRCS) > Makefile.dep - - -# Include dependency file if available: --include Makefile.dep - diff --git a/qemu/roms/SLOF/lib/libnvram/envvar.c b/qemu/roms/SLOF/lib/libnvram/envvar.c deleted file mode 100644 index ee943fce5..000000000 --- a/qemu/roms/SLOF/lib/libnvram/envvar.c +++ /dev/null @@ -1,243 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include -#include "../libc/include/stdio.h" -#include "../libc/include/string.h" -#include "../libc/include/stdlib.h" -#include "nvram.h" - -/* returns the offset of the first byte after the searched envvar */ -static int get_past_env_pos(partition_t part, char *envvar, int evlen) -{ - int offset, len; - static char temp[256]; - uint8_t data; - - offset=part.addr; - - memset(temp, 0, 256); - - do { - len=0; - while((data=nvram_read_byte(offset++)) && len < 256) { - temp[len++]=data; - } - if (!strncmp(envvar, temp, evlen)) { - return offset; - } - } while (len); - - return -1; -} - -/** - * @param partition name of the envvar partition - * @param envvar name of the environment variable - * @param evlen string length of the envvar parameter - * @return pointer to temporary string containing the value of envvar - */ -char *nvram_get_env(partition_t part, char *envvar, int evlen) -{ - static char temp[256+1]; - int len, offset; - uint8_t data; - - DEBUG("nvram_get_env %p... ", envvar); - if(!part.addr) { - /* ERROR: No environment variable partition */ - DEBUG("invalid partition.\n"); - return NULL; - } - - offset=part.addr; - - do { - len=0; - while((data=nvram_read_byte(offset++)) && len < 256) { - temp[len++]=data; - } - temp[len]=0; - - if (!strncmp(envvar, temp, evlen)) { - int pos=0; - while (temp[pos]!='=' && pos < len) pos++; - // DEBUG("value='%s'\n", temp+pos+1); - return temp+pos+1; - } - } while (len); - - DEBUG("not found\n"); - return NULL; -} - -static int find_last_envvar(partition_t part) -{ - uint8_t last, current; - int offset; - - offset=part.addr; - - last=nvram_read_byte(part.addr); - - for (offset=part.addr; offset<(int)(part.addr+part.len); offset++) { - current=nvram_read_byte(offset); - if(!last && !current) - return offset; - - last=current; - } - - return -1; -} - -int nvram_add_env(partition_t part, char *envvar, int evlen, char *value, int vallen) -{ - int freespace, last, len, offset; - unsigned int i; - - /* Find offset where we can write */ - last = find_last_envvar(part); - - /* How much space do we have left? */ - freespace = part.addr+part.len-last; - - /* how long is the entry we want to write? */ - len = evlen + vallen + 2; - - if(freespace - -PRIM(nvram_X2d_c_X40) - unsigned int offset = TOS.u; - TOS.u=nvram_read_byte(offset); -MIRP - -PRIM(nvram_X2d_w_X40) - unsigned int offset = TOS.u; - TOS.u=nvram_read_word(offset); -MIRP - -PRIM(nvram_X2d_l_X40) - unsigned int offset = TOS.u; - TOS.u=nvram_read_dword(offset); -MIRP - -PRIM(nvram_X2d_x_X40) - unsigned int offset = TOS.u; - TOS.u=nvram_read_qword(offset); -MIRP - -PRIM(nvram_X2d_c_X21) - nvram_write_byte(TOS.u, NOS.u); - POP; POP; -MIRP - -PRIM(nvram_X2d_w_X21) - nvram_write_word(TOS.u, NOS.u); - POP; POP; -MIRP - -PRIM(nvram_X2d_l_X21) - nvram_write_dword(TOS.u, NOS.u); - POP; POP; -MIRP - -PRIM(nvram_X2d_x_X21) - nvram_write_qword(TOS.u, NOS.u); - POP; POP; -MIRP - -/* get-nvram-partition ( type -- addr len FAILED? ) */ -PRIM(get_X2d_nvram_X2d_partition) - partition_t partition; - unsigned int ptype = TOS.u; - partition = get_partition(ptype, NULL); - if(partition.len && partition.len != -1) { - TOS.u = partition.addr; - PUSH; - TOS.u = partition.len; - PUSH; - TOS.u = 0; // FALSE - } else { - TOS.u = -1; // TRUE - } -MIRP - -/* get-named-nvram-partition ( name.addr name.len -- addr len FAILED? ) */ -PRIM(get_X2d_named_X2d_nvram_X2d_partition) - partition_t partition; - int namelen = TOS.n; POP; - - partition = get_partition_fs(TOS.a, namelen); - - if(partition.len && partition.len != -1) { - TOS.u = partition.addr; - PUSH; - TOS.u = partition.len; - PUSH; - TOS.u = 0; // FALSE - } else { - TOS.u = -1; // TRUE - } -MIRP - - - -/* new-nvram-partition ( type name.addr name.len len -- part.offs part.len FALSE | TRUE) */ -PRIM(new_X2d_nvram_X2d_partition) - int type, len, namelen; - partition_t partition; - char *name; - - len = TOS.u; POP; - namelen = TOS.u; POP; - name = (char *)TOS.u; POP; - type = TOS.u; POP; - - partition = new_nvram_partition_fs(type, name, namelen, len); - - if(!partition.len) { - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = partition.addr; - PUSH; TOS.u = partition.len; - PUSH; TOS.u = 0; // FALSE - } -MIRP - -/* inrease-nvram-partition ( part.offs part.len new-len -- FALSE | TRUE ) */ -PRIM(increase_X2d_nvram_X2d_partition) - int len, ret; - partition_t partition; - - // FIXME - partition.addr = TOS.u; POP; - partition.len = TOS.u; POP; - len = TOS.u; POP; - - ret=increase_nvram_partition_size(partition, len); - - PUSH; - - if(!ret) - TOS.u=-1; // TRUE - else - TOS.u=0; // FALSE - -MIRP - -PRIM(internal_X2d_reset_X2d_nvram) - reset_nvram(); -MIRP - -PRIM(wipe_X2d_nvram) - wipe_nvram(); -MIRP - -PRIM(nvram_X2d_debug) - nvram_debug(); -MIRP - -// ( part.start part.len name.addr name.len -- var.addr var.len TRUE | false ) -PRIM(internal_X2d_get_X2d_env) - char *name; - int namelen; - partition_t part; - char *val; - - namelen = TOS.u; POP; - name = TOS.a; POP; - part.len = TOS.u; POP; - part.addr = TOS.u; POP; - - val = nvram_get_env(part, name, namelen); - if(val) { - PUSH; TOS.a = val; - PUSH; TOS.u = strlen(val); - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = 0; // FALSE - } -MIRP - -// ( part.start part.len name.addr name.len val.addr val.len -- FALSE|TRUE) -PRIM(internal_X2d_add_X2d_env) - char *name, *val; - int namelen, vallen; - partition_t part; - int ret; - - vallen = TOS.u; POP; - val = TOS.a; POP; - namelen = TOS.u; POP; - name = TOS.a; POP; - part.len = TOS.u; POP; - part.addr = TOS.u; POP; - - ret = nvram_add_env(part, name, namelen, val, vallen); - if(ret) { - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = 0; // FALSE - } -MIRP - -// ( part.addr part.len name.addr name.len -- FALSE|TRUE) -PRIM(internal_X2d_del_X2d_env) - char *name; - int namelen; - partition_t part; - int ret; - - namelen = TOS.u; POP; - name = TOS.a; POP; - part.len = TOS.u; POP; - part.addr = TOS.u; POP; - - ret = nvram_del_env(part, name, namelen); - if(ret) { - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = 0; // FALSE - } - -MIRP - -// internal-set-env ( part.addr part.len name.addr name.len val.addr val.len -- FALSE|TRUE) -PRIM(internal_X2d_set_X2d_env) - char *name, *value; - int namelen, valuelen; - partition_t part; - int ret; - - valuelen = TOS.u; POP; - value = TOS.a; POP; - namelen = TOS.u; POP; - name = TOS.a; POP; - part.len = TOS.u; POP; - part.addr = TOS.u; POP; - - ret = nvram_set_env(part, name, namelen, value, valuelen); - if(ret) { - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = 0; // FALSE - } -MIRP - -// ( part.addr part.len -- FALSE|TRUE) -PRIM(erase_X2d_nvram_X2d_partition) - partition_t part; - int ret; - - part.len = TOS.u; POP; - part.addr = TOS.u; POP; - - ret=clear_nvram_partition(part); - if(ret) { - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = 0; // FALSE - } - -MIRP - -// ( part.addr part.len -- FALSE|TRUE) -PRIM(delete_X2d_nvram_X2d_partition) - partition_t part; - int ret; - - part.len = TOS.u; POP; - part.addr = TOS.u; POP; - - ret=delete_nvram_partition(part); - if(ret) { - PUSH; TOS.u = -1; // TRUE - } else { - PUSH; TOS.u = 0; // FALSE - } - -MIRP - -// ( fetch_token store_token size nvram-addr -- ) -PRIM(internal_X2d_nvram_X2d_init) - void *nvram_addr = TOS.a; POP; - uint32_t nvram_size = TOS.u; POP; - uint32_t store_token = TOS.u; POP; - long fetch_token = TOS.u; POP; - - nvram_init(fetch_token, store_token, nvram_size, nvram_addr); -MIRP diff --git a/qemu/roms/SLOF/lib/libnvram/libnvram.in b/qemu/roms/SLOF/lib/libnvram/libnvram.in deleted file mode 100644 index bbb20a889..000000000 --- a/qemu/roms/SLOF/lib/libnvram/libnvram.in +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -/* NVRAM access primitives */ -cod(nvram-c@) -cod(nvram-c!) -cod(nvram-w@) -cod(nvram-w!) -cod(nvram-l@) -cod(nvram-l!) -cod(nvram-x@) -cod(nvram-x!) - -/* Generic NVRAM helpers */ -cod(internal-reset-nvram) -cod(nvram-debug) -cod(wipe-nvram) - -/* NVRAM Partition Handling */ -cod(get-nvram-partition) -cod(get-named-nvram-partition) -cod(new-nvram-partition) -cod(increase-nvram-partition) -cod(erase-nvram-partition) -cod(delete-nvram-partition) - -/* NVRAM environment access words */ -cod(internal-get-env) -cod(internal-add-env) -cod(internal-del-env) -cod(internal-set-env) - -cod(internal-nvram-init) diff --git a/qemu/roms/SLOF/lib/libnvram/nvram.c b/qemu/roms/SLOF/lib/libnvram/nvram.c deleted file mode 100644 index 473814e5c..000000000 --- a/qemu/roms/SLOF/lib/libnvram/nvram.c +++ /dev/null @@ -1,650 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "cache.h" -#include "nvram.h" -#include "../libhvcall/libhvcall.h" - -#include -#include -#include -#include -#include -#include - -#ifdef RTAS_NVRAM -static uint32_t fetch_token; -static uint32_t store_token; -static uint32_t NVRAM_LENGTH; -static char *nvram_buffer; /* use buffer allocated by SLOF code */ -#else -#ifndef NVRAM_LENGTH -#define NVRAM_LENGTH 0x10000 -#endif -/* - * This is extremely ugly, but still better than implementing - * another sbrk() around it. - */ -static char nvram_buffer[NVRAM_LENGTH]; -#endif - -static uint8_t nvram_buffer_locked=0x00; - -void nvram_init(uint32_t _fetch_token, uint32_t _store_token, - long _nvram_length, void* nvram_addr) -{ -#ifdef RTAS_NVRAM - fetch_token = _fetch_token; - store_token = _store_token; - NVRAM_LENGTH = _nvram_length; - nvram_buffer = nvram_addr; - - DEBUG("\nNVRAM: size=%d, fetch=%x, store=%x\n", - NVRAM_LENGTH, fetch_token, store_token); -#endif -} - - -void asm_cout(long Character,long UART,long NVRAM); - -#if defined(DISABLE_NVRAM) - -static volatile uint8_t nvram[NVRAM_LENGTH]; /* FAKE */ - -#define nvram_access(type,size,name) \ - type nvram_read_##name(unsigned int offset) \ - { \ - type *pos; \ - if (offset > (NVRAM_LENGTH - sizeof(type))) \ - return 0; \ - pos = (type *)(nvram+offset); \ - return *pos; \ - } \ - void nvram_write_##name(unsigned int offset, type data) \ - { \ - type *pos; \ - if (offset > (NVRAM_LENGTH - sizeof(type))) \ - return; \ - pos = (type *)(nvram+offset); \ - *pos = data; \ - } - -#elif defined(RTAS_NVRAM) - -static inline void nvram_fetch(unsigned int offset, void *buf, unsigned int len) -{ - struct hv_rtas_call rtas = { - .token = fetch_token, - .nargs = 3, - .nrets = 2, - .argret = { offset, (uint32_t)(unsigned long)buf, len }, - }; - h_rtas(&rtas); -} - -static inline void nvram_store(unsigned int offset, void *buf, unsigned int len) -{ - struct hv_rtas_call rtas = { - .token = store_token, - .nargs = 3, - .nrets = 2, - .argret = { offset, (uint32_t)(unsigned long)buf, len }, - }; - h_rtas(&rtas); -} - -#define nvram_access(type,size,name) \ - type nvram_read_##name(unsigned int offset) \ - { \ - type val; \ - if (offset > (NVRAM_LENGTH - sizeof(type))) \ - return 0; \ - nvram_fetch(offset, &val, size / 8); \ - return val; \ - } \ - void nvram_write_##name(unsigned int offset, type data) \ - { \ - if (offset > (NVRAM_LENGTH - sizeof(type))) \ - return; \ - nvram_store(offset, &data, size / 8); \ - } - -#else /* DISABLE_NVRAM */ - -static volatile uint8_t *nvram = (volatile uint8_t *)SB_NVRAM_adr; - -#define nvram_access(type,size,name) \ - type nvram_read_##name(unsigned int offset) \ - { \ - type *pos; \ - if (offset > (NVRAM_LENGTH - sizeof(type))) \ - return 0; \ - pos = (type *)(nvram+offset); \ - return ci_read_##size(pos); \ - } \ - void nvram_write_##name(unsigned int offset, type data) \ - { \ - type *pos; \ - if (offset > (NVRAM_LENGTH - sizeof(type))) \ - return; \ - pos = (type *)(nvram+offset); \ - ci_write_##size(pos, data); \ - } - -#endif - -/* - * producer for nvram access functions. Since these functions are - * basically all the same except for the used data types, produce - * them via the nvram_access macro to keep the code from bloating. - */ - -nvram_access(uint8_t, 8, byte) -nvram_access(uint16_t, 16, word) -nvram_access(uint32_t, 32, dword) -nvram_access(uint64_t, 64, qword) - - - -/** - * This function is a minimal abstraction for our temporary - * buffer. It should have been malloced, but since there is no - * usable malloc, we go this route. - * - * @return pointer to temporary buffer - */ - -char *get_nvram_buffer(int len) -{ - if(len>NVRAM_LENGTH) - return NULL; - - if(nvram_buffer_locked) - return NULL; - - nvram_buffer_locked = 0xff; - - return nvram_buffer; -} - -/** - * @param buffer pointer to the allocated buffer. This - * is unused, but nice in case we ever get a real malloc - */ - -void free_nvram_buffer(char *buffer __attribute__((unused))) -{ - nvram_buffer_locked = 0x00; -} - -/** - * @param fmt format string, like in printf - * @param ... variable number of arguments - */ - -int nvramlog_printf(const char* fmt, ...) -{ - char buff[256]; - int count, i; - va_list ap; - - va_start(ap, fmt); - count = vsprintf(buff, fmt, ap); - va_end(ap); - - for (i=0; i>8)+(plainsum&0xff); - - return checksum; -} - -static int calc_used_nvram_space(void) -{ - int walk, len; - - for (walk=0; walk end_offset) { - int j, bufferlen; - char *overlap_buffer; - - bufferlen=free_offset - end_offset; - - overlap_buffer=get_nvram_buffer(bufferlen); - if(!overlap_buffer) { - return 0; - } - - for (i=end_offset, j=0; i