Skip to content

Commit

Permalink
Initial qemu/KVM board support
Browse files Browse the repository at this point in the history
Added a new board for SLOF running on KVM/qemu.

Signed-off-by: Benjamin Herrenschmidt <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
  • Loading branch information
ozbenh authored and huth committed Mar 22, 2011
1 parent cf69a59 commit 39426ba
Show file tree
Hide file tree
Showing 70 changed files with 3,667 additions and 59 deletions.
1 change: 0 additions & 1 deletion .target

This file was deleted.

2 changes: 1 addition & 1 deletion board-js2x/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BOARD=js2x
TARG=ppc64
FLAG="-DBIOSEMU"
export FLAG="-DBIOSEMU"
export CPUARCH=ppc970
export CPUARCHDEF=-DCPU_PPC970
export SNK_BIOSEMU_APPS=1
Expand Down
76 changes: 76 additions & 0 deletions board-qemu/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# *****************************************************************************
# * Copyright (c) 2004, 2011 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
# ****************************************************************************/

BOARD_TARGETS = tools_build romfs_build clients_build net_veth stage1

SUBDIRS = slof
COMMON_LIBS = libc libbootmsg libbases libnvram libelf libhvcall

all: $(BOARD_TARGETS) subdirs boot_rom.bin

.PHONY : subdirs $(SUBDIRS) clean distclean

include config
include Makefile.dirs
include $(TOPCMNDIR)/make.rules
include $(TOPCMNDIR)/Makefile.gen

subdirs: $(SUBDIRS)

$(SUBDIRS): common-libs
@echo " ====== Building $@ ======"
$(MAKE) -C $@ $(MAKEARG)

stage1: common-libs
@echo " ====== Building llfw ======"
make -C llfw RELEASE=-DRELEASE=\"\\\"$(RELEASE)\\\"\"

net_veth: common-libs
@echo " ====== Building veth ======"
make -C veth

clean_here:
rm -f ../slof/OF.ffs
rm -f ../boot_rom.bin

clean: clean_here clean_gen
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean || exit 1; \
done
rm -f ../boot_rom.bin
@make -C llfw clean
make -C veth clean

distclean: clean_here distclean_gen
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir distclean || exit 1; \
done
rm -f ../boot_rom.bin
make -C llfw clean
make -C veth distclean

.driver_dirs:
@rm -rf ../driver-$(RELEASE)
@mkdir -p ../driver-$(RELEASE)

.tar_gz: .driver_dirs
@mv ../boot_rom.bin ../driver-$(RELEASE)/$(RELEASE)-slof.bin
@cp ../VERSION ../driver-$(RELEASE)
@cp changes.txt ../driver-$(RELEASE)
@cd ../driver-$(RELEASE) && md5sum * > md5sum.txt
@chmod 644 ../driver-$(RELEASE)/*
@mv ../driver-$(RELEASE) ../driver-$(RELEASE)-`date +%Y-%h%d`
@tar czf ../driver-$(RELEASE)-`date +%Y-%h%d`.tar.gz \
../driver-$(RELEASE)-`date +%Y-%h%d` > /dev/null 2>&1
@rm -rf ../driver-$(RELEASE)-`date +%Y-%h%d`

driver: driver_prep clean .tar_gz
41 changes: 41 additions & 0 deletions board-qemu/Makefile.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# *****************************************************************************
# * 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
# ****************************************************************************/
#
# This sub-Makefile contains the directory configuration variables.
# It can be included from all board specific subdirectories.
#

# The board specific top directory:
export TOPBRDDIR ?= $(shell while ! test -e Makefile.dirs ; do cd .. ; done ; pwd )

# The board specific directories:
export INCLBRDDIR ?= $(TOPBRDDIR)/include
export LLFWBRDDIR ?= $(TOPBRDDIR)/llfw
export RTASBRDDIR ?= $(TOPBRDDIR)/rtas
export SLOFBRDDIR ?= $(TOPBRDDIR)/slof
export ROMFSBRDDIR ?= $(TOPBRDDIR)/romfs

# The common top directory:
export TOPCMNDIR ?= $(shell cd $(TOPBRDDIR)/.. && pwd)

# The common directories:
export INCLCMNDIR ?= $(TOPCMNDIR)/include
export LLFWCMNDIR ?= $(TOPCMNDIR)/llfw
export RTASCMNDIR ?= $(TOPCMNDIR)/rtas
export SLOFCMNDIR ?= $(TOPCMNDIR)/slof
export ROMFSCMNDIR ?= $(TOPCMNDIR)/romfs

export LIBCMNDIR ?= $(TOPCMNDIR)/lib

export TOOLSDIR ?= $(TOPCMNDIR)/tools
export CLIENTSDIR ?= $(TOPCMNDIR)/clients
export OTHERLICENCEDIR ?= $(TOPCMNDIR)/other-licence
7 changes: 7 additions & 0 deletions board-qemu/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BOARD=qemu
TARG=ppc64
export FLAG="-DDISABLE_NVRAM"
export CPUARCH=ppcp7
export CPUARCHDEF=-DCPU_PPCP7
#export SNK_BIOSEMU_APPS=1
FLASH_SIZE=8388608
27 changes: 27 additions & 0 deletions board-qemu/include/hw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/******************************************************************************
* 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
*****************************************************************************/

uint16_t bswap16_load(uint64_t addr) ;
uint32_t bswap32_load(uint64_t addr) ;

void bswap16_store(uint64_t addr, uint16_t val) ;
void bswap32_store(uint64_t addr, uint32_t val) ;

uint8_t load8_ci(uint64_t addr) ;
uint16_t load16_ci(uint64_t addr) ;
uint32_t load32_ci(uint64_t addr) ;
uint64_t load64_ci(uint64_t addr) ;

void store8_ci(uint64_t addr, uint8_t val) ;
void store16_ci(uint64_t addr, uint16_t val) ;
void store32_ci(uint64_t addr, uint32_t val) ;
void store64_ci(uint64_t addr, uint64_t val) ;
65 changes: 65 additions & 0 deletions board-qemu/include/nvramlog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/******************************************************************************
* Copyright (c) 2004, 2011 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
*****************************************************************************/

#ifndef NVRAMLOG_H
#define NVRAMLOG_H

/* ----------------------------------------------------------------------------
* NVRAM Log-Partition header design:
*
* Partition Header
* 00h - signature ( 1 byte)
* 01h - checksum ( 1 byte)
* 02h - length ( 2 byte) value = 1st_byte*256 + 2nd_byte
* 04h - name (12 byte)
* space for partiton header = 16 byte
*
* Log Header
* 10h - offset ( 2 byte) from Partition Header to Data Section
* 12h - flags ( 2 byte) control flags
* 14h - pointer ( 4 byte) pointer to first free byte in Data Section
* relative to the beginning of the data section
* 18h - zero ( 32 byte) reserved as stack for four 64 bit register
* 38h - reserved ( 8 byte) reserved for 64 bit CRC (not implemented yet)
* space for header = 64 byte
* Data Section
* 40h - cyclic data
* -------------------------------------------------------------------------------- */

// initial values
#define LLFW_LOG_BE0_SIGNATURE 0x51 // signature for general firmware usage
#define LLFW_LOG_BE0_NAME_PREFIX 0x69626D2C // first 4 bytes of name: "ibm,"
#define LLFW_LOG_BE0_NAME 0x435055306C6F6700 // remaining 8 bytes : "CPU0log\0"
#define LLFW_LOG_BE0_LENGTH 0x2000 // Partition length in block of 16 bytes
#define LLFW_LOG_BE0_DATA_OFFSET 0x40 // offset in bytes between header and data
#define LLFW_LOG_BE0_FLAGS 0 // unused

#define LLFW_LOG_BE1_SIGNATURE 0x51 // signature for general firmware usage
#define LLFW_LOG_BE1_NAME_PREFIX 0x69626D2C // first 4 bytes of name: "ibm,"
#define LLFW_LOG_BE1_NAME 0x435055316C6F6700 // remaining 8 bytes : "CPU1log\0\0"
#define LLFW_LOG_BE1_LENGTH 0x500 // Partition length in block of 16 bytes
#define LLFW_LOG_BE1_DATA_OFFSET 0x40 // offset in bytes between header and data
#define LLFW_LOG_BE1_FLAGS 0x0 // unused

// positions of the initial values
#define LLFW_LOG_POS_CHECKSUM 0x01 // 1
#define LLFW_LOG_POS_LENGTH 0x02 // 2
#define LLFW_LOG_POS_NAME 0x04 // 4
#define LLFW_LOG_POS_DATA_OFFSET 0x10 // 16
#define LLFW_LOG_POS_FLAGS 0x12 // 18
#define LLFW_LOG_POS_POINTER 0x14 // 20

// NVRAM info
#define MAMBO_NVRAM_BASE 0x100000 // NVRAM Base for MAMBO
#define NVRAM_EMPTY_PATTERN 0x0000000000000000 // Pattern (64-bit) used to overwrite NVRAM

#endif
31 changes: 31 additions & 0 deletions board-qemu/include/product.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/******************************************************************************
* Copyright (c) 2004, 2011 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
*****************************************************************************/

#ifndef _PRODUCT_H
#define _PRODUCT_H

/* This is also the name which is also put in the flash and should
* therefore not excedd the length of 32 bytes */
#define PRODUCT_NAME "QEMU"

/* Generic identifier used in the flash */
#define FLASHFS_MAGIC "magic123"

/* Magic identifying the platform */
#define FLASHFS_PLATFORM_MAGIC "qemu0"

/* also used in the flash */
#define FLASHFS_PLATFORM_REVISION "1"

#define BOOT_MESSAGE "Press \"s\" to enter Open Firmware.\r\n\r\n\0"

#endif
20 changes: 20 additions & 0 deletions board-qemu/include/southbridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/******************************************************************************
* Copyright (c) 2011 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
*****************************************************************************/

/* Not used */
#define SB_NVRAM_adr 0
#define SB_FLASH_adr 0
#define NVRAM_LENGTH 0x10000
#define FLASH_LENGTH 0
#define SB_MAILBOX_adr 0

#define SECONDARY_CPUS_STOPPED
18 changes: 18 additions & 0 deletions board-qemu/llfw/Cboot.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/******************************************************************************
* 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
*****************************************************************************/

.org 0

/* Boot Information, hardcoded to ColdReset */
.quad 1
/* start address */
.quad 0x100
56 changes: 56 additions & 0 deletions board-qemu/llfw/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# *****************************************************************************
# * Copyright (c) 2004, 2011 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 ../../make.rules

CPPFLAGS = -I$(INCLBRDDIR) -I$(INCLCMNDIR) -I$(INCLCMNDIR)/$(CPUARCH) \
-I$(LIBCMNDIR)/libc/include
CFLAGS += -fno-builtin $(CPPFLAGS) -O2 -msoft-float $(MAMBO)
CFLAGS += $(BOOT) $(IOCONF) -Wa,-mregnames $(RELEASE) $(CPUARCHDEF) -Wall
ASFLAGS = $(BOOT) $(IOCONF) $(RELEASE)$(CPUARCHDEF) -Wa,-mregnames
LDFLAGS1 = -nostdlib -e__start -Tstage2.lds -N -Ttext=0x100


STG1OBJ = startup.o boot_abort.o romfs.o io_generic.o board_io.o
STG1OBJ += stage2_head.o stage2.o comlib.o romfs_wrap.o nvramlog.o

all: stage1.bin Cboot.o

stage1.bin: $(STG1OBJ) $(LIBCMNDIR)/libelf.a $(LIBCMNDIR)/libc.a
$(LD) $(LDFLAGS1) -o stage1.elf $^
$(OBJCOPY) -O binary stage1.elf $@

romfs.o: ../../llfw/romfs.S
$(CC) $(CFLAGS) -c ../../llfw/romfs.S

boot_abort.o: ../../llfw/boot_abort.S
$(CC) $(CFLAGS) -c ../../llfw/boot_abort.S

nvramlog.o: ../../llfw/nvramlog.S
$(CC) $(CFLAGS) -c ../../llfw/nvramlog.S

include $(LLFWCMNDIR)/clib/Makefile.inc

include $(LLFWCMNDIR)/io_generic/Makefile.inc

romfs_wrap.o: ../../llfw/romfs_wrap.c
$(CC) $(CFLAGS) -c ../../llfw/romfs_wrap.c

Cboot.o: Cboot.S
$(CC) $(CFLAGS) -c $^
$(OBJCOPY) -O binary Cboot.o Cboot.bin

%.o: %.S
$(CC) $(CFLAGS) -c $^

clean:
rm -f *.o *.bin *.elf
Loading

0 comments on commit 39426ba

Please sign in to comment.