mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
add initial sparc32 (qemu) support by Blue Swirl
git-svn-id: svn://coreboot.org/openbios/openbios-devel@3 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
5
include/sparc32/elf.h
Normal file
5
include/sparc32/elf.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#define ARCH_ELF_CLASS ELFCLASS32
|
||||
#define ARCH_ELF_DATA ELFDATA2MSB
|
||||
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_SPARC || (x)==EM_SPARC32PLUS)
|
||||
typedef Elf32_Ehdr Elf_ehdr;
|
||||
typedef Elf32_Phdr Elf_phdr;
|
||||
188
include/sparc32/io.h
Normal file
188
include/sparc32/io.h
Normal file
@@ -0,0 +1,188 @@
|
||||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
#define phys_to_virt(phys) ((void *) ((unsigned long) (phys)))
|
||||
#define virt_to_phys(virt) ((unsigned long) (virt))
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
|
||||
#ifndef _IO_BASE
|
||||
#define _IO_BASE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The insw/outsw/insl/outsl macros don't do byte-swapping.
|
||||
* They are only used in practice for transferring buffers which
|
||||
* are arrays of bytes, and byte-swapping is not appropriate in
|
||||
* that case. - paulus
|
||||
*/
|
||||
#define insw(port, buf, ns) _insw_ns((uint16_t *)((port)+_IO_BASE), (buf), (ns))
|
||||
#define outsw(port, buf, ns) _outsw_ns((uint16_t *)((port)+_IO_BASE), (buf), (ns))
|
||||
|
||||
#define inb(port) in_8((uint8_t *)((port)+_IO_BASE))
|
||||
#define outb(val, port) out_8((uint8_t *)((port)+_IO_BASE), (val))
|
||||
#define inw(port) in_le16((uint16_t *)((port)+_IO_BASE))
|
||||
#define outw(val, port) out_le16((uint16_t *)((port)+_IO_BASE), (val))
|
||||
#define inl(port) in_le32((uint32_t *)((port)+_IO_BASE))
|
||||
#define outl(val, port) out_le32((uint32_t *)((port)+_IO_BASE), (val))
|
||||
|
||||
/*
|
||||
* 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
|
||||
*/
|
||||
static inline int in_8(volatile unsigned char *addr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
__asm__ __volatile__("lduba [%1] 0x20, %0\n\t"
|
||||
"stbar\n\t"
|
||||
:"=r"(ret):"r"(addr):"memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void out_8(volatile unsigned char *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("stba %0, [%1] 0x20\n\t"
|
||||
"stbar\n\t"
|
||||
: : "r"(val), "r"(addr):"memory");
|
||||
}
|
||||
|
||||
static inline int in_le16(volatile unsigned short *addr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
// XXX
|
||||
__asm__ __volatile__("lduha [%1] 0x20, %0\n\t"
|
||||
"stbar\n\t"
|
||||
:"=r"(ret):"r"(addr):"memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int in_be16(volatile unsigned short *addr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
__asm__ __volatile__("lduha [%1] 0x20, %0\n\t"
|
||||
"stbar\n\t"
|
||||
:"=r"(ret):"r"(addr):"memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void out_le16(volatile unsigned short *addr, int val)
|
||||
{
|
||||
// XXX
|
||||
__asm__ __volatile__("stha %0, [%1] 0x20\n\t"
|
||||
"stbar\n\t"
|
||||
: : "r"(val), "r"(addr):"memory");
|
||||
}
|
||||
|
||||
static inline void out_be16(volatile unsigned short *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("stha %0, [%1] 0x20\n\t"
|
||||
"stbar\n\t"
|
||||
: : "r"(val), "r"(addr):"memory");
|
||||
}
|
||||
|
||||
static inline unsigned in_le32(volatile unsigned *addr)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
// XXX
|
||||
__asm__ __volatile__("lda [%1] 0x20, %0\n\t"
|
||||
"stbar\n\t"
|
||||
:"=r"(ret):"r"(addr):"memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline unsigned in_be32(volatile unsigned *addr)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
__asm__ __volatile__("lda [%1] 0x20, %0\n\t"
|
||||
"stbar\n\t"
|
||||
:"=r"(ret):"r"(addr):"memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void out_le32(volatile unsigned *addr, int val)
|
||||
{
|
||||
// XXX
|
||||
__asm__ __volatile__("sta %0, [%1] 0x20\n\t"
|
||||
"stbar\n\t"
|
||||
: : "r"(val), "r"(addr):"memory");
|
||||
}
|
||||
|
||||
static inline void out_be32(volatile unsigned *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("sta %0, [%1] 0x20\n\t"
|
||||
"stbar\n\t"
|
||||
: : "r"(val), "r"(addr):"memory");
|
||||
}
|
||||
|
||||
static inline void _insw_ns(volatile uint16_t * port, void *buf, int ns)
|
||||
{
|
||||
uint16_t *b = (uint16_t *) buf;
|
||||
|
||||
while (ns > 0) {
|
||||
*b++ = in_le16(port);
|
||||
ns--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _outsw_ns(volatile uint16_t * port, const void *buf,
|
||||
int ns)
|
||||
{
|
||||
uint16_t *b = (uint16_t *) buf;
|
||||
|
||||
while (ns > 0) {
|
||||
out_le16(port, *b++);
|
||||
ns--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _insw(volatile uint16_t * port, void *buf, int ns)
|
||||
{
|
||||
uint16_t *b = (uint16_t *) buf;
|
||||
|
||||
while (ns > 0) {
|
||||
*b++ = in_be16(port);
|
||||
ns--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void _outsw(volatile uint16_t * port, const void *buf,
|
||||
int ns)
|
||||
{
|
||||
uint16_t *b = (uint16_t *) buf;
|
||||
|
||||
while (ns > 0) {
|
||||
out_be16(port, *b++);
|
||||
ns--;
|
||||
}
|
||||
}
|
||||
#else /* BOOTSTRAP */
|
||||
#ifdef FCOMPILER
|
||||
#define inb(reg) ((u8)0xff)
|
||||
#define inw(reg) ((u16)0xffff)
|
||||
#define inl(reg) ((u32)0xffffffff)
|
||||
#define outb(reg, val) // nothing
|
||||
#define outw(reg, val) // nothing
|
||||
#define outl(reg, val) // nothing
|
||||
#else
|
||||
extern u8 inb(u32 reg);
|
||||
extern u16 inw(u32 reg);
|
||||
extern u32 inl(u32 reg);
|
||||
extern void insw(u32 reg, void *addr, unsigned long count);
|
||||
extern void outb(u32 reg, u8 val);
|
||||
extern void outw(u32 reg, u16 val);
|
||||
extern void outl(u32 reg, u32 val);
|
||||
extern void outsw(u32 reg, const void *addr, unsigned long count);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* _ASM_IO_H */
|
||||
47
include/sparc32/types.h
Normal file
47
include/sparc32/types.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* tag: data types for forth engine
|
||||
*
|
||||
* Copyright (C) 2003-2005 Patrick Mauritz, Stefan Reinauer
|
||||
*
|
||||
* See the file "COPYING" for further information about
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
|
||||
#ifndef __TYPES_H
|
||||
#define __TYPES_H
|
||||
|
||||
#include "mconfig.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* endianess */
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
#include <endian.h>
|
||||
#else
|
||||
#include <machine/endian.h>
|
||||
#endif
|
||||
|
||||
/* cell based types */
|
||||
|
||||
typedef int32_t cell;
|
||||
typedef uint32_t ucell;
|
||||
typedef int64_t dcell;
|
||||
typedef uint64_t ducell;
|
||||
|
||||
#define bitspercell (sizeof(cell)<<3)
|
||||
#define bitsperdcell (sizeof(dcell)<<3)
|
||||
|
||||
#define BITS 32
|
||||
|
||||
/* size named types */
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
typedef signed char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user