mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
initial import of openbios--main--1.0--patch-26
git-svn-id: svn://coreboot.org/openbios/openbios-devel@1 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
6
include/amd64/elf.h
Normal file
6
include/amd64/elf.h
Normal file
@@ -0,0 +1,6 @@
|
||||
/* for now we're a 32bit architecture */
|
||||
#define ARCH_ELF_CLASS ELFCLASS32
|
||||
#define ARCH_ELF_DATA ELFDATA2LSB
|
||||
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486)
|
||||
typedef Elf32_Ehdr Elf_ehdr;
|
||||
typedef Elf32_Phdr Elf_phdr;
|
||||
68
include/amd64/io.h
Normal file
68
include/amd64/io.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
extern unsigned long virt_offset;
|
||||
|
||||
#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset))
|
||||
#define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
|
||||
|
||||
#define __SLOW_DOWN_IO "outb %%al,$0x80;"
|
||||
static inline void slow_down_io(void)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
__SLOW_DOWN_IO
|
||||
#ifdef REALLY_SLOW_IO
|
||||
__SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#endif
|
||||
: : );
|
||||
}
|
||||
|
||||
#define BUILDIO(bwl,bw,type) \
|
||||
static inline void out##bwl(unsigned type value, int port) { \
|
||||
__asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
|
||||
} \
|
||||
static inline unsigned type in##bwl(int port) { \
|
||||
unsigned type value; \
|
||||
__asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \
|
||||
return value; \
|
||||
} \
|
||||
static inline void out##bwl##_p(unsigned type value, int port) { \
|
||||
out##bwl(value, port); \
|
||||
slow_down_io(); \
|
||||
} \
|
||||
static inline unsigned type in##bwl##_p(int port) { \
|
||||
unsigned type value = in##bwl(port); \
|
||||
slow_down_io(); \
|
||||
return value; \
|
||||
} \
|
||||
static inline void outs##bwl(int port, const void *addr, unsigned long count) { \
|
||||
__asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \
|
||||
} \
|
||||
static inline void ins##bwl(int port, void *addr, unsigned long count) { \
|
||||
__asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \
|
||||
}
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
BUILDIO(b,b,char)
|
||||
BUILDIO(w,w,short)
|
||||
BUILDIO(l,,int)
|
||||
#else
|
||||
#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
|
||||
43
include/amd64/types.h
Normal file
43
include/amd64/types.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* tag: data types for forth engine
|
||||
*
|
||||
* This file is autogenerated by types.sh. Do not edit!
|
||||
*
|
||||
* Copyright (C) 2003 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 <stdint.h>
|
||||
|
||||
/* endianess */
|
||||
#include <endian.h>
|
||||
|
||||
/* cell based types */
|
||||
|
||||
typedef int64_t cell;
|
||||
typedef uint64_t ucell;
|
||||
typedef __int128_t dcell;
|
||||
typedef __uint128_t ducell;
|
||||
|
||||
#define bitspercell (sizeof(cell)<<3)
|
||||
#define bitsperdcell (sizeof(dcell)<<3)
|
||||
|
||||
#define BITS 64
|
||||
|
||||
/* size named types */
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long u64;
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long s64;
|
||||
|
||||
#endif
|
||||
104
include/elf_boot.h
Normal file
104
include/elf_boot.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#ifndef ELF_BOOT_H
|
||||
#define ELF_BOOT_H
|
||||
|
||||
|
||||
/* This defines the structure of a table of parameters useful for ELF
|
||||
* bootable images. These parameters are all passed and generated
|
||||
* by the bootloader to the booted image. For simplicity and
|
||||
* consistency the Elf Note format is reused.
|
||||
*
|
||||
* All of the information must be Position Independent Data.
|
||||
* That is it must be safe to relocate the whole ELF boot parameter
|
||||
* block without changing the meaning or correctnes of the data.
|
||||
* Additionally it must be safe to permute the order of the ELF notes
|
||||
* to any possible permutation without changing the meaning or correctness
|
||||
* of the data.
|
||||
*
|
||||
*/
|
||||
|
||||
#define ELF_BHDR_MAGIC 0x0E1FB007
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
typedef uint16_t Elf_Half;
|
||||
typedef uint32_t Elf_Word;
|
||||
|
||||
/*
|
||||
* Elf boot notes...
|
||||
*/
|
||||
|
||||
typedef struct Elf_Bhdr
|
||||
{
|
||||
Elf_Word b_signature; /* "0x0E1FB007" */
|
||||
Elf_Word b_size;
|
||||
Elf_Half b_checksum;
|
||||
Elf_Half b_records;
|
||||
} Elf_Bhdr;
|
||||
|
||||
/*
|
||||
* ELF Notes.
|
||||
*/
|
||||
|
||||
typedef struct Elf_Nhdr
|
||||
{
|
||||
Elf_Word n_namesz; /* Length of the note's name. */
|
||||
Elf_Word n_descsz; /* Length of the note's descriptor. */
|
||||
Elf_Word n_type; /* Type of the note. */
|
||||
} Elf_Nhdr;
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/* Standardized Elf image notes for booting... The name for all of these is ELFBoot */
|
||||
#define ELF_NOTE_BOOT "ELFBoot"
|
||||
|
||||
#define EIN_PROGRAM_NAME 0x00000001
|
||||
/* The program in this ELF file */
|
||||
#define EIN_PROGRAM_VERSION 0x00000002
|
||||
/* The version of the program in this ELF file */
|
||||
#define EIN_PROGRAM_CHECKSUM 0x00000003
|
||||
/* ip style checksum of the memory image. */
|
||||
|
||||
|
||||
/* Linux image notes for booting... The name for all of these is Linux */
|
||||
|
||||
#define LIN_COMMAND_LINE 0x00000001
|
||||
/* The command line to pass to the loaded kernel. */
|
||||
#define LIN_ROOT_DEV 0x00000002
|
||||
/* The root dev to pass to the loaded kernel. */
|
||||
#define LIN_RAMDISK_FLAGS 0x00000003
|
||||
/* Various old ramdisk flags */
|
||||
#define LIN_INITRD_START 0x00000004
|
||||
/* Start of the ramdisk in bytes */
|
||||
#define LIN_INITRD_SIZE 0x00000005
|
||||
/* Size of the ramdisk in bytes */
|
||||
|
||||
/* Notes that are passed to a loaded image */
|
||||
/* For the standard elf boot notes n_namesz must be zero */
|
||||
#define EBN_FIRMWARE_TYPE 0x00000001
|
||||
/* ASCIZ name of the platform firmware. */
|
||||
#define EBN_BOOTLOADER_NAME 0x00000002
|
||||
/* This specifies just the ASCIZ name of the bootloader */
|
||||
#define EBN_BOOTLOADER_VERSION 0x00000003
|
||||
/* This specifies the version of the bootloader as an ASCIZ string */
|
||||
#define EBN_COMMAND_LINE 0x00000004
|
||||
/* This specifies a command line that can be set by user interaction,
|
||||
* and is provided as a free form ASCIZ string to the loaded image.
|
||||
*/
|
||||
#define EBN_NOP 0x00000005
|
||||
/* A note nop note has no meaning, useful for inserting explicit padding */
|
||||
#define EBN_LOADED_IMAGE 0x00000006
|
||||
/* An ASCIZ string naming the loaded image */
|
||||
|
||||
|
||||
/* Etherboot specific notes */
|
||||
#define EB_PARAM_NOTE "Etherboot"
|
||||
#define EB_IA64_SYSTAB 0x00000001
|
||||
#define EB_IA64_MEMMAP 0x00000002
|
||||
#define EB_IA64_FPSWA 0x00000003
|
||||
#define EB_IA64_CONINFO 0x00000004
|
||||
#define EB_BOOTP_DATA 0x00000005
|
||||
#define EB_HEADER 0x00000006
|
||||
#define EB_IA64_IMAGE_HANDLE 0x00000007
|
||||
#define EB_I386_MEMMAP 0x00000008
|
||||
|
||||
|
||||
#endif /* ELF_BOOT_H */
|
||||
5
include/ia64/elf.h
Normal file
5
include/ia64/elf.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#define ARCH_ELF_CLASS ELFCLASS64
|
||||
#define ARCH_ELF_DATA ELFDATA2LSB
|
||||
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_IA64)
|
||||
typedef Elf64_Ehdr Elf_ehdr;
|
||||
typedef Elf64_Phdr Elf_phdr;
|
||||
59
include/ia64/io.h
Normal file
59
include/ia64/io.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
extern unsigned long virt_offset;
|
||||
|
||||
#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset))
|
||||
#define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
|
||||
|
||||
#define __SLOW_DOWN_IO "outb %%al,$0x80;"
|
||||
static inline void slow_down_io(void)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
__SLOW_DOWN_IO
|
||||
#ifdef REALLY_SLOW_IO
|
||||
__SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#endif
|
||||
: : );
|
||||
}
|
||||
|
||||
#define BUILDIO(bwl,bw,type) \
|
||||
static inline void out##bwl(unsigned type value, int port) { \
|
||||
__asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
|
||||
} \
|
||||
static inline unsigned type in##bwl(int port) { \
|
||||
unsigned type value; \
|
||||
__asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \
|
||||
return value; \
|
||||
} \
|
||||
static inline void out##bwl##_p(unsigned type value, int port) { \
|
||||
out##bwl(value, port); \
|
||||
slow_down_io(); \
|
||||
} \
|
||||
static inline unsigned type in##bwl##_p(int port) { \
|
||||
unsigned type value = in##bwl(port); \
|
||||
slow_down_io(); \
|
||||
return value; \
|
||||
} \
|
||||
static inline void outs##bwl(int port, const void *addr, unsigned long count) { \
|
||||
__asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \
|
||||
} \
|
||||
static inline void ins##bwl(int port, void *addr, unsigned long count) { \
|
||||
__asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \
|
||||
}
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
BUILDIO(b,b,char)
|
||||
BUILDIO(w,w,short)
|
||||
BUILDIO(l,,int)
|
||||
#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
|
||||
44
include/ia64/types.h
Normal file
44
include/ia64/types.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* tag: data types for forth engine
|
||||
*
|
||||
* This file is autogenerated by types.sh. Do not edit!
|
||||
*
|
||||
* Copyright (C) 2003 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 <stdint.h>
|
||||
|
||||
/* endianess */
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
/* cell based types */
|
||||
|
||||
typedef int64_t cell;
|
||||
typedef uint64_t ucell;
|
||||
typedef __int128_t dcell;
|
||||
typedef __uint128_t ducell;
|
||||
|
||||
#define bitspercell (sizeof(cell)<<3)
|
||||
#define bitsperdcell (sizeof(dcell)<<3)
|
||||
|
||||
#define BITS 64
|
||||
|
||||
/* size named types */
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long u64;
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long s64;
|
||||
|
||||
#endif
|
||||
7
include/ipchecksum.h
Normal file
7
include/ipchecksum.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef IPCHECKSUM_H
|
||||
#define IPCHECKSUM_H
|
||||
|
||||
unsigned short ipchksum(const void *data, unsigned long length);
|
||||
unsigned short add_ipchksums(unsigned long offset, unsigned short sum, unsigned short new);
|
||||
|
||||
#endif /* IPCHECKSUM_H */
|
||||
42
include/libc/byteorder.h
Normal file
42
include/libc/byteorder.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* tag: byteorder prototypes
|
||||
*
|
||||
* Copyright (C) 2004 Stefan Reinauer
|
||||
*
|
||||
* see the file "COPYING" for further information about
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
#ifndef __BYTEORDER_H
|
||||
#define __BYTEORDER_H
|
||||
|
||||
#define __bswap32(x) \
|
||||
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
|
||||
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
|
||||
|
||||
#define __bswap16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
|
||||
|
||||
|
||||
#ifdef CONFIG_LITTLE_ENDIAN
|
||||
#define __cpu_to_le32(x) ((u32) (x))
|
||||
#define __le32_to_cpu(x) ((u32) (x))
|
||||
#define __cpu_to_le16(x) ((u16) (x))
|
||||
#define __le16_to_cpu(x) ((u16) (x))
|
||||
#define __cpu_to_be32(x) (__bswap32((u32) (x)))
|
||||
#define __be32_to_cpu(x) (__bswap32((u32) (x)))
|
||||
#define __cpu_to_be16(x) (__bswap16((u16) (x)))
|
||||
#define __be16_to_cpu(x) (__bswap16((u16) (x)))
|
||||
#endif
|
||||
#ifdef CONFIG_BIG_ENDIAN
|
||||
#define __cpu_to_le32(x) (__bswap32((u32) (x)))
|
||||
#define __le32_to_cpu(x) (__bswap32((u32) (x)))
|
||||
#define __cpu_to_le16(x) (__bswap16((u16) (x)))
|
||||
#define __le16_to_cpu(x) (__bswap16((u16) (x)))
|
||||
#define __cpu_to_be32(x) ((u32) (x))
|
||||
#define __be32_to_cpu(x) ((u32) (x))
|
||||
#define __cpu_to_be16(x) ((u16) (x))
|
||||
#define __be16_to_cpu(x) ((u16) (x))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
33
include/libc/diskio.h
Normal file
33
include/libc/diskio.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/20 00:57:01 samuel>
|
||||
* Time-stamp: <2004/01/07 19:32:29 samuel>
|
||||
*
|
||||
* <diskio.h>
|
||||
*
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_DISKIO
|
||||
#define _H_DISKIO
|
||||
|
||||
extern int open_ih( ihandle_t ih );
|
||||
extern int open_io( const char *spec );
|
||||
extern int close_io( int fd );
|
||||
extern int read_io( int fd, void *buf, size_t cnt );
|
||||
extern int seek_io( int fd, llong offs );
|
||||
extern llong tell( int fd );
|
||||
extern int reopen( int fd, const char *filename );
|
||||
extern int reopen_nwrom( int fd );
|
||||
extern ihandle_t get_ih_from_fd( int fd );
|
||||
const char *get_file_path( int fd );
|
||||
const char *get_fstype( int fd );
|
||||
const char *get_volume_name( int fd );
|
||||
|
||||
#endif /* _H_DISKIO */
|
||||
26
include/libc/stdlib.h
Normal file
26
include/libc/stdlib.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/19 18:52:20 samuel>
|
||||
* Time-stamp: <2003/12/19 18:52:21 samuel>
|
||||
*
|
||||
* <stdlib.h>
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_STDLIB
|
||||
#define _H_STDLIB
|
||||
|
||||
extern void *malloc( int size );
|
||||
extern void free( void *ptr );
|
||||
extern void *realloc( void *ptr, size_t size );
|
||||
|
||||
/* should perhaps go somewhere else... */
|
||||
extern void qsort( void *base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
|
||||
|
||||
#endif /* _H_STDLIB */
|
||||
99
include/libc/string.h
Normal file
99
include/libc/string.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Creation Date: <2002/10/12 20:41:57 samuel>
|
||||
* Time-stamp: <2003/10/25 12:51:22 samuel>
|
||||
*
|
||||
* <string.h>
|
||||
*
|
||||
* string library functions
|
||||
*
|
||||
* Copyright (C) 2002, 2003 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_STRING
|
||||
#define _H_STRING
|
||||
|
||||
#define bzero(s,n) memset( s, 0, n )
|
||||
#define atol(nptr) strtol(nptr, NULL, 10 )
|
||||
|
||||
extern long strtol( const char *nptr, char **endptr, int base );
|
||||
|
||||
extern int strnicmp(const char *s1, const char *s2, size_t len);
|
||||
extern char *strcpy(char * dest,const char *src);
|
||||
extern char *strncpy(char * dest,const char *src,size_t count);
|
||||
extern char *strcat(char * dest, const char * src);
|
||||
extern char *strncat(char *dest, const char *src, size_t count);
|
||||
extern int strcmp(const char * cs,const char * ct);
|
||||
extern int strncmp(const char * cs,const char * ct,size_t count);
|
||||
extern char *strchr(const char * s, int c);
|
||||
extern char *strrchr(const char * s, int c);
|
||||
extern size_t strlen(const char * s);
|
||||
extern size_t strnlen(const char * s, size_t count);
|
||||
extern size_t strspn(const char *s, const char *accept);
|
||||
extern char *strpbrk(const char * cs,const char * ct);
|
||||
extern char *strtok(char * s,const char * ct);
|
||||
extern char *strsep(char **s, const char *ct);
|
||||
extern void *memset(void * s,int c,size_t count);
|
||||
extern char *bcopy(const char * src, char * dest, int count);
|
||||
extern void *memcpy(void * dest,const void *src,size_t count);
|
||||
extern void *memmove(void * dest,const void *src,size_t count);
|
||||
extern int memcmp(const void * cs,const void * ct,size_t count);
|
||||
extern void *memscan(void * addr, int c, size_t size);void * memscan(void * addr, int c, size_t size);
|
||||
extern char *strstr(const char * s1,const char * s2);
|
||||
extern void *memchr(const void *s, int c, size_t n);
|
||||
|
||||
extern char *strdup( const char *str );
|
||||
extern int strcasecmp( const char *cs, const char *ct );
|
||||
|
||||
extern char *strncpy_nopad( char *dest, const char *src, size_t n );
|
||||
|
||||
#define _U 0x01 /* upper */
|
||||
#define _L 0x02 /* lower */
|
||||
#define _D 0x04 /* digit */
|
||||
#define _C 0x08 /* cntrl */
|
||||
#define _P 0x10 /* punct */
|
||||
#define _S 0x20 /* white space (space/lf/tab) */
|
||||
#define _X 0x40 /* hex digit */
|
||||
#define _SP 0x80 /* hard space (0x20) */
|
||||
|
||||
extern unsigned char _ctype[];
|
||||
|
||||
#define __ismask(x) (_ctype[(int)(unsigned char)(x)])
|
||||
|
||||
#define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
|
||||
#define isalpha(c) ((__ismask(c)&(_U|_L)) != 0)
|
||||
#define iscntrl(c) ((__ismask(c)&(_C)) != 0)
|
||||
#define isdigit(c) ((__ismask(c)&(_D)) != 0)
|
||||
#define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0)
|
||||
#define islower(c) ((__ismask(c)&(_L)) != 0)
|
||||
#define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
|
||||
#define ispunct(c) ((__ismask(c)&(_P)) != 0)
|
||||
#define isspace(c) ((__ismask(c)&(_S)) != 0)
|
||||
#define isupper(c) ((__ismask(c)&(_U)) != 0)
|
||||
#define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)
|
||||
|
||||
#define isascii(c) (((unsigned char)(c))<=0x7f)
|
||||
#define toascii(c) (((unsigned char)(c))&0x7f)
|
||||
|
||||
|
||||
static inline unsigned char __tolower(unsigned char c) {
|
||||
if (isupper(c))
|
||||
c -= 'A'-'a';
|
||||
return c;
|
||||
}
|
||||
|
||||
static inline unsigned char __toupper(unsigned char c) {
|
||||
if (islower(c))
|
||||
c -= 'a'-'A';
|
||||
return c;
|
||||
}
|
||||
|
||||
#define tolower(c) __tolower(c)
|
||||
#define toupper(c) __toupper(c)
|
||||
|
||||
|
||||
#endif /* _H_STRING */
|
||||
24
include/libc/vsprintf.h
Normal file
24
include/libc/vsprintf.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/20 01:51:22 samuel>
|
||||
* Time-stamp: <2004/01/07 19:02:17 samuel>
|
||||
*
|
||||
* <vsprintf.h>
|
||||
*
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_VSPRINTF
|
||||
#define _H_VSPRINTF
|
||||
|
||||
#include <stdarg.h>
|
||||
extern int vsprintf(char *buf, const char *fmt, va_list args );
|
||||
extern int sprintf(char * buf, const char *fmt, ...);
|
||||
|
||||
#endif /* _H_VSPRINTF */
|
||||
79
include/mconfig.h
Normal file
79
include/mconfig.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* We got rid of configure for now, and I hope it stays like this.
|
||||
* This file may have to be changed/reworked completely
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/* mconfig.h. Generated by configure. */
|
||||
/* mconfig.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#define HAVE_ENDIAN_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <machine/endian.h> header file. */
|
||||
/* #undef HAVE_MACHINE_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Minor OpenBIOS version */
|
||||
#define MINOR_VERSION 0
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME ""
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING ""
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION ""
|
||||
|
||||
/* Patchlevel */
|
||||
#define PATCH_LEVEL RC1
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version */
|
||||
#define VERSION "1.0.RC1"
|
||||
|
||||
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||
`char[]'. */
|
||||
#define YYTEXT_POINTER 1
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
38
include/ofmem.h
Normal file
38
include/ofmem.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Creation Date: <1999/11/16 00:47:06 samuel>
|
||||
* Time-stamp: <2003/10/18 13:28:14 samuel>
|
||||
*
|
||||
* <ofmem.h>
|
||||
*
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999, 2002 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_OFMEM
|
||||
#define _H_OFMEM
|
||||
|
||||
extern void ofmem_cleanup( void );
|
||||
extern void ofmem_init( void );
|
||||
|
||||
extern ulong ofmem_claim( ulong addr, ulong size, ulong align );
|
||||
extern ulong ofmem_claim_phys( ulong mphys, ulong size, ulong align );
|
||||
extern ulong ofmem_claim_virt( ulong mvirt, ulong size, ulong align );
|
||||
|
||||
extern int ofmem_map( ulong phys, ulong virt, ulong size, int mode );
|
||||
|
||||
extern void ofmem_release( ulong virt, ulong size );
|
||||
extern ulong ofmem_translate( ulong virt, ulong *ret_mode );
|
||||
|
||||
/* allocations from the private pool */
|
||||
extern void *malloc( int size );
|
||||
extern void free( void *ptr );
|
||||
extern void *realloc( void *ptr, size_t size );
|
||||
|
||||
|
||||
#endif /* _H_OFMEM */
|
||||
138
include/openbios/asm.m4
Normal file
138
include/openbios/asm.m4
Normal file
@@ -0,0 +1,138 @@
|
||||
/* -*- asm -*-
|
||||
* Creation Date: <2001/12/30 20:08:53 samuel>
|
||||
* Time-stamp: <2002/01/14 00:48:09 samuel>
|
||||
*
|
||||
* <asm.m4>
|
||||
*
|
||||
* m4 initialization (m4 is used as an assembly preprocessor)
|
||||
*
|
||||
* Copyright (C) 2001, 2002 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
/* This end-of-quote matches the start-of-quote in mol_config.h */
|
||||
]]]]]
|
||||
changequote([,])
|
||||
|
||||
dnl m4 macros to avoid in header files (we can not rename these)
|
||||
dnl ==========================================================
|
||||
dnl shift, eval, expr, decr, incr, ifelse, popdef, pushdef
|
||||
|
||||
|
||||
dnl **************************************************************
|
||||
dnl * Rename to reduce namespace conflicts
|
||||
dnl **************************************************************
|
||||
|
||||
dnl *** Changing the name of built-in macros using defn does not always work ***
|
||||
|
||||
undefine([changecom])
|
||||
undefine([changequote])
|
||||
dnl undefine([decr])
|
||||
undefine([defn])
|
||||
undefine([divert])
|
||||
undefine([divnum])
|
||||
undefine([errprint])
|
||||
dnl undefine([eval])
|
||||
dnl undefine([expr])
|
||||
undefine([file])
|
||||
undefine([format])
|
||||
undefine([len])
|
||||
undefine([line])
|
||||
dnl undefine([ifelse])
|
||||
dnl undefine([incr])
|
||||
undefine([indir])
|
||||
undefine([include])
|
||||
undefine([index])
|
||||
undefine([maketemp])
|
||||
undefine([paste])
|
||||
undefine([patsubst])
|
||||
dnl undefine([popdef])
|
||||
dnl undefine([pushdef])
|
||||
undefine([regexp])
|
||||
dnl undefine([shift])
|
||||
undefine([sinclude])
|
||||
undefine([spaste])
|
||||
undefine([substr])
|
||||
undefine([syscmd])
|
||||
undefine([sysval])
|
||||
undefine([translit])
|
||||
undefine([traceoff])
|
||||
undefine([traceon])
|
||||
undefine([undivert])
|
||||
undefine([unix])
|
||||
dnl undefine([__gnu__])
|
||||
dnl undefine([__unix__])
|
||||
|
||||
dnl Uncomment to list m4 definitions
|
||||
dnl dumpdef m4exit
|
||||
|
||||
/************************************************************************/
|
||||
/* M4 Macros */
|
||||
/************************************************************************/
|
||||
|
||||
/* WARNING - M4 BUG IN MacOS X (10.1.2):
|
||||
* eval() in MacOS X (10.1.2) handles '&' as '&&' and '|' as '||'.
|
||||
*/
|
||||
|
||||
/* FORLOOP(var, from, to, [body var...]) */
|
||||
define([mFORLOOP], [pushdef([$1], [$2])_mFORLOOP([$1], [$2], [$3], [$4])popdef([$1])])
|
||||
define([_mFORLOOP], [$4[]ifelse($1, [$3], ,
|
||||
[define([$1], incr($1))_mFORLOOP([$1], [$2], [$3], [$4])])])
|
||||
|
||||
define([mFIRST],[$1])
|
||||
define([mCONCAT_C],[ [$@] ])
|
||||
|
||||
/* FOREACH(var, [item1, ...], [body var ...]) */
|
||||
define([mFOREACH],[pushdef([$1],mFIRST($2))_mFOREACH([$1],[shift($2)],[$3])popdef([$1])])
|
||||
define([_mFOREACH],[$3] [ifelse(mFIRST($2),,,[define([$1],mFIRST($2)) _mFOREACH([$1],[shift($2)],[$3])])])
|
||||
|
||||
|
||||
/******************** Nice macro definitions **************************/
|
||||
|
||||
/* MACRO(name, [param1, ...], [body _param1 ...]) */
|
||||
#ifdef __linux__
|
||||
define([MACRO], [
|
||||
.macro [$1] $2
|
||||
mFOREACH([i],[$2],[ pushdef(_[]i,\i) ])
|
||||
$3
|
||||
.endm
|
||||
mFOREACH([i],[$2],[ popdef(_[]i) ])
|
||||
])
|
||||
#else
|
||||
define([MACRO], [
|
||||
.macro [$1]
|
||||
pushdef([_n],0)
|
||||
mFOREACH([i],[$2],[ pushdef(_[]i,[$[]]_n) define([_n],incr(_n)) ])
|
||||
$3
|
||||
.endmacro
|
||||
mFOREACH([i],[$2],[ popdef(_[]i) ])
|
||||
popdef([_n])
|
||||
])
|
||||
#endif
|
||||
define([MACRO_0], [MACRO([$1],[_dummy_param_],[$2])])
|
||||
|
||||
|
||||
/* mDEFINE(name, [param1, ...], [body _param1 ...]) */
|
||||
define([mDEFINE], [
|
||||
pushdef([_n],1)
|
||||
mFOREACH([i],[$2],[ pushdef(_[]i,[$[]]_n) define([_n],incr(_n)) ])
|
||||
define([$1], mCONCAT_C($3) )
|
||||
mFOREACH([i],[$2],[ popdef(_[]i) ])
|
||||
popdef([_n])
|
||||
])
|
||||
|
||||
|
||||
/* rLABEL(label): b label_b ; b label_f */
|
||||
define(rLABEL,[dnl
|
||||
ifdef([$1]_curnum,,[$1[]f:])dnl
|
||||
define([_tmp_curnum],ifdef($1[]_curnum, [eval($1_curnum+1)], 1)) dnl
|
||||
define([$1]_curnum,_tmp_curnum)dnl
|
||||
define([$1]f,$1_[]eval($1_curnum[]+1) )dnl
|
||||
define([$1]b,$1_[]$1_curnum[] )
|
||||
$1[]_[]$1_curnum[]dnl
|
||||
])
|
||||
|
||||
137
include/openbios/bindings.h
Normal file
137
include/openbios/bindings.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/19 23:09:56 samuel>
|
||||
* Time-stamp: <2004/01/07 19:36:42 samuel>
|
||||
*
|
||||
* <bindings.h>
|
||||
*
|
||||
* Forth bindings
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_BINDINGS
|
||||
#define _H_BINDINGS
|
||||
|
||||
#include "openbios/stack.h"
|
||||
#include "openbios/kernel.h"
|
||||
|
||||
#define PUSH3(a,b,c) do { PUSH((a)); PUSH((b)); PUSH((c)); } while(0)
|
||||
#define PUSH2(a,b) do { PUSH((a)); PUSH((b)); } while(0)
|
||||
#define RET( v ) do { PUSH(v); return; } while(0)
|
||||
|
||||
/* initialization */
|
||||
extern int initialize_forth( void );
|
||||
extern void exception( cell errcode );
|
||||
|
||||
/* panic */
|
||||
extern int forth_segv_handler( char *segv_addr );
|
||||
|
||||
/* active package */
|
||||
extern phandle_t find_dev( const char *path );
|
||||
extern phandle_t get_cur_dev( void );
|
||||
extern phandle_t activate_device( const char *str );
|
||||
extern void device_end( void );
|
||||
extern void activate_dev( phandle_t ph );
|
||||
|
||||
|
||||
/* ihandle related */
|
||||
extern phandle_t ih_to_phandle( ihandle_t ih );
|
||||
extern ihandle_t my_parent( void );
|
||||
extern ihandle_t my_self( void );
|
||||
extern char *my_args_copy( void );
|
||||
|
||||
extern xt_t find_package_method( const char *meth, phandle_t ph );
|
||||
extern xt_t find_ih_method( const char *method, ihandle_t ih );
|
||||
extern xt_t find_parent_method( const char *method );
|
||||
extern void call_package( xt_t xt, ihandle_t ihandle );
|
||||
extern void call_parent( xt_t xt );
|
||||
extern void call_parent_method( const char *method );
|
||||
|
||||
/* package */
|
||||
extern ihandle_t open_package( const char *argstr, phandle_t ph );
|
||||
extern ihandle_t open_dev( const char *spec );
|
||||
extern void close_package( ihandle_t ih );
|
||||
extern void close_dev( ihandle_t ih );
|
||||
|
||||
/* property access */
|
||||
extern void set_property( phandle_t ph, const char *name,
|
||||
const char *buf, int len );
|
||||
extern void set_int_property( phandle_t ph, const char *name,
|
||||
int val );
|
||||
extern int get_int_property( phandle_t ph, const char *name,
|
||||
int *retlen );
|
||||
extern char *get_property( phandle_t ph, const char *name,
|
||||
int *retlen );
|
||||
|
||||
/* device tree iteration */
|
||||
extern phandle_t dt_iter_begin( void );
|
||||
extern phandle_t dt_iterate( phandle_t last );
|
||||
extern phandle_t dt_iterate_type( phandle_t last, const char *type );
|
||||
static inline phandle_t dt_find_type( const char *type ) {
|
||||
return dt_iterate_type( 0, type );
|
||||
}
|
||||
|
||||
/* forth bindings */
|
||||
extern int feval( const char *str );
|
||||
extern void bind_xtfunc( const char *name, xt_t xt,
|
||||
ucell arg, void (*func)(void) );
|
||||
extern void bind_func( const char *name, void (*func)(void) );
|
||||
extern xt_t bind_noname_func( void (*func)(void) );
|
||||
extern void push_str( const char *str );
|
||||
extern char *pop_fstr_copy( void );
|
||||
|
||||
extern int _fword( const char *word, xt_t *cache_xt );
|
||||
extern int _eword( const char *word, xt_t *cache_xt, int nargs );
|
||||
extern int _selfword( const char *method, xt_t *cache_xt );
|
||||
extern int _parword( const char *method, xt_t *cache_xt );
|
||||
|
||||
#define fword(w) ({ static xt_t cache_xt = 0; _fword(w, &cache_xt); })
|
||||
#define eword(w, nargs) ({ static xt_t cache_xt = 0; _eword(w, &cache_xt, nargs); })
|
||||
#define selfword(w) ({ static xt_t cache_xt = 0; _selfword(w, &cache_xt); })
|
||||
#define parword(w) ({ static xt_t cache_xt = 0; _parword(w, &cache_xt); })
|
||||
|
||||
extern void throw( int error );
|
||||
|
||||
|
||||
/* node bindings */
|
||||
extern void make_openable( int only_parents );
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
void *func;
|
||||
} method_t;
|
||||
|
||||
#define DECLARE_UNNAMED_NODE( name, flags, size ) \
|
||||
static const int name##_flags_ = flags; \
|
||||
static const int name##_size_ = size;
|
||||
|
||||
#define DECLARE_NODE( name, flags, size, paths... ) \
|
||||
static char *name##_p[] = { paths }; \
|
||||
DECLARE_UNNAMED_NODE(name, flags, size)
|
||||
|
||||
#define NODE_METHODS( name ) \
|
||||
static method_t name##_m[]
|
||||
|
||||
#define REGISTER_NODE( name ) do { \
|
||||
bind_node( name##_flags_, name##_size_, \
|
||||
name##_p, sizeof(name##_p)/sizeof(char*), \
|
||||
name##_m, sizeof(name##_m)/sizeof(method_t) ); \
|
||||
} while(0)
|
||||
|
||||
extern void bind_node( int flags, int size, char **paths, int npaths,
|
||||
method_t *methods, int nmethods );
|
||||
|
||||
extern void bind_new_node( int flags, int size, char *name,
|
||||
method_t *methods, int nmethods );
|
||||
|
||||
#define INSTALL_OPEN 1 /* install trivial open and close methods */
|
||||
|
||||
|
||||
|
||||
#endif /* _H_BINDINGS */
|
||||
77
include/openbios/config.h
Normal file
77
include/openbios/config.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/20 00:07:16 samuel>
|
||||
* Time-stamp: <2004/01/19 17:40:26 stepan>
|
||||
*
|
||||
* <config.h>
|
||||
*
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_CONFIG
|
||||
#define _H_CONFIG
|
||||
|
||||
#include "autoconf.h"
|
||||
#include "mconfig.h"
|
||||
#include "asm/types.h"
|
||||
|
||||
#define PROGRAM_NAME "OpenBIOS"
|
||||
#define PROGRAM_VERSION VERSION
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar;
|
||||
|
||||
typedef unsigned int size_t;
|
||||
typedef unsigned int usize_t;
|
||||
typedef signed int ssize_t;
|
||||
typedef signed int off_t;
|
||||
|
||||
typedef unsigned long long ullong;
|
||||
typedef long long llong;
|
||||
|
||||
typedef unsigned int time_t;
|
||||
|
||||
#define UINT_MAX ((uint)-1)
|
||||
|
||||
#define ENOMEM 1
|
||||
#define EIO 2
|
||||
#define EINVAL 3
|
||||
#define ENOENT 4
|
||||
#define ENOTDIR 5
|
||||
#define EISDIR 6
|
||||
#define ENAMETOOLONG 7
|
||||
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_SET 2
|
||||
#define SEEK_END 3
|
||||
|
||||
#endif /* BOOTSTRAP */
|
||||
|
||||
#include "openbios/sysinclude.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
||||
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/* errno is a macro on some systems, which might cause nasty problems.
|
||||
* We try to cope with this here.
|
||||
*/
|
||||
#undef errno
|
||||
#define errno errno_int
|
||||
|
||||
#endif /* _H_CONFIG */
|
||||
20
include/openbios/drivers.h
Normal file
20
include/openbios/drivers.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* OpenBIOS driver prototypes
|
||||
*
|
||||
* (C) 2004 Stefan Reinauer <stepan@openbios.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "openbios/config.h"
|
||||
|
||||
#ifdef CONFIG_DRIVER_PCI
|
||||
int ob_pci_init(void);
|
||||
#endif
|
||||
#ifdef CONFIG_DRIVER_IDE
|
||||
int ob_ide_init(void);
|
||||
#endif
|
||||
|
||||
227
include/openbios/elf.h
Normal file
227
include/openbios/elf.h
Normal file
@@ -0,0 +1,227 @@
|
||||
#ifndef ELF_H
|
||||
#define ELF_H
|
||||
|
||||
#define EI_NIDENT 16 /* Size of e_ident array. */
|
||||
|
||||
/* Values for e_type. */
|
||||
#define ET_NONE 0 /* No file type */
|
||||
#define ET_REL 1 /* Relocatable file */
|
||||
#define ET_EXEC 2 /* Executable file */
|
||||
#define ET_DYN 3 /* Shared object file */
|
||||
#define ET_CORE 4 /* Core file */
|
||||
|
||||
/* Values for e_machine (architecute). */
|
||||
#define EM_NONE 0 /* No machine */
|
||||
#define EM_M32 1 /* AT&T WE 32100 */
|
||||
#define EM_SPARC 2 /* SUN SPARC */
|
||||
#define EM_386 3 /* Intel 80386+ */
|
||||
#define EM_68K 4 /* Motorola m68k family */
|
||||
#define EM_88K 5 /* Motorola m88k family */
|
||||
#define EM_486 6 /* Perhaps disused */
|
||||
#define EM_860 7 /* Intel 80860 */
|
||||
#define EM_MIPS 8 /* MIPS R3000 big-endian */
|
||||
#define EM_S370 9 /* IBM System/370 */
|
||||
#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
|
||||
|
||||
#define EM_PARISC 15 /* HPPA */
|
||||
#define EM_VPP500 17 /* Fujitsu VPP500 */
|
||||
#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
|
||||
#define EM_960 19 /* Intel 80960 */
|
||||
#define EM_PPC 20 /* PowerPC */
|
||||
#define EM_PPC64 21 /* PowerPC 64-bit */
|
||||
#define EM_S390 22 /* IBM S390 */
|
||||
|
||||
#define EM_V800 36 /* NEC V800 series */
|
||||
#define EM_FR20 37 /* Fujitsu FR20 */
|
||||
#define EM_RH32 38 /* TRW RH-32 */
|
||||
#define EM_RCE 39 /* Motorola RCE */
|
||||
#define EM_ARM 40 /* ARM */
|
||||
#define EM_FAKE_ALPHA 41 /* Digital Alpha */
|
||||
#define EM_SH 42 /* Hitachi SH */
|
||||
#define EM_SPARCV9 43 /* SPARC v9 64-bit */
|
||||
#define EM_TRICORE 44 /* Siemens Tricore */
|
||||
#define EM_ARC 45 /* Argonaut RISC Core */
|
||||
#define EM_H8_300 46 /* Hitachi H8/300 */
|
||||
#define EM_H8_300H 47 /* Hitachi H8/300H */
|
||||
#define EM_H8S 48 /* Hitachi H8S */
|
||||
#define EM_H8_500 49 /* Hitachi H8/500 */
|
||||
#define EM_IA_64 50 /* Intel Merced */
|
||||
#define EM_MIPS_X 51 /* Stanford MIPS-X */
|
||||
#define EM_COLDFIRE 52 /* Motorola Coldfire */
|
||||
#define EM_68HC12 53 /* Motorola M68HC12 */
|
||||
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
|
||||
#define EM_PCP 55 /* Siemens PCP */
|
||||
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
|
||||
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
|
||||
#define EM_STARCORE 58 /* Motorola Start*Core processor */
|
||||
#define EM_ME16 59 /* Toyota ME16 processor */
|
||||
#define EM_ST100 60 /* STMicroelectronic ST100 processor */
|
||||
#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
|
||||
#define EM_X86_64 62 /* AMD x86-64 architecture */
|
||||
#define EM_PDSP 63 /* Sony DSP Processor */
|
||||
|
||||
#define EM_FX66 66 /* Siemens FX66 microcontroller */
|
||||
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
|
||||
#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
|
||||
#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
|
||||
#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
|
||||
#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
|
||||
#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
|
||||
#define EM_SVX 73 /* Silicon Graphics SVx */
|
||||
#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
|
||||
#define EM_VAX 75 /* Digital VAX */
|
||||
#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
|
||||
#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
|
||||
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
|
||||
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
|
||||
#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
|
||||
#define EM_HUANY 81 /* Harvard University machine-independent object files */
|
||||
#define EM_PRISM 82 /* SiTera Prism */
|
||||
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
|
||||
#define EM_FR30 84 /* Fujitsu FR30 */
|
||||
#define EM_D10V 85 /* Mitsubishi D10V */
|
||||
#define EM_D30V 86 /* Mitsubishi D30V */
|
||||
#define EM_V850 87 /* NEC v850 */
|
||||
#define EM_M32R 88 /* Mitsubishi M32R */
|
||||
#define EM_MN10300 89 /* Matsushita MN10300 */
|
||||
#define EM_MN10200 90 /* Matsushita MN10200 */
|
||||
#define EM_PJ 91 /* picoJava */
|
||||
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
|
||||
#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
|
||||
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
|
||||
#define EM_NUM 95
|
||||
|
||||
/* Values for p_type. */
|
||||
#define PT_NULL 0 /* Unused entry. */
|
||||
#define PT_LOAD 1 /* Loadable segment. */
|
||||
#define PT_DYNAMIC 2 /* Dynamic linking information segment. */
|
||||
#define PT_INTERP 3 /* Pathname of interpreter. */
|
||||
#define PT_NOTE 4 /* Auxiliary information. */
|
||||
#define PT_SHLIB 5 /* Reserved (not used). */
|
||||
#define PT_PHDR 6 /* Location of program header itself. */
|
||||
|
||||
/* Values for p_flags. */
|
||||
#define PF_X 0x1 /* Executable. */
|
||||
#define PF_W 0x2 /* Writable. */
|
||||
#define PF_R 0x4 /* Readable. */
|
||||
|
||||
|
||||
#define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */
|
||||
|
||||
#define EI_MAG0 0
|
||||
#define ELFMAG0 0x7f
|
||||
|
||||
#define EI_MAG1 1
|
||||
#define ELFMAG1 'E'
|
||||
|
||||
#define EI_MAG2 2
|
||||
#define ELFMAG2 'L'
|
||||
|
||||
#define EI_MAG3 3
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
#define ELFMAG "\177ELF"
|
||||
|
||||
#define EI_CLASS 4 /* File class byte index */
|
||||
#define ELFCLASSNONE 0 /* Invalid class */
|
||||
#define ELFCLASS32 1 /* 32-bit objects */
|
||||
#define ELFCLASS64 2 /* 64-bit objects */
|
||||
|
||||
#define EI_DATA 5 /* Data encodeing byte index */
|
||||
#define ELFDATANONE 0 /* Invalid data encoding */
|
||||
#define ELFDATA2LSB 1 /* 2's complement little endian */
|
||||
#define ELFDATA2MSB 2 /* 2's complement big endian */
|
||||
|
||||
#define EI_VERSION 6 /* File version byte index */
|
||||
/* Value must be EV_CURRENT */
|
||||
|
||||
#define EV_NONE 0 /* Invalid ELF Version */
|
||||
#define EV_CURRENT 1 /* Current version */
|
||||
|
||||
#define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#include "asm/types.h"
|
||||
/*
|
||||
* ELF definitions common to all 32-bit architectures.
|
||||
*/
|
||||
|
||||
typedef uint32_t Elf32_Addr;
|
||||
typedef uint16_t Elf32_Half;
|
||||
typedef uint32_t Elf32_Off;
|
||||
typedef int32_t Elf32_Sword;
|
||||
typedef uint32_t Elf32_Word;
|
||||
typedef uint32_t Elf32_Size;
|
||||
|
||||
typedef uint64_t Elf64_Addr;
|
||||
typedef uint16_t Elf64_Half;
|
||||
typedef uint64_t Elf64_Off;
|
||||
typedef int32_t Elf64_Sword;
|
||||
typedef uint32_t Elf64_Word;
|
||||
typedef uint64_t Elf64_Size;
|
||||
|
||||
/*
|
||||
* ELF header.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT]; /* File identification. */
|
||||
Elf32_Half e_type; /* File type. */
|
||||
Elf32_Half e_machine; /* Machine architecture. */
|
||||
Elf32_Word e_version; /* ELF format version. */
|
||||
Elf32_Addr e_entry; /* Entry point. */
|
||||
Elf32_Off e_phoff; /* Program header file offset. */
|
||||
Elf32_Off e_shoff; /* Section header file offset. */
|
||||
Elf32_Word e_flags; /* Architecture-specific flags. */
|
||||
Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
|
||||
Elf32_Half e_phentsize; /* Size of program header entry. */
|
||||
Elf32_Half e_phnum; /* Number of program header entries. */
|
||||
Elf32_Half e_shentsize; /* Size of section header entry. */
|
||||
Elf32_Half e_shnum; /* Number of section header entries. */
|
||||
Elf32_Half e_shstrndx; /* Section name strings section. */
|
||||
} Elf32_Ehdr;
|
||||
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT]; /* File identification. */
|
||||
Elf64_Half e_type; /* File type. */
|
||||
Elf64_Half e_machine; /* Machine architecture. */
|
||||
Elf64_Word e_version; /* ELF format version. */
|
||||
Elf64_Addr e_entry; /* Entry point. */
|
||||
Elf64_Off e_phoff; /* Program header file offset. */
|
||||
Elf64_Off e_shoff; /* Section header file offset. */
|
||||
Elf64_Word e_flags; /* Architecture-specific flags. */
|
||||
Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
|
||||
Elf64_Half e_phentsize; /* Size of program header entry. */
|
||||
Elf64_Half e_phnum; /* Number of program header entries. */
|
||||
Elf64_Half e_shentsize; /* Size of section header entry. */
|
||||
Elf64_Half e_shnum; /* Number of section header entries. */
|
||||
Elf64_Half e_shstrndx; /* Section name strings section. */
|
||||
} Elf64_Ehdr;
|
||||
|
||||
/*
|
||||
* Program header.
|
||||
*/
|
||||
typedef struct {
|
||||
Elf32_Word p_type; /* Entry type. */
|
||||
Elf32_Off p_offset; /* File offset of contents. */
|
||||
Elf32_Addr p_vaddr; /* Virtual address (not used). */
|
||||
Elf32_Addr p_paddr; /* Physical address. */
|
||||
Elf32_Size p_filesz; /* Size of contents in file. */
|
||||
Elf32_Size p_memsz; /* Size of contents in memory. */
|
||||
Elf32_Word p_flags; /* Access permission flags. */
|
||||
Elf32_Size p_align; /* Alignment in memory and file. */
|
||||
} Elf32_Phdr;
|
||||
|
||||
typedef struct {
|
||||
Elf64_Word p_type; /* Entry type. */
|
||||
Elf64_Word p_flags; /* Access permission flags. */
|
||||
Elf64_Off p_offset; /* File offset of contents. */
|
||||
Elf64_Addr p_vaddr; /* Virtual address (not used). */
|
||||
Elf64_Addr p_paddr; /* Physical address. */
|
||||
Elf64_Size p_filesz; /* Size of contents in file. */
|
||||
Elf64_Size p_memsz; /* Size of contents in memory. */
|
||||
Elf64_Size p_align; /* Alignment in memory and file. */
|
||||
} Elf64_Phdr;
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* ELF_H */
|
||||
29
include/openbios/elfload.h
Normal file
29
include/openbios/elfload.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Creation Date: <2001/05/05 16:44:17 samuel>
|
||||
* Time-stamp: <2003/10/22 23:18:42 samuel>
|
||||
*
|
||||
* <elfload.h>
|
||||
*
|
||||
* Elf loader
|
||||
*
|
||||
* Copyright (C) 2001, 2003 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_ELFLOAD
|
||||
#define _H_ELFLOAD
|
||||
|
||||
#include "openbios/elf.h"
|
||||
#include "asm/elf.h"
|
||||
|
||||
extern int is_elf( int fd, int offs );
|
||||
extern int find_elf( int fd );
|
||||
|
||||
extern Elf32_Phdr * elf_readhdrs( int fd, int offs, Elf32_Ehdr *e );
|
||||
|
||||
|
||||
#endif /* _H_ELFLOAD */
|
||||
77
include/openbios/fs.h
Normal file
77
include/openbios/fs.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Creation Date: <2001/05/06 17:12:45 samuel>
|
||||
* Time-stamp: <2003/10/22 11:43:45 samuel>
|
||||
*
|
||||
* <fs_loader.h>
|
||||
*
|
||||
* Generic file system access
|
||||
*
|
||||
* Copyright (C) 2001, 2002, 2003 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_FS
|
||||
#define _H_FS
|
||||
|
||||
|
||||
typedef struct fs_ops fs_ops_t;
|
||||
typedef struct opaque_struct file_desc_t;
|
||||
|
||||
#define fs_open_path( fs, path ) (fs)->open_path( fs, path )
|
||||
#define fs_search_rom( fs ) (fs)->search_rom( fs )
|
||||
#define fs_search_file( fs, name ) (fs)->search_file( fs, name )
|
||||
#define fs_vol_name( fs, buf, size ) (fs)->vol_name( fs, buf, size )
|
||||
|
||||
struct fs_ops {
|
||||
void *fs_data;
|
||||
int fd; /* owner block device */
|
||||
int type;
|
||||
|
||||
void (*close_fs)( fs_ops_t *fs );
|
||||
file_desc_t *(*open_path)( fs_ops_t *fs, const char *path );
|
||||
file_desc_t *(*search_rom)( fs_ops_t *fs );
|
||||
file_desc_t *(*search_file)( fs_ops_t *fs, const char *name );
|
||||
char *(*vol_name)( fs_ops_t *fs, char *buf, int size );
|
||||
|
||||
/* file ops */
|
||||
void (*close)( file_desc_t *file );
|
||||
int (*read)( file_desc_t *file, void *buf, size_t count );
|
||||
int (*lseek)( file_desc_t *file, off_t offset, int whence );
|
||||
char *(*get_path)( file_desc_t *file, char *buf, int len );
|
||||
|
||||
char *(*get_fstype)( fs_ops_t *fs );
|
||||
};
|
||||
|
||||
extern fs_ops_t *fs_open( int fs_type, int fd );
|
||||
extern void fs_close( fs_ops_t *fs );
|
||||
const char *fs_get_name( fs_ops_t *fs );
|
||||
|
||||
#ifdef CONFIG_HFSP
|
||||
extern int fs_hfsp_open( int fd, fs_ops_t *fs );
|
||||
#else
|
||||
static inline int fs_hfsp_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HFS
|
||||
extern int fs_hfs_open( int fd, fs_ops_t *fs );
|
||||
#else
|
||||
static inline int fs_hfs_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GRUBFS
|
||||
extern int fs_grubfs_open( int fd, fs_ops_t *fs );
|
||||
#else
|
||||
static inline int fs_grubfs_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* misc */
|
||||
extern char *get_hfs_vol_name( int fd, char *buf, int size );
|
||||
|
||||
|
||||
#endif /* _H_FS */
|
||||
47
include/openbios/kernel.h
Normal file
47
include/openbios/kernel.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/19 00:20:11 samuel>
|
||||
* Time-stamp: <2004/01/07 19:19:14 samuel>
|
||||
*
|
||||
* <kernel.h>
|
||||
*
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
* Stefan Reinauer (stepan@openbios.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_KERNEL
|
||||
#define _H_KERNEL
|
||||
|
||||
#include "openbios/stack.h"
|
||||
#include "asm/io.h"
|
||||
|
||||
extern volatile int runforth;
|
||||
extern int enterforth( xt_t xt );
|
||||
extern void panic(const char *error) __attribute__ ((noreturn));
|
||||
|
||||
extern xt_t findword(char *s1);
|
||||
extern void modules_init( void );
|
||||
|
||||
/* arch kernel hooks */
|
||||
extern void exception(cell no);
|
||||
|
||||
#ifdef FCOMPILER
|
||||
extern void include_file( const char *str );
|
||||
extern void encode_file( const char *str );
|
||||
extern int get_inputbyte( void );
|
||||
#endif
|
||||
|
||||
#undef putchar
|
||||
#undef getchar
|
||||
|
||||
extern int putchar( int ch );
|
||||
extern int availchar( void );
|
||||
extern int getchar( void );
|
||||
|
||||
#endif /* _H_KERNEL */
|
||||
27
include/openbios/nvram.h
Normal file
27
include/openbios/nvram.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Creation Date: <2003/12/20 01:04:25 samuel>
|
||||
* Time-stamp: <2004/01/07 19:59:11 samuel>
|
||||
*
|
||||
* <nvram.h>
|
||||
*
|
||||
* arch NVRAM interface
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_NVRAM
|
||||
#define _H_NVRAM
|
||||
|
||||
extern int arch_nvram_size( void );
|
||||
extern void arch_nvram_get( char *buf );
|
||||
extern void arch_nvram_put( char *buf );
|
||||
|
||||
extern void nvram_init( void );
|
||||
extern void update_nvram( void );
|
||||
|
||||
#endif /* _H_NVRAM */
|
||||
22
include/openbios/of.h
Normal file
22
include/openbios/of.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Creation Date: <2004/01/07 19:19:18 samuel>
|
||||
* Time-stamp: <2004/01/07 19:19:48 samuel>
|
||||
*
|
||||
* <of.h>
|
||||
*
|
||||
* OpenFirmware related defines
|
||||
*
|
||||
* Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_OF
|
||||
#define _H_OF
|
||||
|
||||
extern int of_client_interface( int *params );
|
||||
|
||||
#endif /* _H_OF */
|
||||
90
include/openbios/stack.h
Normal file
90
include/openbios/stack.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* stack.h
|
||||
* tag: stack and stack access functions
|
||||
*
|
||||
* Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
|
||||
*
|
||||
* See the file "COPYING" for further information about
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
|
||||
#ifndef __STACK_H
|
||||
#define __STACK_H
|
||||
|
||||
#define dstacksize 512
|
||||
extern int dstackcnt;
|
||||
extern cell dstack[dstacksize];
|
||||
|
||||
#define rstacksize 512
|
||||
extern int rstackcnt;
|
||||
extern cell rstack[rstacksize];
|
||||
|
||||
//typedef struct opaque_xt *xt_t;
|
||||
//typedef struct opaque_ihandle *ihandle_t;
|
||||
//typedef struct opaque_phandle *phandle_t;
|
||||
|
||||
typedef ucell xt_t;
|
||||
typedef ucell ihandle_t;
|
||||
typedef ucell phandle_t;
|
||||
|
||||
|
||||
|
||||
|
||||
static inline void PUSH(ucell value) {
|
||||
dstack[++dstackcnt] = (value);
|
||||
}
|
||||
static inline void PUSH_xt( xt_t xt ) { PUSH( (ucell)xt ); }
|
||||
static inline void PUSH_ih( ihandle_t ih ) { PUSH( (ucell)ih ); }
|
||||
static inline void PUSH_ph( phandle_t ph ) { PUSH( (ucell)ph ); }
|
||||
|
||||
static inline ucell POP(void) {
|
||||
return (ucell) dstack[dstackcnt--];
|
||||
}
|
||||
static inline xt_t POP_xt( void ) { return (xt_t)POP(); }
|
||||
static inline ihandle_t POP_ih( void ) { return (ihandle_t)POP(); }
|
||||
static inline phandle_t POP_ph( void ) { return (phandle_t)POP(); }
|
||||
|
||||
static inline void DROP(void) {
|
||||
dstackcnt--;
|
||||
}
|
||||
|
||||
static inline void DDROP(void) {
|
||||
dstackcnt -= 2;
|
||||
}
|
||||
|
||||
static inline void DPUSH(ducell value) {
|
||||
dstack[++dstackcnt] = (cell) value;
|
||||
dstack[++dstackcnt] = (cell) (value >> bitspercell);
|
||||
}
|
||||
|
||||
static inline ducell DPOP(void) {
|
||||
ducell du;
|
||||
du = ((ducell) ((ucell) dstack[dstackcnt--]) << bitspercell);
|
||||
du |= (ucell) dstack[dstackcnt--];
|
||||
return du;
|
||||
}
|
||||
|
||||
static inline ucell GETTOS(void) {
|
||||
return dstack[dstackcnt];
|
||||
}
|
||||
|
||||
#define GETITEM(number) (dstack[dstackcnt - number])
|
||||
static inline void PUSHR(ucell value) {
|
||||
rstack[++rstackcnt] = (value);
|
||||
}
|
||||
|
||||
static inline ucell POPR(void) {
|
||||
return (ucell) rstack[rstackcnt--];
|
||||
}
|
||||
static inline ucell GETTORS(void) {
|
||||
return rstack[rstackcnt];
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG_DSTACK) || defined(FCOMPILER)
|
||||
void printdstack(void);
|
||||
#endif
|
||||
#if defined(DEBUG_RSTACK) || defined(FCOMPILER)
|
||||
void printrstack(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
20
include/openbios/sysinclude.h
Normal file
20
include/openbios/sysinclude.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __SYSINCLUDE_H
|
||||
#define __SYSINCLUDE_H
|
||||
|
||||
#ifdef BOOTSTRAP
|
||||
#include "asm/types.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#else /* BOOTSTRAP */
|
||||
#include "libc/stdlib.h"
|
||||
#include "libc/string.h"
|
||||
#endif /* BOOTSTRAP */
|
||||
|
||||
extern int printk( const char *fmt, ... ) \
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
#ifdef BOOTSTRAP
|
||||
#define printk printf
|
||||
#endif
|
||||
|
||||
#endif /* __SYSINCLUDE_H */
|
||||
371
include/ppc/asmdefs.h
Normal file
371
include/ppc/asmdefs.h
Normal file
@@ -0,0 +1,371 @@
|
||||
/* -*- asm -*-
|
||||
*
|
||||
* Creation Date: <2001/02/03 19:38:07 samuel>
|
||||
* Time-stamp: <2003/07/08 18:55:50 samuel>
|
||||
*
|
||||
* <asmdefs.h>
|
||||
*
|
||||
* Common assembly definitions
|
||||
*
|
||||
* Copyright (C) 2001, 2002, 2003 Samuel Rydh (samuel@ibrium.se)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_ASMDEFS
|
||||
#define _H_ASMDEFS
|
||||
|
||||
#include "openbios/asm.m4"
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#error This file is only to be included from assembler code!
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* High/low halfword compatibility macros */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __linux__
|
||||
#define ha16( v ) (v)##@ha
|
||||
#define hi16( v ) (v)##@h
|
||||
#define lo16( v ) (v)##@l
|
||||
#endif
|
||||
#define HA(v) ha16(v)
|
||||
#define HI(v) hi16(v)
|
||||
#define LO(v) lo16(v)
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Register name prefix */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __linux__
|
||||
define([rPREFIX], [])
|
||||
define([fPREFIX], [])
|
||||
define([srPREFIX], [])
|
||||
#else
|
||||
define([rPREFIX], [r])
|
||||
define([fPREFIX], [f])
|
||||
define([srPREFIX], [sr])
|
||||
/* frN -> fN */
|
||||
mFORLOOP([i],0,31,[define(fr[]i,f[]i)])
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
/* Macros and definitions */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __darwin__
|
||||
#define balign_4 .align 2,0
|
||||
#define balign_8 .align 3,0
|
||||
#define balign_16 .align 4,0
|
||||
#define balign_32 .align 5,0
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#define balign_4 .balign 4,0
|
||||
#define balign_8 .balign 8,0
|
||||
#define balign_16 .balign 16,0
|
||||
#define balign_32 .balign 32,0
|
||||
#endif
|
||||
|
||||
MACRO(LOADVAR, [dreg, variable], [
|
||||
lis _dreg,HA(_variable)
|
||||
lwz _dreg,LO(_variable)(_dreg)
|
||||
])
|
||||
|
||||
MACRO(LOADI, [dreg, addr], [
|
||||
lis _dreg,HA(_addr)
|
||||
addi _dreg,_dreg,LO(_addr)
|
||||
])
|
||||
|
||||
MACRO(LOAD_GPR_RANGE, [start, endx, offs, base], [
|
||||
mFORLOOP([i],0,31,[ .if (i >= _start) & (i <= _endx)
|
||||
lwz rPREFIX[]i,_offs+i[]*4(_base)
|
||||
.endif
|
||||
])])
|
||||
|
||||
MACRO(STORE_GPR_RANGE, [start, endx, offs, base], [
|
||||
mFORLOOP([i],0,31,[ .if (i >= _start) & (i <= _endx)
|
||||
stw rPREFIX[]i,_offs+i[]*4(_base)
|
||||
.endif
|
||||
])])
|
||||
|
||||
MACRO(LOAD_FPR_RANGE, [start, endx, offs, base], [
|
||||
mFORLOOP([i],0,31,[ .if (i >= _start) & (i <= _endx)
|
||||
lfd fPREFIX[]i,_offs+i[]*8(_base)
|
||||
.endif
|
||||
])])
|
||||
|
||||
MACRO(STORE_FPR_RANGE, [start, endx, offs, base], [
|
||||
mFORLOOP([i],0,31,[ .if (i >= _start) & (i <= _endx)
|
||||
stfd fPREFIX[]i,_offs+i[]*8(_base)
|
||||
.endif
|
||||
])])
|
||||
|
||||
/************************************************************************/
|
||||
/* FPU load/save macros */
|
||||
/************************************************************************/
|
||||
|
||||
// The FPU macros are used both in the kernel and in
|
||||
// mainloop_asm.h.
|
||||
|
||||
MACRO(xFPR_LOAD_RANGE, [from, to, mbase], [
|
||||
LOAD_FPR_RANGE _from,_to,xFPR_BASE,_mbase
|
||||
])
|
||||
MACRO(xFPR_SAVE_RANGE, [from, to, mbase], [
|
||||
STORE_FPR_RANGE _from,_to,xFPR_BASE,_mbase
|
||||
])
|
||||
// The low half of the fpu is fr0-fr12. I.e. the FPU registers
|
||||
// that might be overwritten when a function call is taken
|
||||
// (fr13 and fpscr are treated specially).
|
||||
|
||||
MACRO(xLOAD_LOW_FPU, [mbase], [
|
||||
xFPR_LOAD_RANGE 0,12,_mbase
|
||||
])
|
||||
|
||||
MACRO(xLOAD_TOPHALF_FPU, [mbase], [
|
||||
xFPR_LOAD_RANGE 14,31,_mbase
|
||||
])
|
||||
MACRO(xLOAD_FULL_FPU, [mbase], [
|
||||
xLOAD_LOW_FPU _mbase
|
||||
xLOAD_TOPHALF_FPU _mbase
|
||||
])
|
||||
|
||||
MACRO(xSAVE_LOW_FPU, [mbase], [
|
||||
xFPR_SAVE_RANGE 0,12,_mbase
|
||||
])
|
||||
MACRO(xSAVE_TOPHALF_FPU, [mbase], [
|
||||
xFPR_SAVE_RANGE 14,31,_mbase
|
||||
])
|
||||
MACRO(xSAVE_FULL_FPU, [mbase], [
|
||||
xSAVE_LOW_FPU _mbase
|
||||
xSAVE_TOPHALF_FPU _mbase
|
||||
])
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* GPR load/save macros */
|
||||
/************************************************************************/
|
||||
|
||||
MACRO(xGPR_SAVE_RANGE, [from, to, mbase], [
|
||||
STORE_GPR_RANGE _from, _to, xGPR0, _mbase
|
||||
])
|
||||
|
||||
MACRO(xGPR_LOAD_RANGE, [from, to, mbase], [
|
||||
LOAD_GPR_RANGE _from, _to, xGPR0, _mbase
|
||||
])
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* AltiVec */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
define(vPREFIX,[])
|
||||
|
||||
#ifndef HAVE_ALTIVEC
|
||||
#define VEC_OPCODE( op1,op2,A,B,C ) \
|
||||
.long (((op1) << (32-6)) | (op2) | ((A) << (32-11)) | ((B) << (32-16)) | ((C) << (32-21))) ;
|
||||
|
||||
#define __stvx( vS,rA,rB ) VEC_OPCODE( 31,0x1ce,vS,rA,rB )
|
||||
#define __lvx( vD,rA,rB ) VEC_OPCODE( 31,0xce, vD,rA,rB )
|
||||
#define __mfvscr( vD ) VEC_OPCODE( 4,1540,vD,0,0 )
|
||||
#define __mtvscr( vB ) VEC_OPCODE( 4,1604,0,0,vB )
|
||||
#define __stvewx( vS,rA,rB ) VEC_OPCODE( 31,(199<<1), vS,rA,rB )
|
||||
|
||||
mFORLOOP([i],0,31,[define(v[]i,[]i)])
|
||||
MACRO(stvx, [vS,rA,rB], [ __stvx( _vS,_rA,_rB ) ; ])
|
||||
MACRO(lvx, [vD,rA,rB], [ __lvx( _vD,_rA,_rB ) ; ])
|
||||
MACRO(mfvscr, [vD], [ __mfvscr( _vD ) ; ])
|
||||
MACRO(mtvscr, [vB], [ __mtvscr( _vB ) ; ])
|
||||
MACRO(stvewx, [vS,rA,rB], [ __stvewx( _vS,_rA,_rB ) ; ])
|
||||
#endif
|
||||
#else /* __linux__ */
|
||||
|
||||
define(vPREFIX,[v])
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
|
||||
// NOTE: Writing to VSCR won't cause exceptions (this
|
||||
// is different compared to FPSCR).
|
||||
|
||||
MACRO(xVEC_SAVE, [mbase, scr], [
|
||||
addi _scr,_mbase,xVEC_BASE
|
||||
mFORLOOP([i],0,31,[
|
||||
stvx vPREFIX[]i,0,_scr
|
||||
addi _scr,_scr,16
|
||||
])
|
||||
addi _scr,_mbase,xVSCR-12
|
||||
mfvscr v0
|
||||
stvx v0,0,_scr
|
||||
addi _scr,_mbase,xVEC0
|
||||
lvx v0,0,_scr
|
||||
mfspr _scr,S_VRSAVE
|
||||
stw _scr,xVRSAVE(_mbase)
|
||||
])
|
||||
|
||||
MACRO(xVEC_LOAD, [mbase, scr], [
|
||||
addi _scr,_mbase,xVSCR-12
|
||||
lvx v0,0,_scr
|
||||
mtvscr v0
|
||||
addi _scr,_mbase,xVEC_BASE
|
||||
mFORLOOP([i],0,31,[
|
||||
lvx vPREFIX[]i,0,_scr
|
||||
addi _scr,_scr,16
|
||||
])
|
||||
lwz _scr,xVRSAVE(_mbase)
|
||||
mtspr S_VRSAVE,_scr
|
||||
])
|
||||
|
||||
/************************************************************************/
|
||||
/* Instructions */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __darwin__
|
||||
MACRO(mtsprg0, [reg], [mtspr SPRG0,_reg] )
|
||||
MACRO(mtsprg1, [reg], [mtspr SPRG1,_reg] )
|
||||
MACRO(mtsprg2, [reg], [mtspr SPRG2,_reg] )
|
||||
MACRO(mtsprg3, [reg], [mtspr SPRG3,_reg] )
|
||||
MACRO(mfsprg0, [reg], [mfspr _reg,SPRG0] )
|
||||
MACRO(mfsprg1, [reg], [mfspr _reg,SPRG1] )
|
||||
MACRO(mfsprg2, [reg], [mfspr _reg,SPRG2] )
|
||||
MACRO(mfsprg3, [reg], [mfspr _reg,SPRG3] )
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
/* Register names */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __darwin__
|
||||
/* These symbols are not defined under Darwin */
|
||||
#define cr0 0
|
||||
#define cr1 1
|
||||
#define cr2 2
|
||||
#define cr3 3
|
||||
#define cr4 4
|
||||
#define cr5 5
|
||||
#define cr6 6
|
||||
#define cr7 7
|
||||
#define cr8 8
|
||||
#define lt 0 /* Less than */
|
||||
#define gt 1 /* Greater than */
|
||||
#define eq 2 /* Equal */
|
||||
#define so 3 /* Summary Overflow */
|
||||
#define un 3 /* Unordered (after floating point) */
|
||||
#endif
|
||||
|
||||
/* FPU register names (to be used as macro arguments) */
|
||||
#define FR0 0
|
||||
#define FR1 1
|
||||
#define FR2 2
|
||||
#define FR3 3
|
||||
#define FR4 4
|
||||
#define FR5 5
|
||||
#define FR6 6
|
||||
#define FR7 7
|
||||
#define FR8 8
|
||||
#define FR9 9
|
||||
#define FR10 10
|
||||
#define FR11 11
|
||||
#define FR12 12
|
||||
#define FR13 13
|
||||
#define FR14 14
|
||||
#define FR15 15
|
||||
#define FR16 16
|
||||
#define FR17 17
|
||||
#define FR18 18
|
||||
#define FR19 19
|
||||
#define FR20 20
|
||||
#define FR21 21
|
||||
#define FR22 22
|
||||
#define FR23 23
|
||||
#define FR24 24
|
||||
#define FR25 25
|
||||
#define FR26 26
|
||||
#define FR27 27
|
||||
#define FR28 28
|
||||
#define FR29 29
|
||||
#define FR30 30
|
||||
#define FR31 31
|
||||
|
||||
/* GPR register names (to be used as macro arguments) */
|
||||
#define R0 0
|
||||
#define R1 1
|
||||
#define R2 2
|
||||
#define R3 3
|
||||
#define R4 4
|
||||
#define R5 5
|
||||
#define R6 6
|
||||
#define R7 7
|
||||
#define R8 8
|
||||
#define R9 9
|
||||
#define R10 10
|
||||
#define R11 11
|
||||
#define R12 12
|
||||
#define R13 13
|
||||
#define R14 14
|
||||
#define R15 15
|
||||
#define R16 16
|
||||
#define R17 17
|
||||
#define R18 18
|
||||
#define R19 19
|
||||
#define R20 20
|
||||
#define R21 21
|
||||
#define R22 22
|
||||
#define R23 23
|
||||
#define R24 24
|
||||
#define R25 25
|
||||
#define R26 26
|
||||
#define R27 27
|
||||
#define R28 28
|
||||
#define R29 29
|
||||
#define R30 30
|
||||
#define R31 31
|
||||
|
||||
#ifndef __darwin__
|
||||
|
||||
/* GPR register names, rN -> N, frN -> N, vN -> N */
|
||||
mFORLOOP([i],0,31,[define(r[]i,[]i)])
|
||||
mFORLOOP([i],0,31,[define(fr[]i,[]i)])
|
||||
mFORLOOP([i],0,31,[define(v[]i,[]i)])
|
||||
|
||||
#endif /* __darwin__ */
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* useful macros */
|
||||
/************************************************************************/
|
||||
|
||||
MACRO(ori_, [reg1, reg2, value], [
|
||||
.if (_value & 0xffff)
|
||||
ori _reg1, _reg2, (_value) & 0xffff
|
||||
.endif
|
||||
.if (_value & ~0xffff)
|
||||
oris _reg1, _reg2, (_value) >> 16
|
||||
.endif
|
||||
])
|
||||
|
||||
/************************************************************************/
|
||||
/* MISC */
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef __linux__
|
||||
#define GLOBL( name ) .globl name ; name
|
||||
#define EXTERN( name ) name
|
||||
#else
|
||||
/* an underscore is needed on Darwin */
|
||||
#define GLOBL( name ) .globl _##name ; name: ; _##name
|
||||
#define EXTERN( name ) _##name
|
||||
#endif
|
||||
|
||||
#define BIT(n) (1<<(31-(n)))
|
||||
|
||||
#endif /* _H_ASMDEFS */
|
||||
|
||||
5
include/ppc/elf.h
Normal file
5
include/ppc/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_PPC)
|
||||
typedef Elf32_Ehdr Elf_ehdr;
|
||||
typedef Elf32_Phdr Elf_phdr;
|
||||
165
include/ppc/io.h
Normal file
165
include/ppc/io.h
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
extern unsigned long virt_offset;
|
||||
|
||||
#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset))
|
||||
#define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
|
||||
#ifndef _IO_BASE
|
||||
#define _IO_BASE 0x80000000
|
||||
#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__("lbz%U1%X1 %0,%1; eieio":"=r"(ret):"m"(*addr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void out_8(volatile unsigned char *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("stb%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
|
||||
}
|
||||
|
||||
static inline int in_le16(volatile unsigned short *addr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
__asm__ __volatile__("lhbrx %0,0,%1; eieio":"=r"(ret):
|
||||
"r"(addr), "m"(*addr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int in_be16(volatile unsigned short *addr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
__asm__ __volatile__("lhz%U1%X1 %0,%1; eieio":"=r"(ret):"m"(*addr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void out_le16(volatile unsigned short *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("sthbrx %1,0,%2; eieio":"=m"(*addr):"r"(val),
|
||||
"r"(addr));
|
||||
}
|
||||
|
||||
static inline void out_be16(volatile unsigned short *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("sth%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
|
||||
}
|
||||
|
||||
static inline unsigned in_le32(volatile unsigned *addr)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
__asm__ __volatile__("lwbrx %0,0,%1; eieio":"=r"(ret):
|
||||
"r"(addr), "m"(*addr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline unsigned in_be32(volatile unsigned *addr)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
__asm__ __volatile__("lwz%U1%X1 %0,%1; eieio":"=r"(ret):"m"(*addr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void out_le32(volatile unsigned *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("stwbrx %1,0,%2; eieio":"=m"(*addr):"r"(val),
|
||||
"r"(addr));
|
||||
}
|
||||
|
||||
static inline void out_be32(volatile unsigned *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__("stw%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
|
||||
}
|
||||
|
||||
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 */
|
||||
84
include/ppc/pci.h
Normal file
84
include/ppc/pci.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef PPC_PCI_H
|
||||
#define PPC_PCI_H
|
||||
|
||||
#include "asm/io.h"
|
||||
|
||||
/* Sandpoint example */
|
||||
#define ISA_IO_BASE 0x80000000
|
||||
#define ISA_MEM_BASE 0xc0000000
|
||||
#define PCIC0_CFGADDR 0xfec00cf8
|
||||
#define PCIC0_CFGDATA 0xfee00cfc
|
||||
#ifndef _IO_BASE
|
||||
#define _IO_BASE ISA_IO_BASE
|
||||
#endif
|
||||
|
||||
#if !(PCI_CONFIG_1 || PCI_CONFIG_2)
|
||||
#define PCI_CONFIG_1 1 /* default */
|
||||
#endif
|
||||
|
||||
#ifdef PCI_CONFIG_1
|
||||
|
||||
/* PCI Configuration Mechanism #1 */
|
||||
|
||||
/* Have pci_addr in the same format as the values written to PCIC0_CFGADDR
|
||||
* so register accesses can be made easy. */
|
||||
#define PCI_ADDR(bus, dev, fn) \
|
||||
((pci_addr) (0x80000000u \
|
||||
| (uint32_t) (bus) << 16 \
|
||||
| (uint32_t) (dev) << 11 \
|
||||
| (uint32_t) (fn) << 8))
|
||||
|
||||
#define PCI_BUS(pcidev) ((uint8_t) ((pcidev) >> 16))
|
||||
#define PCI_DEV(pcidev) ((uint8_t) ((pcidev) >> 11) & 0x1f)
|
||||
#define PCI_FN(pcidev) ((uint8_t) ((pcidev) >> 8) & 7)
|
||||
|
||||
static inline uint8_t pci_config_read8(pci_addr dev, uint8_t reg)
|
||||
{
|
||||
uint8_t res;
|
||||
|
||||
out_le32((unsigned *)PCIC0_CFGADDR, (dev | (reg & ~3)));
|
||||
res = in_8((unsigned char *)PCIC0_CFGDATA + (reg & 3));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline uint16_t pci_config_read16(pci_addr dev, uint8_t reg)
|
||||
{
|
||||
uint16_t res;
|
||||
|
||||
out_le32((unsigned *)PCIC0_CFGADDR, (dev | (reg & ~3)));
|
||||
res = in_le16((unsigned char *)PCIC0_CFGDATA + (reg & 2));
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline uint32_t pci_config_read32(pci_addr dev, uint8_t reg)
|
||||
{
|
||||
uint32_t res;
|
||||
|
||||
out_le32((unsigned *)PCIC0_CFGADDR, (dev | (reg & ~3)));
|
||||
res = in_le32((unsigned char *)PCIC0_CFGDATA);
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline void pci_config_write8(pci_addr dev, uint8_t reg, uint8_t val)
|
||||
{
|
||||
outl(dev | (reg & ~3), 0xcf8);
|
||||
outb(val, 0xcfc | (reg & 3));
|
||||
}
|
||||
|
||||
static inline void pci_config_write16(pci_addr dev, uint8_t reg, uint16_t val)
|
||||
{
|
||||
outl(dev | (reg & ~3), 0xcf8);
|
||||
outw(val, 0xcfc | (reg & 2));
|
||||
}
|
||||
|
||||
static inline void pci_config_write32(pci_addr dev, uint8_t reg, uint32_t val)
|
||||
{
|
||||
outl(dev | reg, 0xcf8);
|
||||
outl(val, 0xcfc);
|
||||
}
|
||||
|
||||
#else /* !PCI_CONFIG_1 */
|
||||
#error PCI Configuration Mechanism is not specified or implemented
|
||||
#endif
|
||||
|
||||
#endif /* PPC_PCI_H */
|
||||
404
include/ppc/processor.h
Normal file
404
include/ppc/processor.h
Normal file
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* Creation Date: <2000/10/29 01:43:29 samuel>
|
||||
* Time-stamp: <2003/07/27 22:37:49 samuel>
|
||||
*
|
||||
* <processor.h>
|
||||
*
|
||||
* Extract from <asm/processor.h>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _H_PROCESSOR
|
||||
#define _H_PROCESSOR
|
||||
|
||||
|
||||
#define PTE0_VSID(s) (((s)>>7) & 0xffffff)
|
||||
#define PTE0_V BIT(0)
|
||||
#define PTE0_H BIT(25)
|
||||
#define PTE0_API 0x3f
|
||||
|
||||
#define PTE1_R BIT(23)
|
||||
#define PTE1_C BIT(24)
|
||||
#define PTE1_W BIT(25)
|
||||
#define PTE1_I BIT(26)
|
||||
#define PTE1_M BIT(27)
|
||||
#define PTE1_G BIT(28)
|
||||
#define PTE1_WIMG (PTE1_W | PTE1_I | PTE1_M | PTE1_G)
|
||||
#define PTE1_PP 0x3
|
||||
#define PTE1_RPN (~0xfffUL)
|
||||
|
||||
#define VSID_Ks BIT(1)
|
||||
#define VSID_Kp BIT(2)
|
||||
#define VSID_N BIT(3)
|
||||
|
||||
|
||||
|
||||
#ifndef MSR_VEC
|
||||
|
||||
#define MSR_VEC (1<<25) /* 6: Enable AltiVec */
|
||||
#define MSR_POW (1<<18) /* 13: Enable Power Management */
|
||||
#define MSR_TGPR (1<<17) /* 14: TLB Update registers in use */
|
||||
#define MSR_ILE (1<<16) /* 15: Interrupt Little Endian */
|
||||
#define MSR_EE (1<<15) /* 16: External Interrupt Enable */
|
||||
#define MSR_PR (1<<14) /* 17: Privilege Level */
|
||||
#define MSR_FP (1<<13) /* 18: Floating Point enable */
|
||||
#define MSR_ME (1<<12) /* 19: Machine Check Enable */
|
||||
#define MSR_FE0 (1<<11) /* 20: Floating Exception mode 0 */
|
||||
#define MSR_SE (1<<10) /* 21: Single Step */
|
||||
#define MSR_BE (1<<9) /* 22: Branch Trace */
|
||||
#define MSR_FE1 (1<<8) /* 23: Floating Exception mode 1 */
|
||||
#define MSR_IP (1<<6) /* 25: Exception prefix 0x000/0xFFF */
|
||||
#define MSR_IR (1<<5) /* 26: Instruction Relocate */
|
||||
#define MSR_DR (1<<4) /* 27: Data Relocate */
|
||||
#define MSR_PE (1<<2) /* 29: Performance Monitor Flag */
|
||||
#define MSR_RI (1<<1) /* 30: Recoverable Exception */
|
||||
#define MSR_LE (1<<0) /* 31: Little Endian */
|
||||
|
||||
#endif /* MSR_VEC */
|
||||
|
||||
#ifndef S_SPRG0
|
||||
|
||||
#define NUM_SPRS 1024
|
||||
//#define S_XER 1
|
||||
#define S_RTCU_R 4 /* 601 RTC Upper/Lower (Reading) */
|
||||
#define S_RTCL_R 5
|
||||
//#define S_LR 8
|
||||
//#define S_CTR 9
|
||||
#define S_DSISR 18 /* Source Instruction Service Register */
|
||||
#define S_DAR 19 /* Data Address Register */
|
||||
#define S_RTCU_W 20 /* 601 RTC Upper/Lower (Writing) */
|
||||
#define S_RTCL_W 21
|
||||
#define S_DEC 22 /* Decrementer Register */
|
||||
#define S_SDR1 25 /* Table Search Description Register */
|
||||
#define S_SRR0 26 /* Save and Restore Register 0 */
|
||||
#define S_SRR1 27 /* Save and Restore Register 1 */
|
||||
#define S_VRSAVE 256 /* (AltiVec) Vector Register Save Register */
|
||||
#define S_TBRL 268 /* Time base Upper/Lower (Reading) */
|
||||
#define S_TBRU 269
|
||||
#define S_SPRG0 272 /* SPR General 0-3 */
|
||||
#define S_SPRG1 273
|
||||
#define S_SPRG2 274
|
||||
#define S_SPRG3 275
|
||||
#define S_SPRG4 276 /* SPR General 4-7 (7445/7455) */
|
||||
#define S_SPRG5 277
|
||||
#define S_SPRG6 278
|
||||
#define S_SPRG7 279
|
||||
#define S_EAR 282 /* External Access Register */
|
||||
#define S_TBWL 284 /* Time base Upper/Lower (Writing) */
|
||||
#define S_TBWU 285
|
||||
#define S_PVR 287 /* Processor Version Register */
|
||||
#define S_IBAT0U 528
|
||||
#define S_IBAT0L 529
|
||||
#define S_IBAT1U 530
|
||||
#define S_IBAT1L 531
|
||||
#define S_IBAT2U 532
|
||||
#define S_IBAT2L 533
|
||||
#define S_IBAT3U 534
|
||||
#define S_IBAT3L 535
|
||||
#define S_DBAT0U 536
|
||||
#define S_DBAT0L 537
|
||||
#define S_DBAT1U 538
|
||||
#define S_DBAT1L 539
|
||||
#define S_DBAT2U 540
|
||||
#define S_DBAT2L 541
|
||||
#define S_DBAT3U 542
|
||||
#define S_DBAT3L 543
|
||||
#define S_UMMCR2 928
|
||||
#define S_UPMC5 929 /* User Performance Monitor Counter Register */
|
||||
#define S_UPMC6 930
|
||||
#define S_UBAMR 935
|
||||
#define S_UMMCR0 936 /* User Monitor Mode Control Register */
|
||||
#define S_UPMC1 937
|
||||
#define S_UPMC2 938
|
||||
#define S_USIAR 939 /* User Sampled Instruction Address Register */
|
||||
#define S_UMMCR1 940
|
||||
#define S_UPMC3 941
|
||||
#define S_UPMC4 942 /* User Performance Monitor Counter Register 4 */
|
||||
#define S_USDAR 943 /* User Sampled Data Address Register */
|
||||
#define S_MMCR2 944 /* Monitor Mode Control Register */
|
||||
#define S_PMC5 945
|
||||
#define S_PMC6 946
|
||||
#define S_BAMR 951 /* Breakpoint Address Mask Register (74xx) */
|
||||
#define S_MMCR0 952 /* Monitor Mode Control Register 0 */
|
||||
#define S_PMC1 953 /* Performance Counter Register */
|
||||
#define S_PMC2 954
|
||||
#define S_SIAR 955 /* Sampled Instruction Address Register */
|
||||
#define S_MMCR1 956
|
||||
#define S_PMC3 957
|
||||
#define S_PMC4 958
|
||||
#define S_SDAR 959 /* Sampled Data Address Register */
|
||||
#define S_DMISS 976 /* 603 */
|
||||
#define S_DCMP 977 /* 603 */
|
||||
#define S_HASH1 978 /* 603 */
|
||||
#define S_HASH2 979 /* 603 */
|
||||
#define S_IMISS 980 /* 603 */
|
||||
#define S_TLBMISS 980 /* 7445/7455 */
|
||||
#define S_ICMP 981 /* 603 */
|
||||
#define S_PTEHI 981 /* 7445/7455 */
|
||||
#define S_RPA 982 /* 603 */
|
||||
#define S_PTELO 982 /* 7445/7455 */
|
||||
#define S_L3PM 983 /* L3 Private Memory Address Control Register */
|
||||
#define S_L3ITCR0 984 /* ??? */
|
||||
#define S_L3OHCR 1000 /* ??? */
|
||||
#define S_L3ITCR1 1001 /* ??? */
|
||||
#define S_L3ITCR2 1002 /* ??? */
|
||||
#define S_L3ITCR3 1003 /* ??? */
|
||||
#define S_HID0 1008 /* Hardware Implementation Registers */
|
||||
#define S_HID1 1009
|
||||
#define S_HID2 1010
|
||||
#define S_IABR S_HID2 /* HID2 - Instruction Address Breakpoint Register */
|
||||
#define S_ICTRL 1011 /* HID3 - Instruction Cache & Interrupt control reg */
|
||||
#define S_HID4 1012 /* HID4 - Instruction Address Compare 1 (?) */
|
||||
#define S_HID5 1013
|
||||
#define S_DABR S_HID5 /* HID5 - Data Address Breakpoint */
|
||||
#define S_MSSCR0 1014 /* HID6 - Memory Subsystem Control Register 0 */
|
||||
#define S_MSSCR1 1015 /* HID7 - Memory Subsystem Control Register 1 */
|
||||
#define S_LDSTCR 1016 /* HID8 - Load/Store Control Register */
|
||||
#define S_L2CR 1017 /* HID9 - Level 2 Cache Control Regsiter */
|
||||
#define S_L3CR 1018 /* HID10 - Level 3 Cache Control Regsiter (7450) */
|
||||
#define S_HID11 1019
|
||||
#define S_ICTC S_HID11 /* HID11 - Instruction Cache Throttling Control Reg */
|
||||
#define S_ICCR S_HID11 /* Instruction Cache Cacheability Reigster */
|
||||
#define S_THRM1 1020 /* HID12 - Thermal Management Register 1 */
|
||||
#define S_THRM2 1021 /* HID13 - Thermal Management Register 2 */
|
||||
#define S_THRM3 1022 /* HID14 - Thermal Management Register 3 */
|
||||
#define S_HID15 1023
|
||||
#define S_PIR S_HID15 /* HID15 - Processor Identification Register */
|
||||
|
||||
#endif /* S_SPRG0 */
|
||||
|
||||
/* the kernel might define these too... */
|
||||
#if !defined(__KERNEL__) || defined(__ASSEMBLY__)
|
||||
|
||||
/* Floating Point Status and Control Register (FPSCR) Fields */
|
||||
#define FPSCR_FX 0x80000000 /* FPU exception summary */
|
||||
#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */
|
||||
#define FPSCR_VX 0x20000000 /* Invalid operation summary */
|
||||
#define FPSCR_OX 0x10000000 /* Overflow exception summary */
|
||||
#define FPSCR_UX 0x08000000 /* Underflow exception summary */
|
||||
#define FPSCR_ZX 0x04000000 /* Zero-devide exception summary */
|
||||
#define FPSCR_XX 0x02000000 /* Inexact exception summary */
|
||||
#define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */
|
||||
#define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */
|
||||
#define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */
|
||||
#define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */
|
||||
#define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */
|
||||
#define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */
|
||||
#define FPSCR_FR 0x00040000 /* Fraction rounded */
|
||||
#define FPSCR_FI 0x00020000 /* Fraction inexact */
|
||||
#define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */
|
||||
#define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */
|
||||
#define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */
|
||||
#define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */
|
||||
#define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */
|
||||
#define FPSCR_VE 0x00000080 /* Invalid op exception enable */
|
||||
#define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */
|
||||
#define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */
|
||||
#define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */
|
||||
#define FPSCR_XE 0x00000008 /* FP inexact exception enable */
|
||||
#define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */
|
||||
#define FPSCR_RN 0x00000003 /* FPU rounding control */
|
||||
|
||||
/* SPR_HID0 */
|
||||
#define HID0_EMCP (1<<31) /* Enable Machine Check pin */
|
||||
#define HID0_EBA (1<<29) /* Enable Bus Address Parity */
|
||||
#define HID0_EBD (1<<28) /* Enable Bus Data Parity */
|
||||
#define HID0_SBCLK (1<<27)
|
||||
#define HID0_EICE (1<<26)
|
||||
#define HID0_ECLK (1<<25)
|
||||
#define HID0_PAR (1<<24)
|
||||
#define HID0_DOZE (1<<23)
|
||||
#define HID0_NAP (1<<22)
|
||||
#define HID0_SLEEP (1<<21)
|
||||
#define HID0_DPM (1<<20)
|
||||
#define HID0_NHR (1<<16) /* Not Hard Reset */
|
||||
#define HID0_ICE (1<<15) /* Instruction Cache Enable */
|
||||
#define HID0_DCE (1<<14) /* Data Cache Enable */
|
||||
#define HID0_ILOCK (1<<13) /* Instruction Cache Lock */
|
||||
#define HID0_DLOCK (1<<12) /* Data Cache Lock */
|
||||
#define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */
|
||||
#define HID0_DCFI (1<<10) /* Data Cache Flash Invalidate */
|
||||
#define HID0_SPD (1<<9) /* Speculative disable */
|
||||
#define HID0_SGE (1<<7) /* Store Gathering Enable */
|
||||
#define HID0_SIED (1<<7) /* Serial Instr. Execution [Disable] */
|
||||
#define HID0_BTIC (1<<5) /* Branch Target Instruction Cache Enable */
|
||||
#define HID0_ABE (1<<3) /* Address Broadcast Enable */
|
||||
#define HID0_BHT (1<<2) /* Branch History Table Enable */
|
||||
#define HID0_BTCD (1<<1) /* Branch target cache disable */
|
||||
|
||||
#define L2CR_L2E BIT(0) /* L2 enable */
|
||||
#define L2CR_L2PE BIT(1) /* L2 data parity generation and checking */
|
||||
#define L2CR_L2SIZ_512K BIT(2)
|
||||
#define L2CR_L2SIZ_256K BIT(3)
|
||||
#define L2CR_L2SIZ_1MB (BIT(2)|BIT(3))
|
||||
#define L2CR_L2CLK_1 BIT(6) /* L2 clock ration */
|
||||
#define L2CR_L2CLK_15 (BIT(6)*2)
|
||||
#define L2CR_L2CLK_2 (BIT(6)*4)
|
||||
#define L2CR_L2CLK_25 (BIT(6)*5)
|
||||
#define L2CR_L2CLK_3 (BIT(6)*6)
|
||||
#define L2CR_L2RAM_FT 0 /* flow-through (reg-buf) synchronous SRAM */
|
||||
#define L2CR_L2RAM_PB BIT(7) /* Piplined (reg-reg) synchronous burst SRAM */
|
||||
#define L2CR_L2RAM_PLW (BIT(7)|BIT(8)) /* Piplined (reg-reg) synchronous late-write */
|
||||
#define L2CR_L2DO BIT(9) /* L2 data-only */
|
||||
#define L2CR_L2I BIT(10) /* L2 global invalidate */
|
||||
#define L2CR_L2CTL BIT(11) /* L2 RAM control (ZZ enable, low-power mode) */
|
||||
#define L2CR_L2WT BIT(12) /* L2 write-through */
|
||||
#define L2CR_L2TS BIT(13) /* L2 test support */
|
||||
#define L2CR_L2OH_05 0 /* L2 output hold 0.5 nS */
|
||||
#define L2CR_L2OH_10 BIT(15) /* L2 output hold 1.0 nS */
|
||||
#define L2CR_L2SL BIT(16) /* L2 DLL slow (use if bus freq < 150 MHz) */
|
||||
#define L2CR_L2DF BIT(17) /* L2 differential clock */
|
||||
#define L2CR_L2BYP BIT(18) /* L2 DLL bypass */
|
||||
#define L2CR_L2IP BIT(31) /* L2 global invalidate in progress */
|
||||
|
||||
/* SPR_THRM1 */
|
||||
#define THRM1_TIN (1 << 31)
|
||||
#define THRM1_TIV (1 << 30)
|
||||
#define THRM1_THRES(x) ((x&0x7f)<<23)
|
||||
#define THRM3_SITV(x) ((x&0x3fff)<<1)
|
||||
#define THRM1_TID (1<<2)
|
||||
#define THRM1_TIE (1<<1)
|
||||
#define THRM1_V (1<<0)
|
||||
|
||||
/* SPR_THRM3 */
|
||||
#define THRM3_E (1<<0)
|
||||
|
||||
/* Processor Version Numbers */
|
||||
|
||||
#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
|
||||
#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
|
||||
|
||||
#define PVR_403GA 0x00200000
|
||||
#define PVR_403GB 0x00200100
|
||||
#define PVR_403GC 0x00200200
|
||||
#define PVR_403GCX 0x00201400
|
||||
#define PVR_405GP 0x40110000
|
||||
#define PVR_601 0x00010000
|
||||
#define PVR_602 0x00050000
|
||||
#define PVR_603 0x00030000
|
||||
#define PVR_603e 0x00060000
|
||||
#define PVR_603ev 0x00070000
|
||||
#define PVR_603r 0x00071000
|
||||
#define PVR_604 0x00040000
|
||||
#define PVR_604e 0x00090000
|
||||
#define PVR_604r 0x000A0000
|
||||
#define PVR_620 0x00140000
|
||||
#define PVR_740 0x00080000
|
||||
#define PVR_750 PVR_740
|
||||
#define PVR_740P 0x10080000
|
||||
#define PVR_750P PVR_740P
|
||||
#define PVR_821 0x00500000
|
||||
#define PVR_823 PVR_821
|
||||
#define PVR_850 PVR_821
|
||||
#define PVR_860 PVR_821
|
||||
#define PVR_7400 0x000C0000
|
||||
#define PVR_8240 0x00810100
|
||||
#define PVR_8260 PVR_8240
|
||||
|
||||
/* Vector VSCR register */
|
||||
#define VSCR_NJ 0x10000
|
||||
#define VSCR_SAT 0x1
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
|
||||
#ifdef __ASSEMBLY__
|
||||
|
||||
#define CTR S_CTR /* Counter Register */
|
||||
#define DAR S_DAR /* Data Address Register */
|
||||
#define DABR S_DABR /* Data Address Breakpoint Register */
|
||||
#define DBAT0L S_DBAT0L /* Data BAT 0 Lower Register */
|
||||
#define DBAT0U S_DBAT0U /* Data BAT 0 Upper Register */
|
||||
#define DBAT1L S_DBAT1L /* Data BAT 1 Lower Register */
|
||||
#define DBAT1U S_DBAT1U /* Data BAT 1 Upper Register */
|
||||
#define DBAT2L S_DBAT2L /* Data BAT 2 Lower Register */
|
||||
#define DBAT2U S_DBAT2U /* Data BAT 2 Upper Register */
|
||||
#define DBAT3L S_DBAT3L /* Data BAT 3 Lower Register */
|
||||
#define DBAT3U S_DBAT3U /* Data BAT 3 Upper Register */
|
||||
#define DCMP S_DCMP /* Data TLB Compare Register */
|
||||
#define DEC S_DEC /* Decrement Register */
|
||||
#define DMISS S_DMISS /* Data TLB Miss Register */
|
||||
#define DSISR S_DSISR /* Data Storage Interrupt Status Register */
|
||||
#define EAR S_EAR /* External Address Register */
|
||||
#define HASH1 S_HASH1 /* Primary Hash Address Register */
|
||||
#define HASH2 S_HASH2 /* Secondary Hash Address Register */
|
||||
#define HID0 S_HID0 /* Hardware Implementation Register 0 */
|
||||
#define HID1 S_HID1 /* Hardware Implementation Register 1 */
|
||||
#define IABR S_IABR /* Instruction Address Breakpoint Register */
|
||||
#define IBAT0L S_IBAT0L /* Instruction BAT 0 Lower Register */
|
||||
#define IBAT0U S_IBAT0U /* Instruction BAT 0 Upper Register */
|
||||
#define IBAT1L S_IBAT1L /* Instruction BAT 1 Lower Register */
|
||||
#define IBAT1U S_IBAT1U /* Instruction BAT 1 Upper Register */
|
||||
#define IBAT2L S_IBAT2L /* Instruction BAT 2 Lower Register */
|
||||
#define IBAT2U S_IBAT2U /* Instruction BAT 2 Upper Register */
|
||||
#define IBAT3L S_IBAT3L /* Instruction BAT 3 Lower Register */
|
||||
#define IBAT3U S_IBAT3U /* Instruction BAT 3 Upper Register */
|
||||
#define ICMP S_ICMP /* Instruction TLB Compare Register */
|
||||
#define IMISS S_IMISS /* Instruction TLB Miss Register */
|
||||
#define IMMR S_IMMR /* PPC 860/821 Internal Memory Map Register */
|
||||
#define L2CR S_L2CR /* PPC 750 L2 control register */
|
||||
#define PVR S_PVR /* Processor Version */
|
||||
#define RPA S_RPA /* Required Physical Address Register */
|
||||
#define SDR1 S_SDR1 /* MMU hash base register */
|
||||
#define SPR0 S_SPRG0 /* Supervisor Private Registers */
|
||||
#define SPR1 S_SPRG1
|
||||
#define SPR2 S_SPRG2
|
||||
#define SPR3 S_SPRG3
|
||||
#define SPRG0 S_SPRG0
|
||||
#define SPRG1 S_SPRG1
|
||||
#define SPRG2 S_SPRG2
|
||||
#define SPRG3 S_SPRG3
|
||||
#define SRR0 S_SRR0 /* Save and Restore Register 0 */
|
||||
#define SRR1 S_SRR1 /* Save and Restore Register 1 */
|
||||
#define TBRL S_STBRL /* Time Base Read Lower Register */
|
||||
#define TBRU S_TBRU /* Time Base Read Upper Register */
|
||||
#define TBWL S_TBWL /* Time Base Write Lower Register */
|
||||
#define TBWU S_TBWU /* Time Base Write Upper Register */
|
||||
#define ICTC S_ICTC
|
||||
#define THRM1 S_THRM1 /* Thermal Management Register 1 */
|
||||
#define THRM2 S_THRM2 /* Thermal Management Register 2 */
|
||||
#define THRM3 S_THRM3 /* Thermal Management Register 3 */
|
||||
#define SIAR S_SIAR
|
||||
#define SDAR S_SDAR
|
||||
#define XER 1
|
||||
|
||||
#define SR0 0 /* Segment registers */
|
||||
#define SR1 1
|
||||
#define SR2 2
|
||||
#define SR3 3
|
||||
#define SR4 4
|
||||
#define SR5 5
|
||||
#define SR6 6
|
||||
#define SR7 7
|
||||
#define SR8 8
|
||||
#define SR9 9
|
||||
#define SR10 10
|
||||
#define SR11 11
|
||||
#define SR12 12
|
||||
#define SR13 13
|
||||
#define SR14 14
|
||||
#define SR15 15
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/* opcode macros */
|
||||
|
||||
#define OPCODE_PRIM(n) ( ((ulong)(n)) >> 26 )
|
||||
#define OPCODE_EXT(n) ( (((ulong)(n)) >> 1) & 0x3ff )
|
||||
#define OPCODE(op,op_ext) ( ((op)<<10) + op_ext )
|
||||
|
||||
#define B1(n) ( (((ulong)(n)) >> 21) & 0x1f )
|
||||
#define B2(n) ( (((ulong)(n)) >> 16) & 0x1f )
|
||||
#define B3(n) ( (((ulong)(n)) >> 11) & 0x1f )
|
||||
|
||||
#define BD(n) ((ulong)((n) & 0x7fff) + (((n) & 0x8000) ? (ulong)0xffff8000 : 0))
|
||||
|
||||
#define SPRNUM_FLIP( v ) ( (((v)>>5) & 0x1f) | (((v)<<5) & 0x3e0) )
|
||||
|
||||
#endif /* _H_PROCESSOR */
|
||||
|
||||
63
include/ppc/types.h
Normal file
63
include/ppc/types.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* 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"
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <stdint.h>
|
||||
#else
|
||||
/* Mac OS X */
|
||||
typedef char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned char u_int8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned short u_int16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned int u_int32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef unsigned long long u_int64_t;
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
34
include/sys_info.h
Normal file
34
include/sys_info.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef SYS_INFO_H
|
||||
#define SYS_INFO_H
|
||||
|
||||
/* Information collected from firmware/bootloader */
|
||||
|
||||
struct sys_info {
|
||||
/* Values passed by bootloader */
|
||||
unsigned long boot_type;
|
||||
unsigned long boot_data;
|
||||
unsigned long boot_arg;
|
||||
|
||||
char *firmware; /* "PCBIOS", "LinuxBIOS", etc. */
|
||||
char *command_line; /* command line given to us */
|
||||
|
||||
/* memory map */
|
||||
int n_memranges;
|
||||
struct memrange {
|
||||
unsigned long long base;
|
||||
unsigned long long size;
|
||||
} *memrange;
|
||||
unsigned long *dict_start;
|
||||
unsigned long *dict_end;
|
||||
};
|
||||
|
||||
void collect_sys_info(struct sys_info *info);
|
||||
void collect_elfboot_info(struct sys_info *info);
|
||||
void collect_linuxbios_info(struct sys_info *info);
|
||||
|
||||
/* Our name and version. I want to see single instance of these in the image */
|
||||
extern const char *program_name, *program_version;
|
||||
|
||||
#define LOADER_NOT_SUPPORT 0xbadf11e
|
||||
|
||||
#endif /* SYS_INFO_H */
|
||||
25
include/unix/plugin_pci.h
Normal file
25
include/unix/plugin_pci.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* tag: openbios pci plugin headers
|
||||
*
|
||||
* Copyright (C) 2003 Stefan Reinauer
|
||||
*
|
||||
* See the file "COPYING" for further information about
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
|
||||
#ifndef __PLUGINS_PCI_H
|
||||
#define __PLUGINS_PCI_H
|
||||
|
||||
typedef struct pci_dev pci_dev_t;
|
||||
|
||||
struct pci_dev {
|
||||
unsigned bus;
|
||||
unsigned dev;
|
||||
unsigned fn;
|
||||
|
||||
u8 *config;
|
||||
pci_dev_t *next;
|
||||
};
|
||||
|
||||
int pci_register_device(unsigned bus, unsigned dev, unsigned fn, u8 *config);
|
||||
|
||||
#endif
|
||||
31
include/unix/plugins.h
Normal file
31
include/unix/plugins.h
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#ifndef __PLUGINS_H
|
||||
#define __PLUGINS_H
|
||||
|
||||
#include "asm/types.h"
|
||||
|
||||
struct io_ops {
|
||||
u8 (*inb)(u32 reg);
|
||||
u16 (*inw)(u32 reg);
|
||||
u32 (*inl)(u32 reg);
|
||||
void (*outb)(u32 reg, u8 val);
|
||||
void (*outw)(u32 reg, u16 val);
|
||||
void (*outl)(u32 reg, u32 val);
|
||||
};
|
||||
typedef struct io_ops io_ops_t;
|
||||
|
||||
extern unsigned char *plugindir;
|
||||
|
||||
#define PLUGIN_DEPENDENCIES(x...) const char *plugin_deps[]={ x, NULL };
|
||||
#define PLUGIN_AUTHOR(author) const char *plugin_author=author;
|
||||
#define PLUGIN_LICENSE(license) const char *plugin_license=license;
|
||||
#define PLUGIN_DESCRIPTION(desc) const char *plugin_description=desc;
|
||||
|
||||
int register_iorange(const char *name, io_ops_t *ops,
|
||||
unsigned int rstart, unsigned int rend);
|
||||
io_ops_t *find_iorange(u32 reg);
|
||||
|
||||
int load_plugin(const char *plugin_name);
|
||||
int is_loaded(const char *plugin_name);
|
||||
|
||||
#endif
|
||||
5
include/x86/elf.h
Normal file
5
include/x86/elf.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#define ARCH_ELF_CLASS ELFCLASS32
|
||||
#define ARCH_ELF_DATA ELFDATA2LSB
|
||||
#define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486)
|
||||
typedef Elf32_Ehdr Elf_ehdr;
|
||||
typedef Elf32_Phdr Elf_phdr;
|
||||
70
include/x86/io.h
Normal file
70
include/x86/io.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
extern unsigned long virt_offset;
|
||||
|
||||
#define phys_to_virt(phys) ((void *) ((unsigned long) (phys) - virt_offset))
|
||||
#define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
|
||||
|
||||
#define __SLOW_DOWN_IO "outb %%al,$0x80;"
|
||||
static inline void slow_down_io(void)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
__SLOW_DOWN_IO
|
||||
#ifdef REALLY_SLOW_IO
|
||||
__SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO
|
||||
#endif
|
||||
: : );
|
||||
}
|
||||
|
||||
#define BUILDIO(bwl,bw,type) \
|
||||
static inline void out##bwl(unsigned type value, int port) { \
|
||||
__asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \
|
||||
} \
|
||||
static inline unsigned type in##bwl(int port) { \
|
||||
unsigned type value; \
|
||||
__asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \
|
||||
return value; \
|
||||
} \
|
||||
static inline void out##bwl##_p(unsigned type value, int port) { \
|
||||
out##bwl(value, port); \
|
||||
slow_down_io(); \
|
||||
} \
|
||||
static inline unsigned type in##bwl##_p(int port) { \
|
||||
unsigned type value = in##bwl(port); \
|
||||
slow_down_io(); \
|
||||
return value; \
|
||||
} \
|
||||
static inline void outs##bwl(int port, const void *addr, unsigned long count) { \
|
||||
__asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); \
|
||||
} \
|
||||
static inline void ins##bwl(int port, void *addr, unsigned long count) { \
|
||||
__asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); \
|
||||
}
|
||||
|
||||
#ifndef BOOTSTRAP
|
||||
BUILDIO(b,b,char)
|
||||
BUILDIO(w,w,short)
|
||||
BUILDIO(l,,int)
|
||||
#else
|
||||
#ifdef FCOMPILER
|
||||
#define inb(reg) ((u8)0xff)
|
||||
#define inw(reg) ((u16)0xffff)
|
||||
#define inl(reg) ((u32)0xffffffff)
|
||||
// #define insw( u32 reg, void *addr, unsigned long count );
|
||||
#define outb(reg, val) // nothing
|
||||
#define outw(reg, val) // nothing
|
||||
#define outl(reg, val) // nothing
|
||||
// #define outsw( u32 reg, const void *addr, unsigned long count);
|
||||
#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
|
||||
66
include/x86/pci.h
Normal file
66
include/x86/pci.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef i386_PCI_H
|
||||
#define i386_PCI_H
|
||||
|
||||
#include "asm/io.h"
|
||||
|
||||
#if !(PCI_CONFIG_1 || PCI_CONFIG_2)
|
||||
#define PCI_CONFIG_1 1 /* default */
|
||||
#endif
|
||||
|
||||
#ifdef PCI_CONFIG_1
|
||||
|
||||
/* PCI Configuration Mechanism #1 */
|
||||
|
||||
/* Have pci_addr in the same format as the values written to 0xcf8
|
||||
* so register accesses can be made easy. */
|
||||
#define PCI_ADDR(bus, dev, fn) \
|
||||
((pci_addr) (0x80000000u \
|
||||
| (uint32_t) (bus) << 16 \
|
||||
| (uint32_t) (dev) << 11 \
|
||||
| (uint32_t) (fn) << 8))
|
||||
|
||||
#define PCI_BUS(pcidev) ((uint8_t) ((pcidev) >> 16))
|
||||
#define PCI_DEV(pcidev) ((uint8_t) ((pcidev) >> 11) & 0x1f)
|
||||
#define PCI_FN(pcidev) ((uint8_t) ((pcidev) >> 8) & 7)
|
||||
|
||||
static inline uint8_t pci_config_read8(pci_addr dev, uint8_t reg)
|
||||
{
|
||||
outl(dev | (reg & ~3), 0xcf8);
|
||||
return inb(0xcfc | (reg & 3));
|
||||
}
|
||||
|
||||
static inline uint16_t pci_config_read16(pci_addr dev, uint8_t reg)
|
||||
{
|
||||
outl(dev | (reg & ~3), 0xcf8);
|
||||
return inw(0xcfc | (reg & 2));
|
||||
}
|
||||
|
||||
static inline uint32_t pci_config_read32(pci_addr dev, uint8_t reg)
|
||||
{
|
||||
outl(dev | reg, 0xcf8);
|
||||
return inl(0xcfc | reg);
|
||||
}
|
||||
|
||||
static inline void pci_config_write8(pci_addr dev, uint8_t reg, uint8_t val)
|
||||
{
|
||||
outl(dev | (reg & ~3), 0xcf8);
|
||||
outb(val, 0xcfc | (reg & 3));
|
||||
}
|
||||
|
||||
static inline void pci_config_write16(pci_addr dev, uint8_t reg, uint16_t val)
|
||||
{
|
||||
outl(dev | (reg & ~3), 0xcf8);
|
||||
outw(val, 0xcfc | (reg & 2));
|
||||
}
|
||||
|
||||
static inline void pci_config_write32(pci_addr dev, uint8_t reg, uint32_t val)
|
||||
{
|
||||
outl(dev | reg, 0xcf8);
|
||||
outl(val, 0xcfc);
|
||||
}
|
||||
|
||||
#else /* !PCI_CONFIG_1 */
|
||||
#error PCI Configuration Mechanism is not specified or implemented
|
||||
#endif
|
||||
|
||||
#endif /* i386_PCI_H */
|
||||
44
include/x86/types.h
Normal file
44
include/x86/types.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* tag: data types for forth engine
|
||||
*
|
||||
* This file is autogenerated by types.sh. Do not edit!
|
||||
*
|
||||
* Copyright (C) 2003-2005 Stefan Reinauer, Patrick Mauritz
|
||||
*
|
||||
* See the file "COPYING" for further information about
|
||||
* the copyright and warranty status of this work.
|
||||
*/
|
||||
|
||||
#ifndef __TYPES_H
|
||||
#define __TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* endianess */
|
||||
|
||||
#include "autoconf.h"
|
||||
|
||||
/* 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 char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user