Forgot to update OpenXDK includes. Sorry about that!
This commit is contained in:
parent
bcc8260f17
commit
9d10c637af
|
@ -0,0 +1,143 @@
|
||||||
|
#undef WIN32
|
||||||
|
/* ANSI and traditional C compatability macros
|
||||||
|
Copyright 1991, 1992 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
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; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
/* ANSI and traditional C compatibility macros
|
||||||
|
|
||||||
|
ANSI C is assumed if __STDC__ is #defined.
|
||||||
|
|
||||||
|
Macro ANSI C definition Traditional C definition
|
||||||
|
----- ---- - ---------- ----------- - ----------
|
||||||
|
PTR `void *' `char *'
|
||||||
|
LONG_DOUBLE `long double' `double'
|
||||||
|
VOLATILE `volatile' `'
|
||||||
|
SIGNED `signed' `'
|
||||||
|
PTRCONST `void *const' `char *'
|
||||||
|
ANSI_PROTOTYPES 1 not defined
|
||||||
|
|
||||||
|
CONST is also defined, but is obsolete. Just use const.
|
||||||
|
|
||||||
|
DEFUN (name, arglist, args)
|
||||||
|
|
||||||
|
Defines function NAME.
|
||||||
|
|
||||||
|
ARGLIST lists the arguments, separated by commas and enclosed in
|
||||||
|
parentheses. ARGLIST becomes the argument list in traditional C.
|
||||||
|
|
||||||
|
ARGS list the arguments with their types. It becomes a prototype in
|
||||||
|
ANSI C, and the type declarations in traditional C. Arguments should
|
||||||
|
be separated with `AND'. For functions with a variable number of
|
||||||
|
arguments, the last thing listed should be `DOTS'.
|
||||||
|
|
||||||
|
DEFUN_VOID (name)
|
||||||
|
|
||||||
|
Defines a function NAME, which takes no arguments.
|
||||||
|
|
||||||
|
obsolete -- EXFUN (name, (prototype)) -- obsolete.
|
||||||
|
|
||||||
|
Replaced by PARAMS. Do not use; will disappear someday soon.
|
||||||
|
Was used in external function declarations.
|
||||||
|
In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
|
||||||
|
parentheses). In traditional C it is `NAME()'.
|
||||||
|
For a function that takes no arguments, PROTOTYPE should be `(void)'.
|
||||||
|
|
||||||
|
PARAMS ((args))
|
||||||
|
|
||||||
|
We could use the EXFUN macro to handle prototype declarations, but
|
||||||
|
the name is misleading and the result is ugly. So we just define a
|
||||||
|
simple macro to handle the parameter lists, as in:
|
||||||
|
|
||||||
|
static int foo PARAMS ((int, char));
|
||||||
|
|
||||||
|
This produces: `static int foo();' or `static int foo (int, char);'
|
||||||
|
|
||||||
|
EXFUN would have done it like this:
|
||||||
|
|
||||||
|
static int EXFUN (foo, (int, char));
|
||||||
|
|
||||||
|
but the function is not external...and it's hard to visually parse
|
||||||
|
the function name out of the mess. EXFUN should be considered
|
||||||
|
obsolete; new code should be written to use PARAMS.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
extern int printf PARAMS ((CONST char *format DOTS));
|
||||||
|
int DEFUN(fprintf, (stream, format),
|
||||||
|
FILE *stream AND CONST char *format DOTS) { ... }
|
||||||
|
void DEFUN_VOID(abort) { ... }
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ANSIDECL_H
|
||||||
|
|
||||||
|
#define _ANSIDECL_H 1
|
||||||
|
|
||||||
|
#include <defs.h>
|
||||||
|
|
||||||
|
/* Every source file includes this file,
|
||||||
|
so they will all get the switch for lint. */
|
||||||
|
/* LINTLIBRARY */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32)
|
||||||
|
/* All known AIX compilers implement these things (but don't always
|
||||||
|
define __STDC__). The RISC/OS MIPS compiler defines these things
|
||||||
|
in SVR4 mode, but does not define __STDC__. */
|
||||||
|
|
||||||
|
#define PTR void *
|
||||||
|
#define PTRCONST void *CONST
|
||||||
|
#define LONG_DOUBLE long double
|
||||||
|
|
||||||
|
#define AND ,
|
||||||
|
#define NOARGS void
|
||||||
|
#define CONST const
|
||||||
|
#define VOLATILE volatile
|
||||||
|
#define SIGNED signed
|
||||||
|
#define DOTS , ...
|
||||||
|
|
||||||
|
#define EXFUN(name, proto) name proto
|
||||||
|
#define DEFUN(name, arglist, args) name(args)
|
||||||
|
#define DEFUN_VOID(name) name(void)
|
||||||
|
|
||||||
|
#define PROTO(type, name, arglist) type name arglist
|
||||||
|
#define PARAMS(paramlist) paramlist
|
||||||
|
#define ANSI_PROTOTYPES 1
|
||||||
|
|
||||||
|
#else /* Not ANSI C. */
|
||||||
|
|
||||||
|
#define PTR char *
|
||||||
|
#define PTRCONST PTR
|
||||||
|
#define LONG_DOUBLE double
|
||||||
|
|
||||||
|
#define AND ;
|
||||||
|
#define NOARGS
|
||||||
|
#define CONST
|
||||||
|
#ifndef const /* some systems define it in header files for non-ansi mode */
|
||||||
|
#define const
|
||||||
|
#endif
|
||||||
|
#define VOLATILE
|
||||||
|
#define SIGNED
|
||||||
|
#define DOTS
|
||||||
|
|
||||||
|
#define EXFUN(name, proto) name()
|
||||||
|
#define DEFUN(name, arglist, args) name arglist args;
|
||||||
|
#define DEFUN_VOID(name) name()
|
||||||
|
#define PROTO(type, name, arglist) type name ()
|
||||||
|
#define PARAMS(paramlist) ()
|
||||||
|
|
||||||
|
#endif /* ANSI C. */
|
||||||
|
|
||||||
|
#endif /* ansidecl.h */
|
|
@ -0,0 +1,74 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __STDIO_H__
|
||||||
|
#define __STDIO_H__
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
//int sprintf(char*, const char *format, ...);
|
||||||
|
int __cdecl sprintf(char *, const char *, ...);
|
||||||
|
|
||||||
|
//#include <tamtypes.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define _O_RDONLY (0x00000001)
|
||||||
|
#define _O_WRONLY (0x00000002)
|
||||||
|
#define _O_RDWR (0x00000003)
|
||||||
|
#define _O_NBLOCK (0x00000010)
|
||||||
|
#define _O_APPEND (0x00000100)
|
||||||
|
#define _O_CREAT (0x00000200)
|
||||||
|
#define _O_TRUNC (0x00000400)
|
||||||
|
#define _O_EXCL (0x00000800)
|
||||||
|
#define _O_TEMPORARY (0x00001000)
|
||||||
|
#define _O_TEXT (0x00004000)
|
||||||
|
#define _O_BINARY (0x00008000)
|
||||||
|
|
||||||
|
#define O_RDONLY _O_RDONLY
|
||||||
|
#define O_WRONLY _O_WRONLY
|
||||||
|
#define O_RDWR _O_RDWR
|
||||||
|
#define O_NBLOCK _O_NBLOCK
|
||||||
|
#define O_APPEND _O_APPEND
|
||||||
|
#define O_CREAT _O_CREAT
|
||||||
|
#define O_EXCL _O_EXCL
|
||||||
|
#define O_TRUNC _O_TRUNC
|
||||||
|
#define O_TEMPORARY _O_TEMPORARY
|
||||||
|
#define O_TEXT _O_TEXT
|
||||||
|
#define O_BINARY _O_BINARY
|
||||||
|
|
||||||
|
|
||||||
|
#define SEEK_SET 0
|
||||||
|
#define SEEK_CUR 1
|
||||||
|
#define SEEK_END 2
|
||||||
|
|
||||||
|
extern u32 LastErrorCode;
|
||||||
|
|
||||||
|
int _open( char *filename, int oflag, int permission );
|
||||||
|
int _read( int handle, void *buffer, unsigned int count );
|
||||||
|
int _write( int handle, void* buffer, unsigned int count );
|
||||||
|
int _close( int handle );
|
||||||
|
int _lseek( int handle, u32 offset, int base );
|
||||||
|
|
||||||
|
int nprintf(const char *format, ...);
|
||||||
|
int printf(const char *format, ...);
|
||||||
|
//int sprintf(char*, const char *format, ...);
|
||||||
|
*/
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif // __STDIO_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* This file should define __BYTE_ORDER as appropriate for the machine
|
||||||
|
in question. See string/endian.h for how to define it.
|
||||||
|
|
||||||
|
If only the stub bits/endian.h applies to a particular configuration,
|
||||||
|
bytesex.h is generated by running a program on the host machine.
|
||||||
|
So if cross-compiling to a machine with a different byte order,
|
||||||
|
the bits/endian.h file for that machine must exist. */
|
||||||
|
|
||||||
|
#ifndef _ENDIAN_H
|
||||||
|
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||||
|
//#error Machine byte order unknown.
|
|
@ -0,0 +1,131 @@
|
||||||
|
/* Copyright (C) 1991,1992,94-1999,2000,2001 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Never include this file directly; use <sys/types.h> instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BITS_TYPES_H
|
||||||
|
#define _BITS_TYPES_H 1
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* Convenience types. */
|
||||||
|
typedef unsigned char __u_char;
|
||||||
|
typedef unsigned short __u_short;
|
||||||
|
typedef unsigned int __u_int;
|
||||||
|
typedef unsigned long __u_long;
|
||||||
|
#ifdef __GNUC__
|
||||||
|
typedef unsigned long long int __u_quad_t;
|
||||||
|
typedef long long int __quad_t;
|
||||||
|
#else
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
long __val[2];
|
||||||
|
} __quad_t;
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__u_long __val[2];
|
||||||
|
} __u_quad_t;
|
||||||
|
#endif
|
||||||
|
typedef signed char __int8_t;
|
||||||
|
typedef unsigned char __uint8_t;
|
||||||
|
typedef signed short int __int16_t;
|
||||||
|
typedef unsigned short int __uint16_t;
|
||||||
|
typedef signed int __int32_t;
|
||||||
|
typedef unsigned int __uint32_t;
|
||||||
|
#ifdef __GNUC__
|
||||||
|
typedef signed long long int __int64_t;
|
||||||
|
typedef unsigned long long int __uint64_t;
|
||||||
|
#endif
|
||||||
|
typedef __quad_t *__qaddr_t;
|
||||||
|
|
||||||
|
typedef int __dev_t; /* Type of device numbers. */
|
||||||
|
typedef unsigned int __uid_t; /* Type of user identifications. */
|
||||||
|
typedef unsigned int __gid_t; /* Type of group identifications. */
|
||||||
|
typedef unsigned int __ino_t; /* Type of file serial numbers. */
|
||||||
|
typedef __quad_t __ino64_t; /* Type of file serial numbers (LFS). */
|
||||||
|
typedef unsigned int __mode_t; /* Type of file attribute bitmasks. */
|
||||||
|
typedef unsigned short int __nlink_t; /* Type of file link counts. */
|
||||||
|
typedef long int __off_t; /* Type of file sizes and offsets. */
|
||||||
|
typedef __quad_t __loff_t; /* Type of file sizes and offsets. */
|
||||||
|
typedef __loff_t __off64_t; /* Type of file sizes and offsets (LFS). */
|
||||||
|
typedef int __pid_t; /* Type of process identifications. */
|
||||||
|
typedef int __ssize_t; /* Type of a byte count, or error. */
|
||||||
|
typedef __u_quad_t __fsid_t; /* Type of file system IDs. */
|
||||||
|
typedef long int __clock_t; /* Type of CPU usage counts. */
|
||||||
|
typedef long int __rlim_t; /* Type for resource measurement. */
|
||||||
|
typedef __quad_t __rlim64_t; /* Type for resource measurement (LFS). */
|
||||||
|
typedef unsigned int __id_t; /* General type for IDs. */
|
||||||
|
|
||||||
|
/* Everythin' else. */
|
||||||
|
typedef long int __daddr_t; /* The type of a disk address. */
|
||||||
|
typedef char *__caddr_t;
|
||||||
|
typedef long int __time_t;
|
||||||
|
typedef unsigned int __useconds_t;
|
||||||
|
typedef long int __suseconds_t;
|
||||||
|
typedef long int __swblk_t; /* Type of a swap block maybe? */
|
||||||
|
typedef long int __key_t; /* Type of an IPC key */
|
||||||
|
|
||||||
|
|
||||||
|
/* Clock ID used in clock and timer functions. */
|
||||||
|
typedef int __clockid_t;
|
||||||
|
|
||||||
|
/* Timer ID returned by `timer_create'. */
|
||||||
|
typedef int __timer_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* Number of descriptors that can fit in an `fd_set'. */
|
||||||
|
#define __FD_SETSIZE 256
|
||||||
|
|
||||||
|
|
||||||
|
/* XXX Used in `struct shmid_ds'. */
|
||||||
|
typedef unsigned short int __ipc_pid_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* Type to represent block size. */
|
||||||
|
typedef unsigned int __blksize_t;
|
||||||
|
|
||||||
|
/* Types from the Large File Support interface. */
|
||||||
|
|
||||||
|
/* Type to count number os disk blocks. */
|
||||||
|
typedef long int __blkcnt_t;
|
||||||
|
typedef __quad_t __blkcnt64_t;
|
||||||
|
|
||||||
|
/* Type to count file system blocks. */
|
||||||
|
typedef unsigned int __fsblkcnt_t;
|
||||||
|
typedef __u_quad_t __fsblkcnt64_t;
|
||||||
|
|
||||||
|
/* Type to count file system inodes. */
|
||||||
|
typedef unsigned long int __fsfilcnt_t;
|
||||||
|
typedef __u_quad_t __fsfilcnt64_t;
|
||||||
|
|
||||||
|
/* Used in XTI. */
|
||||||
|
typedef int __t_scalar_t;
|
||||||
|
typedef unsigned int __t_uscalar_t;
|
||||||
|
|
||||||
|
/* Duplicates info from stdint.h but this is used in unistd.h. */
|
||||||
|
typedef long int __intptr_t;
|
||||||
|
|
||||||
|
/* Duplicate info from sys/socket.h. */
|
||||||
|
typedef unsigned int __socklen_t;
|
||||||
|
|
||||||
|
#endif /* bits/types.h */
|
|
@ -0,0 +1,23 @@
|
||||||
|
// **************************************************************************
|
||||||
|
//
|
||||||
|
// CONIO.H : Standard Port IO routines
|
||||||
|
//
|
||||||
|
// **************************************************************************
|
||||||
|
#ifndef __CONIO_H__
|
||||||
|
#define __CONIO_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _outb( unsigned short port, unsigned char data );
|
||||||
|
void _outw( unsigned short port, unsigned short data );
|
||||||
|
void _outd( unsigned short port, unsigned int data );
|
||||||
|
unsigned char _inb( unsigned short port );
|
||||||
|
unsigned short _inw( unsigned short port );
|
||||||
|
unsigned int _ind( unsigned short port );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__CONIO_H__
|
|
@ -0,0 +1,278 @@
|
||||||
|
/* Copyright (C) 1991,92,93,95,96,97,98,99,2001 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ISO C99 Standard 7.4: Character handling <ctype.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CTYPE_H
|
||||||
|
#define _CTYPE_H 1
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
#include <bits/types.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
#ifndef _ISbit
|
||||||
|
/* These are all the characteristics of characters.
|
||||||
|
If there get to be more than 16 distinct characteristics,
|
||||||
|
many things must be changed that use `unsigned short int's.
|
||||||
|
|
||||||
|
The characteristics are stored always in network byte order (big
|
||||||
|
endian). We define the bit value interpretations here dependent on the
|
||||||
|
machine's byte order. */
|
||||||
|
|
||||||
|
# include <endian.h>
|
||||||
|
# if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
# define _ISbit(bit) (1 << (bit))
|
||||||
|
# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
|
||||||
|
# define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))
|
||||||
|
# endif
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
_ISupper = _ISbit (0), /* UPPERCASE. */
|
||||||
|
_ISlower = _ISbit (1), /* lowercase. */
|
||||||
|
_ISalpha = _ISbit (2), /* Alphabetic. */
|
||||||
|
_ISdigit = _ISbit (3), /* Numeric. */
|
||||||
|
_ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
|
||||||
|
_ISspace = _ISbit (5), /* Whitespace. */
|
||||||
|
_ISprint = _ISbit (6), /* Printing. */
|
||||||
|
_ISgraph = _ISbit (7), /* Graphical. */
|
||||||
|
_ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
|
||||||
|
_IScntrl = _ISbit (9), /* Control character. */
|
||||||
|
_ISpunct = _ISbit (10), /* Punctuation. */
|
||||||
|
_ISalnum = _ISbit (11) /* Alphanumeric. */
|
||||||
|
};
|
||||||
|
#endif /* ! _ISbit */
|
||||||
|
|
||||||
|
/* These are defined in ctype-info.c.
|
||||||
|
The declarations here must match those in localeinfo.h.
|
||||||
|
|
||||||
|
These point into arrays of 384, so they can be indexed by any `unsigned
|
||||||
|
char' value [0,255]; by EOF (-1); or by any `signed char' value
|
||||||
|
[-128,-1). ISO C requires that the ctype functions work for `unsigned
|
||||||
|
char' values and for EOF; we also support negative `signed char' values
|
||||||
|
for broken old programs. The case conversion arrays are of `int's
|
||||||
|
rather than `unsigned char's because tolower (EOF) must be EOF, which
|
||||||
|
doesn't fit into an `unsigned char'. But today more important is that
|
||||||
|
the arrays are also used for multi-byte character sets. */
|
||||||
|
extern __const unsigned short int *__ctype_b; /* Characteristics. */
|
||||||
|
extern __const __int32_t *__ctype_tolower; /* Case conversions. */
|
||||||
|
extern __const __int32_t *__ctype_toupper; /* Case conversions. */
|
||||||
|
|
||||||
|
#define __isctype(c, type) \
|
||||||
|
(__ctype_b[(int) (c)] & (unsigned short int) type)
|
||||||
|
|
||||||
|
#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
|
||||||
|
#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
|
||||||
|
|
||||||
|
#define __exctype(name) extern int name (int) __THROW
|
||||||
|
|
||||||
|
/* The following names are all functions:
|
||||||
|
int isCHARACTERISTIC(int c);
|
||||||
|
which return nonzero iff C has CHARACTERISTIC.
|
||||||
|
For the meaning of the characteristic names, see the `enum' above. */
|
||||||
|
__exctype (isalnum);
|
||||||
|
__exctype (isalpha);
|
||||||
|
__exctype (iscntrl);
|
||||||
|
__exctype (isdigit);
|
||||||
|
__exctype (islower);
|
||||||
|
__exctype (isgraph);
|
||||||
|
__exctype (isprint);
|
||||||
|
__exctype (ispunct);
|
||||||
|
__exctype (isspace);
|
||||||
|
__exctype (isupper);
|
||||||
|
__exctype (isxdigit);
|
||||||
|
|
||||||
|
#ifdef __USE_ISOC99
|
||||||
|
__exctype (isblank);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Return the lowercase version of C. */
|
||||||
|
extern int tolower (int __c) __THROW;
|
||||||
|
|
||||||
|
/* Return the uppercase version of C. */
|
||||||
|
extern int toupper (int __c) __THROW;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
|
||||||
|
|
||||||
|
/* Return nonzero iff C is in the ASCII set
|
||||||
|
(i.e., is no more than 7 bits wide). */
|
||||||
|
extern int isascii (int __c) __THROW;
|
||||||
|
|
||||||
|
/* Return the part of C that is in the ASCII set
|
||||||
|
(i.e., the low-order 7 bits of C). */
|
||||||
|
extern int toascii (int __c) __THROW;
|
||||||
|
|
||||||
|
/* These are the same as `toupper' and `tolower' except that they do not
|
||||||
|
check the argument for being in the range of a `char'. */
|
||||||
|
__exctype (_toupper);
|
||||||
|
__exctype (_tolower);
|
||||||
|
#endif /* Use SVID or use misc. */
|
||||||
|
|
||||||
|
/* This code is needed for the optimized mapping functions. */
|
||||||
|
#define __tobody(c, f, a, args) \
|
||||||
|
(__extension__ \
|
||||||
|
({ int __res; \
|
||||||
|
if (sizeof (c) > 1) \
|
||||||
|
{ \
|
||||||
|
if (__builtin_constant_p (c)) \
|
||||||
|
{ \
|
||||||
|
int __c = (c); \
|
||||||
|
__res = __c < -128 || __c > 255 ? __c : a[__c]; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
__res = f args; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
__res = a[(int) (c)]; \
|
||||||
|
__res; }))
|
||||||
|
|
||||||
|
#ifndef __NO_CTYPE
|
||||||
|
# define isalnum(c) __isctype((c), _ISalnum)
|
||||||
|
# define isalpha(c) __isctype((c), _ISalpha)
|
||||||
|
# define iscntrl(c) __isctype((c), _IScntrl)
|
||||||
|
# define isdigit(c) __isctype((c), _ISdigit)
|
||||||
|
# define islower(c) __isctype((c), _ISlower)
|
||||||
|
# define isgraph(c) __isctype((c), _ISgraph)
|
||||||
|
# define isprint(c) __isctype((c), _ISprint)
|
||||||
|
# define ispunct(c) __isctype((c), _ISpunct)
|
||||||
|
# define isspace(c) __isctype((c), _ISspace)
|
||||||
|
# define isupper(c) __isctype((c), _ISupper)
|
||||||
|
# define isxdigit(c) __isctype((c), _ISxdigit)
|
||||||
|
|
||||||
|
# ifdef __USE_ISOC99
|
||||||
|
# define isblank(c) __isctype((c), _ISblank)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __USE_EXTERN_INLINES
|
||||||
|
extern __inline int
|
||||||
|
tolower (int __c) __THROW
|
||||||
|
{
|
||||||
|
return __c >= -128 && __c < 256 ? __ctype_tolower[__c] : __c;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern __inline int
|
||||||
|
toupper (int __c) __THROW
|
||||||
|
{
|
||||||
|
return __c >= -128 && __c < 256 ? __ctype_toupper[__c] : __c;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
|
||||||
|
# define tolower(c) __tobody (c, tolower, __ctype_tolower, (c))
|
||||||
|
# define toupper(c) __tobody (c, toupper, __ctype_toupper, (c))
|
||||||
|
# endif /* Optimizing gcc */
|
||||||
|
|
||||||
|
# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
|
||||||
|
# define isascii(c) __isascii (c)
|
||||||
|
# define toascii(c) __toascii (c)
|
||||||
|
|
||||||
|
# define _tolower(c) ((int) __ctype_tolower[(int) (c)])
|
||||||
|
# define _toupper(c) ((int) __ctype_toupper[(int) (c)])
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif /* Not __NO_CTYPE. */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __USE_GNU
|
||||||
|
/* The concept of one static locale per category is not very well
|
||||||
|
thought out. Many applications will need to process its data using
|
||||||
|
information from several different locales. Another application is
|
||||||
|
the implementation of the internationalization handling in the
|
||||||
|
upcoming ISO C++ standard library. To support this another set of
|
||||||
|
the functions using locale data exist which have an additional
|
||||||
|
argument.
|
||||||
|
|
||||||
|
Attention: all these functions are *not* standardized in any form.
|
||||||
|
This is a proof-of-concept implementation. */
|
||||||
|
|
||||||
|
/* Structure for reentrant locale using functions. This is an
|
||||||
|
(almost) opaque type for the user level programs. */
|
||||||
|
# include <xlocale.h>
|
||||||
|
|
||||||
|
/* These definitions are similar to the ones above but all functions
|
||||||
|
take as an argument a handle for the locale which shall be used. */
|
||||||
|
# define __isctype_l(c, type, locale) \
|
||||||
|
((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)
|
||||||
|
|
||||||
|
# define __exctype_l(name) extern int name (int, __locale_t) __THROW
|
||||||
|
|
||||||
|
/* The following names are all functions:
|
||||||
|
int isCHARACTERISTIC(int c, locale_t *locale);
|
||||||
|
which return nonzero iff C has CHARACTERISTIC.
|
||||||
|
For the meaning of the characteristic names, see the `enum' above. */
|
||||||
|
__exctype_l (__isalnum_l);
|
||||||
|
__exctype_l (__isalpha_l);
|
||||||
|
__exctype_l (__iscntrl_l);
|
||||||
|
__exctype_l (__isdigit_l);
|
||||||
|
__exctype_l (__islower_l);
|
||||||
|
__exctype_l (__isgraph_l);
|
||||||
|
__exctype_l (__isprint_l);
|
||||||
|
__exctype_l (__ispunct_l);
|
||||||
|
__exctype_l (__isspace_l);
|
||||||
|
__exctype_l (__isupper_l);
|
||||||
|
__exctype_l (__isxdigit_l);
|
||||||
|
|
||||||
|
__exctype_l (__isblank_l);
|
||||||
|
|
||||||
|
|
||||||
|
/* Return the lowercase version of C in locale L. */
|
||||||
|
extern int __tolower_l (int __c, __locale_t __l) __THROW;
|
||||||
|
|
||||||
|
/* Return the uppercase version of C. */
|
||||||
|
extern int __toupper_l (int __c, __locale_t __l) __THROW;
|
||||||
|
|
||||||
|
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
|
||||||
|
# define __tolower_l(c, locale) \
|
||||||
|
__tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
|
||||||
|
# define __toupper_l(c, locale) \
|
||||||
|
__tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))
|
||||||
|
# endif /* Optimizing gcc */
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef __NO_CTYPE
|
||||||
|
# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
|
||||||
|
# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
|
||||||
|
# define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l))
|
||||||
|
# define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l))
|
||||||
|
# define __islower_l(c,l) __isctype_l((c), _ISlower, (l))
|
||||||
|
# define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l))
|
||||||
|
# define __isprint_l(c,l) __isctype_l((c), _ISprint, (l))
|
||||||
|
# define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l))
|
||||||
|
# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
|
||||||
|
# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
|
||||||
|
# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
|
||||||
|
|
||||||
|
# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
|
||||||
|
|
||||||
|
# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
|
||||||
|
# define __isascii_l(c,l) __isascii(c)
|
||||||
|
# define __toascii_l(c,l) __toascii(c)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# endif /* Not __NO_CTYPE. */
|
||||||
|
|
||||||
|
#endif /* Use GNU. */
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif /* ctype.h */
|
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef __DEFS__
|
||||||
|
#define __DEFS__
|
||||||
|
|
||||||
|
typedef unsigned char byte;
|
||||||
|
typedef unsigned char u8;
|
||||||
|
typedef signed char s8;
|
||||||
|
typedef unsigned short u16;
|
||||||
|
typedef signed short s16;
|
||||||
|
typedef unsigned int u32;
|
||||||
|
typedef signed int s32;
|
||||||
|
typedef signed __int64 s64;
|
||||||
|
typedef unsigned __int64 u64;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL 0x00
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// LIBC basics
|
||||||
|
//
|
||||||
|
|
||||||
|
// GET rid of C4146 compiler warnings: unary minus operator applied to unsigned type, result still unsigned
|
||||||
|
#define NEGU32(a) ((u32) (-((s32)(a))) )
|
||||||
|
|
||||||
|
//typedef unsigned int size_t;
|
||||||
|
#define op_t unsigned long int
|
||||||
|
#define OPSIZ (sizeof(op_t))
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define CONST const*/
|
||||||
|
#define __CONSTVALUE
|
||||||
|
#define __alloca _alloca // MSDEV has a built in _alloca
|
||||||
|
|
||||||
|
|
||||||
|
int isascii(int c);
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__DEFS__
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include <string/endian.h>
|
||||||
|
|
||||||
|
#if defined _LIBC && !defined _ISOMAC
|
||||||
|
# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
|
||||||
|
# define BIG_ENDI 1
|
||||||
|
# undef LITTLE_ENDI
|
||||||
|
# define HIGH_HALF 0
|
||||||
|
# define LOW_HALF 1
|
||||||
|
# else
|
||||||
|
# if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
|
||||||
|
# undef BIG_ENDI
|
||||||
|
# define LITTLE_ENDI 1
|
||||||
|
# define HIGH_HALF 1
|
||||||
|
# define LOW_HALF 0
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
|
@ -0,0 +1,43 @@
|
||||||
|
/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ANSI Standard: 4.1.3 Errors <errno.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ERRNO_H
|
||||||
|
|
||||||
|
#define _ERRNO_H 1
|
||||||
|
|
||||||
|
/* Get the error number constants. */
|
||||||
|
#include <errnos.h>
|
||||||
|
|
||||||
|
/* Declare the `errno' variable. */
|
||||||
|
extern int __errno;
|
||||||
|
|
||||||
|
#define errno __errno
|
||||||
|
|
||||||
|
#ifdef __USE_GNU
|
||||||
|
/* The full and simple forms of the name with which the program was
|
||||||
|
invoked. These variables are set up automatically at startup based on
|
||||||
|
the value of ARGV[0] (this works only if you use GNU ld). */
|
||||||
|
extern char *program_invocation_name, *program_invocation_short_name;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* errno.h */
|
||||||
|
#define EINVAL -1
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifdef _ERRNO_H
|
||||||
|
#endif /* <errno.h> included. */
|
||||||
|
|
||||||
|
#if !defined(__Emath_defined) && (defined(_ERRNO_H) || defined(__need_Emath))
|
||||||
|
#define EDOM 1
|
||||||
|
#define ERANGE 2
|
||||||
|
#else /* Emath not defined and <errno.h> included or need Emath. */
|
||||||
|
#define ENOSYS 3
|
||||||
|
#endif /* <errno.h> included. */
|
||||||
|
|
||||||
|
#undef __need_Emath
|
||||||
|
#ifndef __Emath_defined
|
||||||
|
#define __Emath_defined 1
|
||||||
|
#endif
|
|
@ -0,0 +1,315 @@
|
||||||
|
/* Copyright (C) 1991-1993, 1995-2000, 2001 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#ifndef _FEATURES_H
|
||||||
|
#define _FEATURES_H 1
|
||||||
|
|
||||||
|
/* These are defined by the user (or the compiler)
|
||||||
|
to specify the desired environment:
|
||||||
|
|
||||||
|
__STRICT_ANSI__ ISO Standard C.
|
||||||
|
_ISOC99_SOURCE Extensions to ISO C89 from ISO C99.
|
||||||
|
_POSIX_SOURCE IEEE Std 1003.1.
|
||||||
|
_POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
|
||||||
|
if >=199309L, add IEEE Std 1003.1b-1993;
|
||||||
|
if >=199506L, add IEEE Std 1003.1c-1995
|
||||||
|
_XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
|
||||||
|
Single Unix conformance is wanted, to 600 for the
|
||||||
|
upcoming sixth revision.
|
||||||
|
_XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
|
||||||
|
_LARGEFILE_SOURCE Some more functions for correct standard I/O.
|
||||||
|
_LARGEFILE64_SOURCE Additional functionality from LFS for large files.
|
||||||
|
_FILE_OFFSET_BITS=N Select default filesystem interface.
|
||||||
|
_BSD_SOURCE ISO C, POSIX, and 4.3BSD things.
|
||||||
|
_SVID_SOURCE ISO C, POSIX, and SVID things.
|
||||||
|
_GNU_SOURCE All of the above, plus GNU extensions.
|
||||||
|
_REENTRANT Select additionally reentrant object.
|
||||||
|
_THREAD_SAFE Same as _REENTRANT, often used by other systems.
|
||||||
|
|
||||||
|
The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
|
||||||
|
If none of these are defined, the default is to have _SVID_SOURCE,
|
||||||
|
_BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
|
||||||
|
199506L. If more than one of these are defined, they accumulate.
|
||||||
|
For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
|
||||||
|
together give you ISO C, 1003.1, and 1003.2, but nothing else.
|
||||||
|
|
||||||
|
These are defined by this file and are used by the
|
||||||
|
header files to decide what to declare or define:
|
||||||
|
|
||||||
|
__USE_ISOC99 Define ISO C99 things.
|
||||||
|
__USE_POSIX Define IEEE Std 1003.1 things.
|
||||||
|
__USE_POSIX2 Define IEEE Std 1003.2 things.
|
||||||
|
__USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
|
||||||
|
__USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things.
|
||||||
|
__USE_XOPEN Define XPG things.
|
||||||
|
__USE_XOPEN_EXTENDED Define X/Open Unix things.
|
||||||
|
__USE_UNIX98 Define Single Unix V2 things.
|
||||||
|
__USE_XOPEN2K Define XPG6 things.
|
||||||
|
__USE_LARGEFILE Define correct standard I/O things.
|
||||||
|
__USE_LARGEFILE64 Define LFS things with separate names.
|
||||||
|
__USE_FILE_OFFSET64 Define 64bit interface as default.
|
||||||
|
__USE_BSD Define 4.3BSD things.
|
||||||
|
__USE_SVID Define SVID things.
|
||||||
|
__USE_MISC Define things common to BSD and System V Unix.
|
||||||
|
__USE_GNU Define GNU extensions.
|
||||||
|
__USE_REENTRANT Define reentrant/thread-safe *_r functions.
|
||||||
|
__FAVOR_BSD Favor 4.3BSD things in cases of conflict.
|
||||||
|
|
||||||
|
The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
|
||||||
|
defined by this file unconditionally. `__GNU_LIBRARY__' is provided
|
||||||
|
only for compatibility. All new code should use the other symbols
|
||||||
|
to test for features.
|
||||||
|
|
||||||
|
All macros listed above as possibly being defined by this file are
|
||||||
|
explicitly undefined if they are not explicitly defined.
|
||||||
|
Feature-test macros that are not defined by the user or compiler
|
||||||
|
but are implied by the other feature-test macros defined (or by the
|
||||||
|
lack of any definitions) are defined by the file. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Undefine everything, so we get a clean slate. */
|
||||||
|
#undef __USE_ISOC99
|
||||||
|
#undef __USE_POSIX
|
||||||
|
#undef __USE_POSIX2
|
||||||
|
#undef __USE_POSIX199309
|
||||||
|
#undef __USE_POSIX199506
|
||||||
|
#undef __USE_XOPEN
|
||||||
|
#undef __USE_XOPEN_EXTENDED
|
||||||
|
#undef __USE_UNIX98
|
||||||
|
#undef __USE_XOPEN2K
|
||||||
|
#undef __USE_LARGEFILE
|
||||||
|
#undef __USE_LARGEFILE64
|
||||||
|
#undef __USE_FILE_OFFSET64
|
||||||
|
#undef __USE_BSD
|
||||||
|
#undef __USE_SVID
|
||||||
|
#undef __USE_MISC
|
||||||
|
#undef __USE_GNU
|
||||||
|
#undef __USE_REENTRANT
|
||||||
|
#undef __FAVOR_BSD
|
||||||
|
#undef __KERNEL_STRICT_NAMES
|
||||||
|
|
||||||
|
/* Suppress kernel-name space pollution unless user expressedly asks
|
||||||
|
for it. */
|
||||||
|
#ifndef _LOOSE_KERNEL_NAMES
|
||||||
|
# define __KERNEL_STRICT_NAMES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Always use ISO C things. */
|
||||||
|
#define __USE_ANSI 1
|
||||||
|
|
||||||
|
|
||||||
|
/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
|
||||||
|
#if defined _BSD_SOURCE && \
|
||||||
|
!(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
|
||||||
|
defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
|
||||||
|
defined _GNU_SOURCE || defined _SVID_SOURCE)
|
||||||
|
# define __FAVOR_BSD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If _GNU_SOURCE was defined by the user, turn on all the other features. */
|
||||||
|
#ifdef _GNU_SOURCE
|
||||||
|
# undef _ISOC99_SOURCE
|
||||||
|
# define _ISOC99_SOURCE 1
|
||||||
|
# undef _POSIX_SOURCE
|
||||||
|
# define _POSIX_SOURCE 1
|
||||||
|
# undef _POSIX_C_SOURCE
|
||||||
|
# define _POSIX_C_SOURCE 199506L
|
||||||
|
# undef _XOPEN_SOURCE
|
||||||
|
# define _XOPEN_SOURCE 600
|
||||||
|
# undef _XOPEN_SOURCE_EXTENDED
|
||||||
|
# define _XOPEN_SOURCE_EXTENDED 1
|
||||||
|
# undef _LARGEFILE64_SOURCE
|
||||||
|
# define _LARGEFILE64_SOURCE 1
|
||||||
|
# undef _BSD_SOURCE
|
||||||
|
# define _BSD_SOURCE 1
|
||||||
|
# undef _SVID_SOURCE
|
||||||
|
# define _SVID_SOURCE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If nothing (other than _GNU_SOURCE) is defined,
|
||||||
|
define _BSD_SOURCE and _SVID_SOURCE. */
|
||||||
|
#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
|
||||||
|
!defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
|
||||||
|
!defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
|
||||||
|
!defined _BSD_SOURCE && !defined _SVID_SOURCE)
|
||||||
|
# define _BSD_SOURCE 1
|
||||||
|
# define _SVID_SOURCE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is to enable the ISO C99 extension. Also recognize the old macro
|
||||||
|
which was used prior to the standard acceptance. This macro will
|
||||||
|
eventually go away and the features enabled by default once the ISO C99
|
||||||
|
standard is widely adopted. */
|
||||||
|
#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
|
||||||
|
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
|
||||||
|
# define __USE_ISOC99 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
|
||||||
|
(and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
|
||||||
|
#if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
|
||||||
|
!defined _POSIX_C_SOURCE)
|
||||||
|
# define _POSIX_SOURCE 1
|
||||||
|
# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
|
||||||
|
# define _POSIX_C_SOURCE 2
|
||||||
|
# else
|
||||||
|
# define _POSIX_C_SOURCE 199506L
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
|
||||||
|
# define __USE_POSIX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
|
||||||
|
# define __USE_POSIX2 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (_POSIX_C_SOURCE - 0) >= 199309L
|
||||||
|
# define __USE_POSIX199309 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (_POSIX_C_SOURCE - 0) >= 199506L
|
||||||
|
# define __USE_POSIX199506 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _XOPEN_SOURCE
|
||||||
|
# define __USE_XOPEN 1
|
||||||
|
# if (_XOPEN_SOURCE - 0) >= 500
|
||||||
|
# define __USE_XOPEN_EXTENDED 1
|
||||||
|
# define __USE_UNIX98 1
|
||||||
|
# undef _LARGEFILE_SOURCE
|
||||||
|
# define _LARGEFILE_SOURCE 1
|
||||||
|
# if (_XOPEN_SOURCE - 0) >= 600
|
||||||
|
# define __USE_XOPEN2K 1
|
||||||
|
# undef __USE_ISOC99
|
||||||
|
# define __USE_ISOC99 1
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifdef _XOPEN_SOURCE_EXTENDED
|
||||||
|
# define __USE_XOPEN_EXTENDED 1
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE_SOURCE
|
||||||
|
# define __USE_LARGEFILE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
# define __USE_LARGEFILE64 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
|
||||||
|
# define __USE_FILE_OFFSET64 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _BSD_SOURCE || defined _SVID_SOURCE
|
||||||
|
# define __USE_MISC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _BSD_SOURCE
|
||||||
|
# define __USE_BSD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _SVID_SOURCE
|
||||||
|
# define __USE_SVID 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GNU_SOURCE
|
||||||
|
# define __USE_GNU 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _REENTRANT || defined _THREAD_SAFE
|
||||||
|
# define __USE_REENTRANT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We do support the IEC 559 math functionality, real and complex. */
|
||||||
|
#define __STDC_IEC_559__ 1
|
||||||
|
#define __STDC_IEC_559_COMPLEX__ 1
|
||||||
|
|
||||||
|
/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */
|
||||||
|
#define __STDC_ISO_10646__ 200009L
|
||||||
|
|
||||||
|
/* This macro indicates that the installed library is the GNU C Library.
|
||||||
|
For historic reasons the value now is 6 and this will stay from now
|
||||||
|
on. The use of this variable is deprecated. Use __GLIBC__ and
|
||||||
|
__GLIBC_MINOR__ now (see below) when you want to test for a specific
|
||||||
|
GNU C library version and use the values in <gnu/lib-names.h> to get
|
||||||
|
the sonames of the shared libraries. */
|
||||||
|
#undef __GNU_LIBRARY__
|
||||||
|
#define __GNU_LIBRARY__ 6
|
||||||
|
|
||||||
|
/* Major and minor version number of the GNU C library package. Use
|
||||||
|
these macros to test for features in specific releases. */
|
||||||
|
#define __GLIBC__ 2
|
||||||
|
#define __GLIBC_MINOR__ 2
|
||||||
|
|
||||||
|
/* Convenience macros to test the versions of glibc and gcc.
|
||||||
|
Use them like this:
|
||||||
|
#if __GNUC_PREREQ (2,8)
|
||||||
|
... code requiring gcc 2.8 or later ...
|
||||||
|
#endif
|
||||||
|
Note - they won't work for gcc1 or glibc1, since the _MINOR macros
|
||||||
|
were not defined then. */
|
||||||
|
#if defined __GNUC__ && defined __GNUC_MINOR__
|
||||||
|
# define __GNUC_PREREQ(maj, min) \
|
||||||
|
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||||
|
#else
|
||||||
|
# define __GNUC_PREREQ(maj, min) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __GLIBC_PREREQ(maj, min) \
|
||||||
|
((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
|
||||||
|
|
||||||
|
/* This is here only because every header file already includes this one. */
|
||||||
|
#ifndef __ASSEMBLER__
|
||||||
|
# ifndef _SYS_CDEFS_H
|
||||||
|
# include <sys/cdefs.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* If we don't have __REDIRECT, prototypes will be missing if
|
||||||
|
__USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
|
||||||
|
# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
|
||||||
|
# define __USE_LARGEFILE 1
|
||||||
|
# define __USE_LARGEFILE64 1
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif /* !ASSEMBLER */
|
||||||
|
|
||||||
|
/* Decide whether we can define 'extern inline' functions in headers. */
|
||||||
|
#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
|
||||||
|
&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
|
||||||
|
# define __USE_EXTERN_INLINES 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is here only because every header file already includes this one. */
|
||||||
|
#ifndef _LIBC
|
||||||
|
/* Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
|
||||||
|
<gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
|
||||||
|
which will always return failure (and set errno to ENOSYS).
|
||||||
|
|
||||||
|
We avoid including <gnu/stubs.h> when compiling the C library itself to
|
||||||
|
avoid a dependency loop. stubs.h depends on every object file. If
|
||||||
|
this #include were done for the library source code, then every object
|
||||||
|
file would depend on stubs.h. */
|
||||||
|
|
||||||
|
//# include <gnu/stubs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* features.h */
|
|
@ -0,0 +1,4 @@
|
||||||
|
#define __USE_MISC 1
|
||||||
|
#define __USE_GNU 1
|
||||||
|
#define __P(arg) arg
|
||||||
|
#define __ptr_t void *
|
|
@ -0,0 +1,306 @@
|
||||||
|
#ifndef _FLOAT_
|
||||||
|
#define _FLOAT_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ansidecl.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _CRTIMP
|
||||||
|
#define _CRTIMP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern u8 _Nan[8];
|
||||||
|
extern u8 _Inf[8];
|
||||||
|
|
||||||
|
//#define NAN ((unsigned __int64)0xfff8000000000000)
|
||||||
|
|
||||||
|
#define NAN *((double*)(&_Nan[0])) // instead of using __int64, store a NAN somwhere in memory (misc_vars.c)
|
||||||
|
#define INF *((double*)(&_Inf[0])) // Constant INF
|
||||||
|
|
||||||
|
#define DBL_DIG 15 // # of decimal digits of precision
|
||||||
|
#define DBL_EPSILON 2.2204460492503131e-016 // smallest such that 1.0+DBL_EPSILON != 1.0
|
||||||
|
#define DBL_MANT_DIG 53 // # of bits in mantissa
|
||||||
|
#define DBL_MAX 1.7976931348623158e+308 // max value
|
||||||
|
#define DBL_MAX_10_EXP 308 // max decimal exponent
|
||||||
|
#define DBL_MAX_EXP 1024 // max binary exponent
|
||||||
|
#define DBL_MIN 2.2250738585072014e-308 // min positive value
|
||||||
|
#define DBL_MIN_10_EXP (-307) // min decimal exponent
|
||||||
|
#define DBL_MIN_EXP (-1021) // min binary exponent
|
||||||
|
#define _DBL_RADIX 2 // exponent radix
|
||||||
|
#define _DBL_ROUNDS 1 // addition rounding: near
|
||||||
|
|
||||||
|
#define FLT_DIG 6 // # of decimal digits of precision
|
||||||
|
#define FLT_EPSILON 1.192092896e-07F // smallest such that 1.0+FLT_EPSILON != 1.0
|
||||||
|
#define FLT_GUARD 0
|
||||||
|
#define FLT_MANT_DIG 24 // # of bits in mantissa
|
||||||
|
#define FLT_MAX 3.402823466e+38F // max value
|
||||||
|
#define FLT_MAX_10_EXP 38 // max decimal exponent
|
||||||
|
#define FLT_MAX_EXP 128 // max binary exponent
|
||||||
|
#define FLT_MIN 1.175494351e-38F // min positive value
|
||||||
|
#define FLT_MIN_10_EXP (-37) // min decimal exponent
|
||||||
|
#define FLT_MIN_EXP (-125) // min binary exponent
|
||||||
|
#define FLT_NORMALIZE 0
|
||||||
|
#define FLT_RADIX 2 // exponent radix
|
||||||
|
#define FLT_ROUNDS 1 // addition rounding: near
|
||||||
|
|
||||||
|
#ifndef _M_M68K
|
||||||
|
#define LDBL_DIG DBL_DIG // # of decimal digits of precision
|
||||||
|
#define LDBL_EPSILON DBL_EPSILON // smallest such that 1.0+LDBL_EPSILON != 1.0
|
||||||
|
#define LDBL_MANT_DIG DBL_MANT_DIG // # of bits in mantissa
|
||||||
|
#define LDBL_MAX DBL_MAX // max value
|
||||||
|
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP // max decimal exponent
|
||||||
|
#define LDBL_MAX_EXP DBL_MAX_EXP // max binary exponent
|
||||||
|
#define LDBL_MIN DBL_MIN // min positive value
|
||||||
|
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP // min decimal exponent
|
||||||
|
#define LDBL_MIN_EXP DBL_MIN_EXP // min binary exponent
|
||||||
|
#define _LDBL_RADIX DBL_RADIX // exponent radix
|
||||||
|
#define _LDBL_ROUNDS DBL_ROUNDS // addition rounding: near
|
||||||
|
#else
|
||||||
|
#define LDBL_DIG 18 // # of decimal digits of precision
|
||||||
|
#define LDBL_EPSILON 1.08420217248550443412e-019L // smallest such that 1.0+LDBL_EPSILON != 1.0
|
||||||
|
#define LDBL_MANT_DIG 64 // # of bits in mantissa
|
||||||
|
#define LDBL_MAX 1.189731495357231765e+4932L // max value
|
||||||
|
#define LDBL_MAX_10_EXP 4932 // max decimal exponent
|
||||||
|
#define LDBL_MAX_EXP 16384 // max binary exponent
|
||||||
|
#define LDBL_MIN 3.3621031431120935063e-4932L // min positive value
|
||||||
|
#define LDBL_MIN_10_EXP (-4931) // min decimal exponent
|
||||||
|
#define LDBL_MIN_EXP (-16381) // min binary exponent
|
||||||
|
#define _LDBL_RADIX 2 // exponent radix
|
||||||
|
#define _LDBL_ROUNDS 1 // addition rounding: near
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Function prototypes
|
||||||
|
|
||||||
|
_CRTIMP unsigned int __cdecl _clearfp(void);
|
||||||
|
_CRTIMP unsigned int __cdecl _controlfp(unsigned int,unsigned int);
|
||||||
|
_CRTIMP unsigned int __cdecl _statusfp(void);
|
||||||
|
_CRTIMP void __cdecl _fpreset(void);
|
||||||
|
|
||||||
|
#ifndef _MAC
|
||||||
|
#define _clear87 _clearfp
|
||||||
|
#define _status87 _statusfp
|
||||||
|
#endif // _MAC
|
||||||
|
|
||||||
|
//
|
||||||
|
// Abstract User Control Word Mask and bit definitions
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef _MAC
|
||||||
|
#define _MCW_EM 0x0008001f // interrupt Exception Masks
|
||||||
|
#else
|
||||||
|
#define _MCW_EM 0x0000001f // interrupt Exception Masks
|
||||||
|
#endif
|
||||||
|
#define _EM_INEXACT 0x00000001 // inexact (precision)
|
||||||
|
#define _EM_UNDERFLOW 0x00000002 // underflow
|
||||||
|
#define _EM_OVERFLOW 0x00000004 // overflow
|
||||||
|
#define _EM_ZERODIVIDE 0x00000008 // zero divide
|
||||||
|
#define _EM_INVALID 0x00000010 // invalid
|
||||||
|
|
||||||
|
#define _MCW_RC 0x00000300 // Rounding Control
|
||||||
|
#define _RC_NEAR 0x00000000 // near
|
||||||
|
#define _RC_DOWN 0x00000100 // down
|
||||||
|
#define _RC_UP 0x00000200 // up
|
||||||
|
#define _RC_CHOP 0x00000300 // chop
|
||||||
|
|
||||||
|
//
|
||||||
|
// Abstract User Status Word bit definitions
|
||||||
|
|
||||||
|
|
||||||
|
#define _SW_INEXACT 0x00000001 // inexact (precision)
|
||||||
|
#define _SW_UNDERFLOW 0x00000002 // underflow
|
||||||
|
#define _SW_OVERFLOW 0x00000004 // overflow
|
||||||
|
#define _SW_ZERODIVIDE 0x00000008 // zero divide
|
||||||
|
#define _SW_INVALID 0x00000010 // invalid
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// i386 specific definitions
|
||||||
|
|
||||||
|
#define _MCW_PC 0x00030000 // Precision Control
|
||||||
|
#ifdef _M_MPPC
|
||||||
|
//
|
||||||
|
* PowerMac specific definitions(no precision control)
|
||||||
|
|
||||||
|
#define _PC_64 0x00000000 // 64 bits
|
||||||
|
#define _PC_53 0x00000000 // 53 bits
|
||||||
|
#define _PC_24 0x00000000 // 24 bits
|
||||||
|
#else
|
||||||
|
#define _PC_64 0x00000000 // 64 bits
|
||||||
|
#define _PC_53 0x00010000 // 53 bits
|
||||||
|
#define _PC_24 0x00020000 // 24 bits
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _MCW_IC 0x00040000 // Infinity Control
|
||||||
|
#define _IC_AFFINE 0x00040000 // affine
|
||||||
|
#define _IC_PROJECTIVE 0x00000000 // projective
|
||||||
|
|
||||||
|
#define _EM_DENORMAL 0x00080000 // denormal exception mask (_control87 only)
|
||||||
|
|
||||||
|
#define _SW_DENORMAL 0x00080000 // denormal status bit
|
||||||
|
|
||||||
|
|
||||||
|
_CRTIMP unsigned int __cdecl _control87(unsigned int,unsigned int);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// RISC specific definitions
|
||||||
|
|
||||||
|
|
||||||
|
#define _MCW_DN 0x03000000 // Denormal Control
|
||||||
|
#define _DN_SAVE 0x00000000 // save denormal results and operands
|
||||||
|
#define _DN_FLUSH 0x01000000 // flush denormal results and operands to zero
|
||||||
|
#define _DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000 // flush operands to zero and save results
|
||||||
|
#define _DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000 // save operands and flush results to zero
|
||||||
|
|
||||||
|
|
||||||
|
// initial Control Word value
|
||||||
|
|
||||||
|
#if defined(_M_IX86)
|
||||||
|
|
||||||
|
#define _CW_DEFAULT ( _RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
|
||||||
|
|
||||||
|
#elif defined(_MAC)
|
||||||
|
|
||||||
|
#define _CW_DEFAULT ( _RC_NEAR + _PC_64 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT )
|
||||||
|
|
||||||
|
#elif defined(_M_MRX000) || defined (_M_ALPHA) || defined(_M_PPC)
|
||||||
|
|
||||||
|
#define _CW_DEFAULT ( _RC_NEAR + _DN_FLUSH + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT )
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Global variable holding floating point error code
|
||||||
|
|
||||||
|
#if defined(_MT) || defined(_DLL)
|
||||||
|
_CRTIMP extern int * __cdecl __fpecode(void);
|
||||||
|
#define _fpecode (*__fpecode())
|
||||||
|
#else // ndef _MT && ndef _DLL
|
||||||
|
extern int _fpecode;
|
||||||
|
#endif // _MT || _DLL
|
||||||
|
|
||||||
|
// invalid subconditions (_SW_INVALID also set)
|
||||||
|
|
||||||
|
#define _SW_UNEMULATED 0x0040 // unemulated instruction
|
||||||
|
#define _SW_SQRTNEG 0x0080 // square root of a neg number
|
||||||
|
#define _SW_STACKOVERFLOW 0x0200 // FP stack overflow
|
||||||
|
#define _SW_STACKUNDERFLOW 0x0400 // FP stack underflow
|
||||||
|
|
||||||
|
// Floating point error signals and return codes
|
||||||
|
|
||||||
|
#define _FPE_INVALID 0x81
|
||||||
|
#define _FPE_DENORMAL 0x82
|
||||||
|
#define _FPE_ZERODIVIDE 0x83
|
||||||
|
#define _FPE_OVERFLOW 0x84
|
||||||
|
#define _FPE_UNDERFLOW 0x85
|
||||||
|
#define _FPE_INEXACT 0x86
|
||||||
|
|
||||||
|
#define _FPE_UNEMULATED 0x87
|
||||||
|
#define _FPE_SQRTNEG 0x88
|
||||||
|
#define _FPE_STACKOVERFLOW 0x8a
|
||||||
|
#define _FPE_STACKUNDERFLOW 0x8b
|
||||||
|
|
||||||
|
#define _FPE_EXPLICITGEN 0x8c // raise( SIGFPE );
|
||||||
|
|
||||||
|
|
||||||
|
// IEEE recommended functions
|
||||||
|
|
||||||
|
_CRTIMP double __cdecl _copysign (double, double);
|
||||||
|
_CRTIMP double __cdecl _chgsign (double);
|
||||||
|
_CRTIMP double __cdecl _scalb(double, long);
|
||||||
|
_CRTIMP double __cdecl _logb(double);
|
||||||
|
_CRTIMP double __cdecl _nextafter(double, double);
|
||||||
|
_CRTIMP int __cdecl _finite(double);
|
||||||
|
_CRTIMP int __cdecl _isnan(double);
|
||||||
|
_CRTIMP int __cdecl _fpclass(double);
|
||||||
|
|
||||||
|
#define _FPCLASS_SNAN 0x0001 // signaling NaN
|
||||||
|
#define _FPCLASS_QNAN 0x0002 // quiet NaN
|
||||||
|
#define _FPCLASS_NINF 0x0004 // negative infinity
|
||||||
|
#define _FPCLASS_NN 0x0008 // negative normal
|
||||||
|
#define _FPCLASS_ND 0x0010 // negative denormal
|
||||||
|
#define _FPCLASS_NZ 0x0020 // -0
|
||||||
|
#define _FPCLASS_PZ 0x0040 // +0
|
||||||
|
#define _FPCLASS_PD 0x0080 // positive denormal
|
||||||
|
#define _FPCLASS_PN 0x0100 // positive normal
|
||||||
|
#define _FPCLASS_PINF 0x0200 // positive infinity
|
||||||
|
|
||||||
|
|
||||||
|
#if !__STDC__
|
||||||
|
|
||||||
|
// Non-ANSI names for compatibility
|
||||||
|
|
||||||
|
#ifndef _MAC
|
||||||
|
#define clear87 _clear87
|
||||||
|
#define status87 _status87
|
||||||
|
#define control87 _control87
|
||||||
|
#endif // _MAC
|
||||||
|
|
||||||
|
_CRTIMP void __cdecl fpreset(void);
|
||||||
|
|
||||||
|
#define DBL_RADIX _DBL_RADIX
|
||||||
|
#define DBL_ROUNDS _DBL_ROUNDS
|
||||||
|
|
||||||
|
#define LDBL_RADIX _LDBL_RADIX
|
||||||
|
#define LDBL_ROUNDS _LDBL_ROUNDS
|
||||||
|
|
||||||
|
#define MCW_EM _MCW_EM
|
||||||
|
#define EM_INVALID _EM_INVALID
|
||||||
|
#define EM_DENORMAL _EM_DENORMAL
|
||||||
|
#define EM_ZERODIVIDE _EM_ZERODIVIDE
|
||||||
|
#define EM_OVERFLOW _EM_OVERFLOW
|
||||||
|
#define EM_UNDERFLOW _EM_UNDERFLOW
|
||||||
|
#define EM_INEXACT _EM_INEXACT
|
||||||
|
|
||||||
|
#define MCW_IC _MCW_IC
|
||||||
|
#define IC_AFFINE _IC_AFFINE
|
||||||
|
#define IC_PROJECTIVE _IC_PROJECTIVE
|
||||||
|
|
||||||
|
#define MCW_RC _MCW_RC
|
||||||
|
#define RC_CHOP _RC_CHOP
|
||||||
|
#define RC_UP _RC_UP
|
||||||
|
#define RC_DOWN _RC_DOWN
|
||||||
|
#define RC_NEAR _RC_NEAR
|
||||||
|
|
||||||
|
#define MCW_PC _MCW_PC
|
||||||
|
#define PC_24 _PC_24
|
||||||
|
#define PC_53 _PC_53
|
||||||
|
#define PC_64 _PC_64
|
||||||
|
|
||||||
|
#define CW_DEFAULT _CW_DEFAULT
|
||||||
|
|
||||||
|
#define SW_INVALID _SW_INVALID
|
||||||
|
#define SW_DENORMAL _SW_DENORMAL
|
||||||
|
#define SW_ZERODIVIDE _SW_ZERODIVIDE
|
||||||
|
#define SW_OVERFLOW _SW_OVERFLOW
|
||||||
|
#define SW_UNDERFLOW _SW_UNDERFLOW
|
||||||
|
#define SW_INEXACT _SW_INEXACT
|
||||||
|
|
||||||
|
#define SW_UNEMULATED _SW_UNEMULATED
|
||||||
|
#define SW_SQRTNEG _SW_SQRTNEG
|
||||||
|
#define SW_STACKOVERFLOW _SW_STACKOVERFLOW
|
||||||
|
#define SW_STACKUNDERFLOW _SW_STACKUNDERFLOW
|
||||||
|
|
||||||
|
#define FPE_INVALID _FPE_INVALID
|
||||||
|
#define FPE_DENORMAL _FPE_DENORMAL
|
||||||
|
#define FPE_ZERODIVIDE _FPE_ZERODIVIDE
|
||||||
|
#define FPE_OVERFLOW _FPE_OVERFLOW
|
||||||
|
#define FPE_UNDERFLOW _FPE_UNDERFLOW
|
||||||
|
#define FPE_INEXACT _FPE_INEXACT
|
||||||
|
|
||||||
|
#define FPE_UNEMULATED _FPE_UNEMULATED
|
||||||
|
#define FPE_SQRTNEG _FPE_SQRTNEG
|
||||||
|
#define FPE_STACKOVERFLOW _FPE_STACKOVERFLOW
|
||||||
|
#define FPE_STACKUNDERFLOW _FPE_STACKUNDERFLOW
|
||||||
|
|
||||||
|
#define FPE_EXPLICITGEN _FPE_EXPLICITGEN
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,80 @@
|
||||||
|
/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#ifndef __GNU_STABS_H
|
||||||
|
|
||||||
|
#define __GNU_STABS_H 1
|
||||||
|
|
||||||
|
//#ifdef HAVE_GNU_LD
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// GNU-STABS for rand.c stuff
|
||||||
|
//
|
||||||
|
/* Alias a function:
|
||||||
|
function_alias(creat, _creat, int, (file, mode),
|
||||||
|
DEFUN(creat, (file, mode),
|
||||||
|
CONST char *file AND int mode))
|
||||||
|
Yes, this is very repetitive. Nothing you can do about it, so shut up. */
|
||||||
|
#define function_alias(name, _name, type, args, defun) \
|
||||||
|
symbol_alias (_name, name);
|
||||||
|
|
||||||
|
#define function_alias_void(name, _name, args, defun) \
|
||||||
|
symbol_alias (_name, name);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NO_UNDERSCORES
|
||||||
|
#define __SYMBOL_PREFIX
|
||||||
|
#else
|
||||||
|
#define __SYMBOL_PREFIX "_"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Make references to ALIAS refer to SYMBOL.
|
||||||
|
/*
|
||||||
|
#define symbol_alias(symbol, alias) \
|
||||||
|
asm(".stabs \"" __SYMBOL_PREFIX #alias "\",11,0,0,0\n"\
|
||||||
|
".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0")
|
||||||
|
|
||||||
|
// Issue a warning message from the linker whenever SYMBOL is referenced.
|
||||||
|
#define warn_references(symbol, msg) \
|
||||||
|
asm(".stabs \"" msg "\",30,0,0,0\n" \
|
||||||
|
".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0")
|
||||||
|
|
||||||
|
#define stub_warning(name) \
|
||||||
|
warn_references(name, \
|
||||||
|
"warning: " #name " is not implemented and will always fail")
|
||||||
|
|
||||||
|
#define text_set_element(set, symbol) \
|
||||||
|
asm(".stabs \"" __SYMBOL_PREFIX #set "\",23,0,0," __SYMBOL_PREFIX #symbol)
|
||||||
|
#define data_set_element(set, symbol) \
|
||||||
|
asm(".stabs \"" __SYMBOL_PREFIX #set "\",25,0,0," __SYMBOL_PREFIX #symbol)
|
||||||
|
#define bss_set_element(set, symbol) \
|
||||||
|
asm(".stabs \"" __SYMBOL_PREFIX #set "\",27,0,0," __SYMBOL_PREFIX #symbol)
|
||||||
|
|
||||||
|
#else // No GNU stabs.
|
||||||
|
|
||||||
|
#define function_alias(name, _name, type, args, defun) \
|
||||||
|
type defun { return _name args; }
|
||||||
|
|
||||||
|
#define function_alias_void(name, _name, args, defun) \
|
||||||
|
void defun { _name args; }
|
||||||
|
|
||||||
|
*/
|
||||||
|
//#endif // GNU stabs.
|
||||||
|
|
||||||
|
#endif // gnu-stabs.h
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
|
||||||
|
Used by <stdlib.h> and <math.h> functions for overflow.
|
||||||
|
|
||||||
|
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#ifndef _HUGE_VAL_H
|
||||||
|
#define _HUGE_VAL_H 1
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
|
/* IEEE positive infinity. */
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
#define __huge_val_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
|
||||||
|
#endif
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
#define __huge_val_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define HUGE_VAL \
|
||||||
|
(__extension__ ((union { unsigned char __c[8]; \
|
||||||
|
double __d; }) \
|
||||||
|
{ __huge_val_bytes }).__d)
|
||||||
|
#else /* Not GCC. */
|
||||||
|
static __const unsigned char __huge_val[8] = __huge_val_bytes;
|
||||||
|
#define HUGE_VAL (*(__const double *) __huge_val)
|
||||||
|
#endif /* GCC. */
|
||||||
|
|
||||||
|
#endif /* huge_val.h */
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#ifndef _LIMITS
|
||||||
|
#define _LIMITS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define LONG_MIN (-2147483647-1)
|
||||||
|
#define LONG_MAX (2147483647)
|
||||||
|
#define ULONG_MAX (0xffffffff)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _LIMITS
|
|
@ -0,0 +1,282 @@
|
||||||
|
/* Declarations for `malloc' and friends.
|
||||||
|
Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||||
|
Written May 1989 by Mike Haertel.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
The author may be reached (Email) at the address mike@ai.mit.edu,
|
||||||
|
or (US mail) as Mike Haertel c/o Free Software Foundation. */
|
||||||
|
|
||||||
|
#ifndef _MALLOC_H
|
||||||
|
|
||||||
|
#define _MALLOC_H 1
|
||||||
|
|
||||||
|
#ifdef _MALLOC_INTERNAL
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LIBC) || defined(STDC_HEADERS) || defined(USG)
|
||||||
|
#include <string.h>
|
||||||
|
#else
|
||||||
|
#ifndef memset
|
||||||
|
#define memset(s, zero, n) bzero ((s), (n))
|
||||||
|
#endif
|
||||||
|
#ifndef memcpy
|
||||||
|
#define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__GNU_LIBRARY__) || (defined (__STDC__) && __STDC__)
|
||||||
|
#include <limits.h>
|
||||||
|
#else
|
||||||
|
#ifndef CHAR_BIT
|
||||||
|
#define CHAR_BIT 8
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _MALLOC_INTERNAL. */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
|
||||||
|
#undef __P
|
||||||
|
#define __P(args) args
|
||||||
|
#undef __ptr_t
|
||||||
|
#define __ptr_t void *
|
||||||
|
#else /* Not C++ or ANSI C. */
|
||||||
|
#undef __P
|
||||||
|
#define __P(args) ()
|
||||||
|
#undef const
|
||||||
|
#define const
|
||||||
|
#undef __ptr_t
|
||||||
|
#define __ptr_t char *
|
||||||
|
#endif /* C++ or ANSI C. */
|
||||||
|
|
||||||
|
#if defined (__STDC__) && __STDC__
|
||||||
|
#include <stddef.h>
|
||||||
|
#define __malloc_size_t size_t
|
||||||
|
#else
|
||||||
|
#define __malloc_size_t unsigned int
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Allocate SIZE bytes of memory. */
|
||||||
|
extern __ptr_t malloc __P ((size_t __size));
|
||||||
|
/* Re-allocate the previously allocated block
|
||||||
|
in __ptr_t, making the new block SIZE bytes long. */
|
||||||
|
extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size));
|
||||||
|
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
|
||||||
|
extern __ptr_t calloc __P ((size_t __nmemb, size_t __size));
|
||||||
|
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
|
||||||
|
extern void free __P ((__ptr_t __ptr));
|
||||||
|
|
||||||
|
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
|
||||||
|
extern __ptr_t memalign __P ((size_t __alignment, size_t __size));
|
||||||
|
|
||||||
|
/* Allocate SIZE bytes on a page boundary. */
|
||||||
|
extern __ptr_t valloc __P ((size_t __size));
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MALLOC_INTERNAL
|
||||||
|
|
||||||
|
/* The allocator divides the heap into blocks of fixed size; large
|
||||||
|
requests receive one or more whole blocks, and small requests
|
||||||
|
receive a fragment of a block. Fragment sizes are powers of two,
|
||||||
|
and all fragments of a block are the same size. When all the
|
||||||
|
fragments in a block have been freed, the block itself is freed. */
|
||||||
|
#define INT_BIT (CHAR_BIT * sizeof(int))
|
||||||
|
#define BLOCKLOG (INT_BIT > 16 ? 12 : 9)
|
||||||
|
#define BLOCKSIZE (1 << BLOCKLOG)
|
||||||
|
#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE)
|
||||||
|
|
||||||
|
/* Determine the amount of memory spanned by the initial heap table
|
||||||
|
(not an absolute limit). */
|
||||||
|
#define HEAP (INT_BIT > 16 ? 4194304 : 65536)
|
||||||
|
|
||||||
|
/* Number of contiguous free blocks allowed to build up at the end of
|
||||||
|
memory before they will be returned to the system. */
|
||||||
|
#define FINAL_FREE_BLOCKS 8
|
||||||
|
|
||||||
|
/* Data structure giving per-block information. */
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
/* Heap information for a busy block. */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/* Zero for a large block, or positive giving the
|
||||||
|
logarithm to the base two of the fragment size. */
|
||||||
|
int type;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
__malloc_size_t nfree; /* Free frags in a fragmented block. */
|
||||||
|
__malloc_size_t first; /* First free fragment of the block. */
|
||||||
|
} frag;
|
||||||
|
/* Size (in blocks) of a large cluster. */
|
||||||
|
__malloc_size_t size;
|
||||||
|
} info;
|
||||||
|
} busy;
|
||||||
|
/* Heap information for a free block
|
||||||
|
(that may be the first of a free cluster). */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
__malloc_size_t size; /* Size (in blocks) of a free cluster. */
|
||||||
|
__malloc_size_t next; /* Index of next free cluster. */
|
||||||
|
__malloc_size_t prev; /* Index of previous free cluster. */
|
||||||
|
} free;
|
||||||
|
} malloc_info;
|
||||||
|
|
||||||
|
/* Pointer to first block of the heap. */
|
||||||
|
extern char *_heapbase;
|
||||||
|
|
||||||
|
/* Table indexed by block number giving per-block information. */
|
||||||
|
extern malloc_info *_heapinfo;
|
||||||
|
|
||||||
|
/* Address to block number and vice versa. */
|
||||||
|
#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1)
|
||||||
|
#define ADDRESS(B) ((__ptr_t) (((B) - 1) * BLOCKSIZE + _heapbase))
|
||||||
|
|
||||||
|
/* Current search index for the heap table. */
|
||||||
|
extern __malloc_size_t _heapindex;
|
||||||
|
|
||||||
|
/* Limit of valid info table indices. */
|
||||||
|
extern __malloc_size_t _heaplimit;
|
||||||
|
|
||||||
|
/* Doubly linked lists of free fragments. */
|
||||||
|
struct list
|
||||||
|
{
|
||||||
|
struct list *next;
|
||||||
|
struct list *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Free list headers for each fragment size. */
|
||||||
|
extern struct list _fraghead[];
|
||||||
|
|
||||||
|
/* List of blocks allocated with `memalign' (or `valloc'). */
|
||||||
|
struct alignlist
|
||||||
|
{
|
||||||
|
struct alignlist *next;
|
||||||
|
__ptr_t aligned; /* The address that memaligned returned. */
|
||||||
|
__ptr_t exact; /* The address that malloc returned. */
|
||||||
|
};
|
||||||
|
extern struct alignlist *_aligned_blocks;
|
||||||
|
|
||||||
|
/* Instrumentation. */
|
||||||
|
extern __malloc_size_t _chunks_used;
|
||||||
|
extern __malloc_size_t _bytes_used;
|
||||||
|
extern __malloc_size_t _chunks_free;
|
||||||
|
extern __malloc_size_t _bytes_free;
|
||||||
|
|
||||||
|
/* Internal version of `free' used in `morecore' (malloc.c). */
|
||||||
|
extern void _free_internal __P ((__ptr_t __ptr));
|
||||||
|
|
||||||
|
#endif /* _MALLOC_INTERNAL. */
|
||||||
|
|
||||||
|
/* Underlying allocation function; successive calls should
|
||||||
|
return contiguous pieces of memory. */
|
||||||
|
extern __ptr_t (*__morecore) __P ((ptrdiff_t __size));
|
||||||
|
|
||||||
|
/* Default value of `__morecore'. */
|
||||||
|
extern __ptr_t __default_morecore __P ((ptrdiff_t __size));
|
||||||
|
|
||||||
|
/* If not NULL, this function is called after each time
|
||||||
|
`__morecore' is called to increase the data size. */
|
||||||
|
extern void (*__after_morecore_hook) __P ((void));
|
||||||
|
|
||||||
|
/* Nonzero if `malloc' has been called and done its initialization. */
|
||||||
|
extern int __malloc_initialized;
|
||||||
|
|
||||||
|
/* Hooks for debugging versions. */
|
||||||
|
extern void (*__free_hook) __P ((__ptr_t __ptr));
|
||||||
|
extern __ptr_t (*__malloc_hook) __P ((size_t __size));
|
||||||
|
extern __ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, size_t __size));
|
||||||
|
|
||||||
|
/* Return values for `mprobe': these are the kinds of inconsistencies that
|
||||||
|
`mcheck' enables detection of. */
|
||||||
|
enum mcheck_status
|
||||||
|
{
|
||||||
|
MCHECK_DISABLED = -1, /* Consistency checking is not turned on. */
|
||||||
|
MCHECK_OK, /* Block is fine. */
|
||||||
|
MCHECK_FREE, /* Block freed twice. */
|
||||||
|
MCHECK_HEAD, /* Memory before the block was clobbered. */
|
||||||
|
MCHECK_TAIL /* Memory after the block was clobbered. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Activate a standard collection of debugging hooks. This must be called
|
||||||
|
before `malloc' is ever called. ABORTFUNC is called with an error code
|
||||||
|
(see enum above) when an inconsistency is detected. If ABORTFUNC is
|
||||||
|
null, the standard function prints on stderr and then calls `abort'. */
|
||||||
|
extern int mcheck __P ((void (*__abortfunc) __P ((enum mcheck_status))));
|
||||||
|
|
||||||
|
/* Check for aberrations in a particular malloc'd block. You must have
|
||||||
|
called `mcheck' already. These are the same checks that `mcheck' does
|
||||||
|
when you free or reallocate a block. */
|
||||||
|
extern enum mcheck_status mprobe __P ((__ptr_t __ptr));
|
||||||
|
|
||||||
|
/* Activate a standard collection of tracing hooks. */
|
||||||
|
extern void mtrace __P ((void));
|
||||||
|
extern void muntrace __P ((void));
|
||||||
|
|
||||||
|
/* Statistics available to the user. */
|
||||||
|
struct mstats
|
||||||
|
{
|
||||||
|
__malloc_size_t bytes_total; /* Total size of the heap. */
|
||||||
|
__malloc_size_t chunks_used; /* Chunks allocated by the user. */
|
||||||
|
__malloc_size_t bytes_used; /* Byte total of user-allocated chunks. */
|
||||||
|
__malloc_size_t chunks_free; /* Chunks in the free list. */
|
||||||
|
__malloc_size_t bytes_free; /* Byte total of chunks in the free list. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Pick up the current statistics. */
|
||||||
|
extern struct mstats mstats __P ((void));
|
||||||
|
|
||||||
|
/* Call WARNFUN with a warning message when memory usage is high. */
|
||||||
|
extern void memory_warnings __P ((__ptr_t __start,
|
||||||
|
void (*__warnfun) __P ((const char *))));
|
||||||
|
|
||||||
|
|
||||||
|
/* Relocating allocator. */
|
||||||
|
|
||||||
|
/* Allocate SIZE bytes, and store the address in *HANDLEPTR. */
|
||||||
|
extern __ptr_t r_alloc __P ((__ptr_t *__handleptr, size_t __size));
|
||||||
|
|
||||||
|
/* Free the storage allocated in HANDLEPTR. */
|
||||||
|
extern void r_alloc_free __P ((__ptr_t *__handleptr));
|
||||||
|
|
||||||
|
/* Adjust the block at HANDLEPTR to be SIZE bytes long. */
|
||||||
|
extern __ptr_t r_re_alloc __P ((__ptr_t *__handleptr, size_t __size));
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* malloc.h */
|
|
@ -0,0 +1,285 @@
|
||||||
|
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ANSI Standard: 4.5 MATHEMATICS <math.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MATH_H
|
||||||
|
#define _MATH_H 1
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <defs.h>
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
#define __need_Emath
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* Get machine-dependent HUGE_VAL value (returned on overflow). */
|
||||||
|
#include <huge_val.h>
|
||||||
|
|
||||||
|
/* Get machine-dependent NAN value (returned for some domain errors). */
|
||||||
|
#ifdef __USE_GNU
|
||||||
|
#include <nan.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Trigonometric functions. */
|
||||||
|
|
||||||
|
/* Arc cosine of X. */
|
||||||
|
extern __CONSTVALUE double acos __P ((double __x));
|
||||||
|
/* Arc sine of X. */
|
||||||
|
extern __CONSTVALUE double asin __P ((double __x));
|
||||||
|
/* Arc tangent of X. */
|
||||||
|
extern __CONSTVALUE double atan __P ((double __x));
|
||||||
|
/* Arc tangent of Y/X. */
|
||||||
|
extern __CONSTVALUE double atan2 __P ((double __y, double __x));
|
||||||
|
|
||||||
|
/* Cosine of X. */
|
||||||
|
extern __CONSTVALUE double cos __P ((double __x));
|
||||||
|
/* Sine of X. */
|
||||||
|
extern __CONSTVALUE double sin __P ((double __x));
|
||||||
|
extern __CONSTVALUE double _sin __P ((double __x));
|
||||||
|
/* Tangent of X. */
|
||||||
|
extern __CONSTVALUE double tan __P ((double __x));
|
||||||
|
|
||||||
|
|
||||||
|
/* Hyperbolic functions. */
|
||||||
|
|
||||||
|
/* Hyperbolic cosine of X. */
|
||||||
|
extern __CONSTVALUE double cosh __P ((double __x));
|
||||||
|
/* Hyperbolic sine of X. */
|
||||||
|
extern __CONSTVALUE double sinh __P ((double __x));
|
||||||
|
/* Hyperbolic tangent of X. */
|
||||||
|
extern __CONSTVALUE double tanh __P ((double __x));
|
||||||
|
|
||||||
|
#ifdef __USE_MISC
|
||||||
|
/* Hyperbolic arc cosine of X. */
|
||||||
|
extern __CONSTVALUE double acosh __P ((double __x));
|
||||||
|
/* Hyperbolic arc sine of X. */
|
||||||
|
extern __CONSTVALUE double asinh __P ((double __x));
|
||||||
|
/* Hyperbolic arc tangent of X. */
|
||||||
|
extern __CONSTVALUE double atanh __P ((double __x));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exponential and logarithmic functions. */
|
||||||
|
|
||||||
|
/* Exponentional function of X. */
|
||||||
|
extern __CONSTVALUE double exp __P ((double __x));
|
||||||
|
|
||||||
|
/* Break VALUE into a normalized fraction and an integral power of 2. */
|
||||||
|
extern double frexp __P ((double __value, int *__exp));
|
||||||
|
|
||||||
|
/* X times (two to the EXP power). */
|
||||||
|
extern __CONSTVALUE double ldexp __P ((double __x, int __exp));
|
||||||
|
|
||||||
|
/* Natural logarithm of X. */
|
||||||
|
extern __CONSTVALUE double log __P ((double __x));
|
||||||
|
|
||||||
|
/* Base-ten logarithm of X. */
|
||||||
|
extern __CONSTVALUE double log10 __P ((double __x));
|
||||||
|
|
||||||
|
#ifdef __USE_MISC
|
||||||
|
/* Return exp(X) - 1. */
|
||||||
|
extern __CONSTVALUE double __expm1 __P ((double __x));
|
||||||
|
extern __CONSTVALUE double expm1 __P ((double __x));
|
||||||
|
|
||||||
|
/* Return log(1 + X). */
|
||||||
|
extern __CONSTVALUE double log1p __P ((double __x));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Break VALUE into integral and fractional parts. */
|
||||||
|
extern double modf __P ((double __value, double *__iptr));
|
||||||
|
|
||||||
|
|
||||||
|
/* Power functions. */
|
||||||
|
|
||||||
|
/* Return X to the Y power. */
|
||||||
|
extern __CONSTVALUE double pow __P ((double __x, double __y));
|
||||||
|
|
||||||
|
/* Return the square root of X. */
|
||||||
|
extern __CONSTVALUE double sqrt __P ((double __x));
|
||||||
|
|
||||||
|
#ifdef __USE_MISC
|
||||||
|
/* Return the cube root of X. */
|
||||||
|
extern __CONSTVALUE double cbrt __P ((double __x));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Nearest integer, absolute value, and remainder functions. */
|
||||||
|
|
||||||
|
/* Smallest integral value not less than X. */
|
||||||
|
extern __CONSTVALUE double ceil __P ((double __x));
|
||||||
|
|
||||||
|
/* Absolute value of X. */
|
||||||
|
extern __CONSTVALUE double fabs __P ((double __x));
|
||||||
|
|
||||||
|
/* Largest integer not greater than X. */
|
||||||
|
extern __CONSTVALUE double floor __P ((double __x));
|
||||||
|
|
||||||
|
/* Floating-point modulo remainder of X/Y. */
|
||||||
|
extern __CONSTVALUE double fmod __P ((double __x, double __y));
|
||||||
|
|
||||||
|
|
||||||
|
/* Return 0 if VALUE is finite or NaN, +1 if it
|
||||||
|
is +Infinity, -1 if it is -Infinity. */
|
||||||
|
extern __CONSTVALUE int __isinf __P ((double __value));
|
||||||
|
|
||||||
|
/* Return nonzero if VALUE is not a number. */
|
||||||
|
extern __CONSTVALUE int __isnan __P ((double __value));
|
||||||
|
|
||||||
|
/* Return nonzero if VALUE is finite and not NaN. */
|
||||||
|
extern __CONSTVALUE int __finite __P ((double __value));
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
#define __finite(value) (!__isinf(value))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Deal with an infinite or NaN result.
|
||||||
|
If ERROR is ERANGE, result is +Inf;
|
||||||
|
if ERROR is - ERANGE, result is -Inf;
|
||||||
|
otherwise result is NaN.
|
||||||
|
This will set `errno' to either ERANGE or EDOM,
|
||||||
|
and may return an infinity or NaN, or may do something else. */
|
||||||
|
extern double __infnan __P ((int __error));
|
||||||
|
|
||||||
|
/* Return X with its signed changed to Y's. */
|
||||||
|
extern __CONSTVALUE double __copysign __P ((double __x, double __y));
|
||||||
|
|
||||||
|
/* Return X times (2 to the Nth power). */
|
||||||
|
extern __CONSTVALUE double __scalb __P ((double __x, int __n));
|
||||||
|
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
#define __scalb(x, n) ldexp ((x), (n))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return the remainder of X/Y. */
|
||||||
|
extern __CONSTVALUE double __drem __P ((double __x, double __y));
|
||||||
|
|
||||||
|
/* Return the base 2 signed integral exponent of X. */
|
||||||
|
extern __CONSTVALUE double __logb __P ((double __x));
|
||||||
|
|
||||||
|
#ifdef __USE_MISC
|
||||||
|
|
||||||
|
/* Return the integer nearest X in the direction of the
|
||||||
|
prevailing rounding mode. */
|
||||||
|
extern __CONSTVALUE double __rint __P ((double __x));
|
||||||
|
extern __CONSTVALUE double rint __P ((double __x));
|
||||||
|
|
||||||
|
/* Return `sqrt(X*X + Y*Y)'. */
|
||||||
|
extern __CONSTVALUE double hypot __P ((double __x, double __y));
|
||||||
|
|
||||||
|
struct __cabs_complex
|
||||||
|
{
|
||||||
|
double __x, __y;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Return `sqrt(X*X + Y*Y)'. */
|
||||||
|
extern __CONSTVALUE double cabs __P ((struct __cabs_complex));
|
||||||
|
|
||||||
|
extern __CONSTVALUE int isinf __P ((double __value));
|
||||||
|
extern __CONSTVALUE int isnan __P ((double __value));
|
||||||
|
extern __CONSTVALUE int finite __P ((double __value));
|
||||||
|
extern __CONSTVALUE double infnan __P ((int __error));
|
||||||
|
extern __CONSTVALUE double copysign __P ((double __x, double __y));
|
||||||
|
extern __CONSTVALUE double scalb __P ((double __x, int __n));
|
||||||
|
extern __CONSTVALUE double drem __P ((double __x, double __y));
|
||||||
|
extern __CONSTVALUE double logb __P ((double __x));
|
||||||
|
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
#define isinf(value) __isinf(value)
|
||||||
|
#define isnan(value) __isnan(value)
|
||||||
|
#define infnan(error) __infnan(error)
|
||||||
|
#define finite(value) __finite(value)
|
||||||
|
#define copysign(x, y) __copysign((x), (y))
|
||||||
|
#define scalb(x, n) __scalb((x), (n))
|
||||||
|
#define drem(x, y) __drem((x), (y))
|
||||||
|
#define logb(x) __logb(x)
|
||||||
|
#endif /* Optimizing. */
|
||||||
|
|
||||||
|
#endif /* Use misc. */
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* The "Future Library Directions" section of the
|
||||||
|
ANSI Standard reserves these as `float' and
|
||||||
|
`long double' versions of the above functions. */
|
||||||
|
|
||||||
|
extern __CONSTVALUE float acosf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float asinf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float atanf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float atan2f __P ((float __y, float __x));
|
||||||
|
extern __CONSTVALUE float cosf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float sinf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float tanf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float coshf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float sinhf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float tanhf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float expf __P ((float __x));
|
||||||
|
extern float frexpf __P ((float __value, int *__exp));
|
||||||
|
extern __CONSTVALUE float ldexpf __P ((float __x, int __exp));
|
||||||
|
extern __CONSTVALUE float logf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float log10f __P ((float __x));
|
||||||
|
extern float modff __P ((float __value, float *__iptr));
|
||||||
|
extern __CONSTVALUE float powf __P ((float __x, float __y));
|
||||||
|
extern __CONSTVALUE float sqrtf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float ceilf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float fabsf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float floorf __P ((float __x));
|
||||||
|
extern __CONSTVALUE float fmodf __P ((float __x, float __y));
|
||||||
|
|
||||||
|
extern __CONSTVALUE __long_double_t acosl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t asinl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t atanl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t atan2l __P ((__long_double_t __y, __long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t cosl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t sinl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t tanl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t coshl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t sinhl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t tanhl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t expl __P ((__long_double_t __x));
|
||||||
|
extern __long_double_t frexpl __P ((__long_double_t __value, int *__exp));
|
||||||
|
extern __CONSTVALUE __long_double_t ldexpl __P ((__long_double_t __x, int __exp));
|
||||||
|
extern __CONSTVALUE __long_double_t logl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t log10l __P ((__long_double_t __x));
|
||||||
|
extern __long_double_t modfl __P ((__long_double_t __value, __long_double_t * __ip));
|
||||||
|
extern __CONSTVALUE __long_double_t powl __P ((__long_double_t __x, __long_double_t __y));
|
||||||
|
extern __CONSTVALUE __long_double_t sqrtl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t ceill __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t fabsl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t floorl __P ((__long_double_t __x));
|
||||||
|
extern __CONSTVALUE __long_double_t fmodl __P ((__long_double_t __x, __long_double_t __y));
|
||||||
|
#endif /* 0 */
|
||||||
|
|
||||||
|
/* Get machine-dependent inline versions (if there are any). */
|
||||||
|
/*
|
||||||
|
#include <__math.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* math.h */
|
|
@ -0,0 +1,165 @@
|
||||||
|
/* memcopy.h -- definitions for memory copy functions. Generic C version.
|
||||||
|
Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||||
|
Contributed by Torbjorn Granlund (tege@sics.se).
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
/* The strategy of the memory functions is:
|
||||||
|
|
||||||
|
1. Copy bytes until the destination pointer is aligned.
|
||||||
|
|
||||||
|
2. Copy words in unrolled loops. If the source and destination
|
||||||
|
are not aligned in the same way, use word memory operations,
|
||||||
|
but shift and merge two read words before writing.
|
||||||
|
|
||||||
|
3. Copy the few remaining bytes.
|
||||||
|
|
||||||
|
This is fast on processors that have at least 10 registers for
|
||||||
|
allocation by GCC, and that can access memory at reg+const in one
|
||||||
|
instruction.
|
||||||
|
|
||||||
|
I made an "exhaustive" test of this memmove when I wrote it,
|
||||||
|
exhaustive in the sense that I tried all alignment and length
|
||||||
|
combinations, with and without overlap. */
|
||||||
|
|
||||||
|
#ifndef _MEMCPY_H_
|
||||||
|
#define _MEMCPY_H_
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#include <endian.h>
|
||||||
|
|
||||||
|
/* The macros defined in this file are:
|
||||||
|
|
||||||
|
BYTE_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_to_copy)
|
||||||
|
|
||||||
|
BYTE_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_to_copy)
|
||||||
|
|
||||||
|
WORD_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_remaining, nbytes_to_copy)
|
||||||
|
|
||||||
|
WORD_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_remaining, nbytes_to_copy)
|
||||||
|
|
||||||
|
MERGE(old_word, sh_1, new_word, sh_2)
|
||||||
|
[I fail to understand. I feel stupid. --roland]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Type to use for aligned memory operations.
|
||||||
|
This should normally be the biggest type supported by a single load
|
||||||
|
and store. */
|
||||||
|
#define op_t unsigned long int
|
||||||
|
#define OPSIZ (sizeof(op_t))
|
||||||
|
|
||||||
|
|
||||||
|
/* Type to use for unaligned operations. */
|
||||||
|
typedef unsigned char byte;
|
||||||
|
|
||||||
|
/* Optimal type for storing bytes in registers. */
|
||||||
|
#define reg_char char
|
||||||
|
|
||||||
|
#undef TESTME
|
||||||
|
|
||||||
|
#ifndef MERGE
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||||
|
//#define TESTME
|
||||||
|
#define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
#ifndef TESTME
|
||||||
|
#define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2)))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif //MERGE
|
||||||
|
|
||||||
|
|
||||||
|
/* Copy exactly NBYTES bytes from SRC_BP to DST_BP,
|
||||||
|
without any assumptions about alignment of the pointers. */
|
||||||
|
#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
size_t __nbytes = (nbytes); \
|
||||||
|
while (__nbytes > 0) \
|
||||||
|
{ \
|
||||||
|
byte __x = ((byte *) src_bp)[0]; \
|
||||||
|
src_bp += 1; \
|
||||||
|
__nbytes -= 1; \
|
||||||
|
((byte *) dst_bp)[0] = __x; \
|
||||||
|
dst_bp += 1; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* Copy exactly NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
|
||||||
|
beginning at the bytes right before the pointers and continuing towards
|
||||||
|
smaller addresses. Don't assume anything about alignment of the
|
||||||
|
pointers. */
|
||||||
|
#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
size_t __nbytes = (nbytes); \
|
||||||
|
while (__nbytes > 0) \
|
||||||
|
{ \
|
||||||
|
byte __x; \
|
||||||
|
src_ep -= 1; \
|
||||||
|
__x = ((byte *) src_ep)[0]; \
|
||||||
|
dst_ep -= 1; \
|
||||||
|
__nbytes -= 1; \
|
||||||
|
((byte *) dst_ep)[0] = __x; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with
|
||||||
|
the assumption that DST_BP is aligned on an OPSIZ multiple. If
|
||||||
|
not all bytes could be easily copied, store remaining number of bytes
|
||||||
|
in NBYTES_LEFT, otherwise store 0. */
|
||||||
|
extern void _wordcopy_fwd_aligned __P ((long int, long int, size_t));
|
||||||
|
extern void _wordcopy_fwd_dest_aligned __P ((long int, long int, size_t));
|
||||||
|
#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (src_bp % OPSIZ == 0) \
|
||||||
|
_wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
|
||||||
|
else \
|
||||||
|
_wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \
|
||||||
|
src_bp += (nbytes) & NEGU32(OPSIZ); \
|
||||||
|
dst_bp += (nbytes) & NEGU32(OPSIZ); \
|
||||||
|
(nbytes_left) = (nbytes) % OPSIZ; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
|
||||||
|
beginning at the words (of type op_t) right before the pointers and
|
||||||
|
continuing towards smaller addresses. May take advantage of that
|
||||||
|
DST_END_PTR is aligned on an OPSIZ multiple. If not all bytes could be
|
||||||
|
easily copied, store remaining number of bytes in NBYTES_REMAINING,
|
||||||
|
otherwise store 0. */
|
||||||
|
extern void _wordcopy_bwd_aligned __P ((long int, long int, size_t));
|
||||||
|
extern void _wordcopy_bwd_dest_aligned __P ((long int, long int, size_t));
|
||||||
|
#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (src_ep % OPSIZ == 0) \
|
||||||
|
_wordcopy_bwd_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
|
||||||
|
else \
|
||||||
|
_wordcopy_bwd_dest_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \
|
||||||
|
src_ep -= (nbytes) & NEGU32(OPSIZ); \
|
||||||
|
dst_ep -= (nbytes) & NEGU32(OPSIZ); \
|
||||||
|
(nbytes_left) = (nbytes) % OPSIZ; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* Threshold value for when to enter the unrolled loops. */
|
||||||
|
#define OP_T_THRES 16
|
||||||
|
|
||||||
|
#endif //_MEMCPY_H_
|
|
@ -0,0 +1,226 @@
|
||||||
|
/* Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#ifndef _SYS_CDEFS_H
|
||||||
|
#define _SYS_CDEFS_H 1
|
||||||
|
|
||||||
|
/* We are almost always included from features.h. */
|
||||||
|
#ifndef _FEATURES_H
|
||||||
|
# include <features.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The GNU libc does not support any K&R compilers or the traditional mode
|
||||||
|
of ISO C compilers anymore. Check for some of the combinations not
|
||||||
|
anymore supported. */
|
||||||
|
#if defined __GNUC__ && !defined __STDC__
|
||||||
|
# error "You need a ISO C conforming compiler to use the glibc headers"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some user header file might have defined this before. */
|
||||||
|
#undef __P
|
||||||
|
#undef __PMT
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
|
||||||
|
/* GCC can always grok prototypes. For C++ programs we add throw()
|
||||||
|
to help it optimize the function calls. But this works only with
|
||||||
|
gcc 2.8.x and egcs. */
|
||||||
|
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||||
|
# define __THROW throw ()
|
||||||
|
# else
|
||||||
|
# define __THROW
|
||||||
|
# endif
|
||||||
|
# define __P(args) args __THROW
|
||||||
|
/* This macro will be used for functions which might take C++ callback
|
||||||
|
functions. */
|
||||||
|
# define __PMT(args) args
|
||||||
|
|
||||||
|
#else /* Not GCC. */
|
||||||
|
|
||||||
|
# define __inline /* No inline functions. */
|
||||||
|
|
||||||
|
# define __THROW
|
||||||
|
# define __P(args) args
|
||||||
|
# define __PMT(args) args
|
||||||
|
|
||||||
|
# define __const const
|
||||||
|
# define __signed signed
|
||||||
|
# define __volatile volatile
|
||||||
|
|
||||||
|
#endif /* GCC. */
|
||||||
|
|
||||||
|
/* For these things, GCC behaves the ANSI way normally,
|
||||||
|
and the non-ANSI way under -traditional. */
|
||||||
|
|
||||||
|
#define __CONCAT(x,y) x ## y
|
||||||
|
#define __STRING(x) #x
|
||||||
|
|
||||||
|
/* This is not a typedef so `const __ptr_t' does the right thing. */
|
||||||
|
#define __ptr_t void *
|
||||||
|
#define __long_double_t long double
|
||||||
|
|
||||||
|
|
||||||
|
/* C++ needs to know that types and declarations are C, not C++. */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# define __BEGIN_DECLS extern "C" {
|
||||||
|
# define __END_DECLS }
|
||||||
|
#else
|
||||||
|
# define __BEGIN_DECLS
|
||||||
|
# define __END_DECLS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Support for bounded pointers. */
|
||||||
|
#ifndef __BOUNDED_POINTERS__
|
||||||
|
# define __bounded /* nothing */
|
||||||
|
# define __unbounded /* nothing */
|
||||||
|
# define __ptrvalue /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Support for flexible arrays. */
|
||||||
|
#if __GNUC_PREREQ (2,97)
|
||||||
|
/* GCC 2.97 supports C99 flexible array members. */
|
||||||
|
# define __flexarr []
|
||||||
|
#else
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# define __flexarr [0]
|
||||||
|
# else
|
||||||
|
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||||
|
# define __flexarr []
|
||||||
|
# else
|
||||||
|
/* Some other non-C99 compiler. Approximate with [1]. */
|
||||||
|
# define __flexarr [1]
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* __asm__ ("xyz") is used throughout the headers to rename functions
|
||||||
|
at the assembly language level. This is wrapped by the __REDIRECT
|
||||||
|
macro, in order to support compilers that can do this some other
|
||||||
|
way. When compilers don't support asm-names at all, we have to do
|
||||||
|
preprocessor tricks instead (which don't have exactly the right
|
||||||
|
semantics, but it's the best we can do).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
|
||||||
|
|
||||||
|
#if defined __GNUC__ && __GNUC__ >= 2
|
||||||
|
|
||||||
|
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
|
||||||
|
# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
|
||||||
|
# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
|
||||||
|
|
||||||
|
/*
|
||||||
|
#elif __SOME_OTHER_COMPILER__
|
||||||
|
|
||||||
|
# define __REDIRECT(name, proto, alias) name proto; \
|
||||||
|
_Pragma("let " #name " = " #alias)
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* GCC has various useful declarations that can be made with the
|
||||||
|
`__attribute__' syntax. All of the ways we use this do fine if
|
||||||
|
they are omitted for compilers that don't understand it. */
|
||||||
|
#if !defined __GNUC__ || __GNUC__ < 2
|
||||||
|
# define __attribute__(xyz) /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* At some point during the gcc 2.96 development the `malloc' attribute
|
||||||
|
for functions was introduced. We don't want to use it unconditionally
|
||||||
|
(although this would be possible) since it generates warnings. */
|
||||||
|
#if __GNUC_PREREQ (2,96)
|
||||||
|
# define __attribute_malloc__ __attribute__ ((__malloc__))
|
||||||
|
#else
|
||||||
|
# define __attribute_malloc__ /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* At some point during the gcc 2.96 development the `pure' attribute
|
||||||
|
for functions was introduced. We don't want to use it unconditionally
|
||||||
|
(although this would be possible) since it generates warnings. */
|
||||||
|
#if __GNUC_PREREQ (2,96)
|
||||||
|
# define __attribute_pure__ __attribute__ ((__pure__))
|
||||||
|
#else
|
||||||
|
# define __attribute_pure__ /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* At some point during the gcc 3.1 development the `used' attribute
|
||||||
|
for functions was introduced. We don't want to use it unconditionally
|
||||||
|
(although this would be possible) since it generates warnings. */
|
||||||
|
#if __GNUC_PREREQ (3,1)
|
||||||
|
# define __attribute_used__ __attribute__ ((__used__))
|
||||||
|
#else
|
||||||
|
# define __attribute_used__ __attribute__ ((__unused__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* At some point during the gcc 2.8 development the `format_arg' attribute
|
||||||
|
for functions was introduced. We don't want to use it unconditionally
|
||||||
|
(although this would be possible) since it generates warnings.
|
||||||
|
If several `format_arg' attributes are given for the same function, in
|
||||||
|
gcc-3.0 and older, all but the last one are ignored. In newer gccs,
|
||||||
|
all designated arguments are considered. */
|
||||||
|
#if __GNUC_PREREQ (2,8)
|
||||||
|
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
|
||||||
|
#else
|
||||||
|
# define __attribute_format_arg__(x) /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* At some point during the gcc 2.97 development the `strfmon' format
|
||||||
|
attribute for functions was introduced. We don't want to use it
|
||||||
|
unconditionally (although this would be possible) since it
|
||||||
|
generates warnings. */
|
||||||
|
#if __GNUC_PREREQ (2,97)
|
||||||
|
# define __attribute_format_strfmon__(a,b) \
|
||||||
|
__attribute__ ((__format__ (__strfmon__, a, b)))
|
||||||
|
#else
|
||||||
|
# define __attribute_format_strfmon__(a,b) /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* It is possible to compile containing GCC extensions even if GCC is
|
||||||
|
run in pedantic mode if the uses are carefully marked using the
|
||||||
|
`__extension__' keyword. But this is not generally available before
|
||||||
|
version 2.8. */
|
||||||
|
#if !__GNUC_PREREQ (2,8)
|
||||||
|
# define __extension__ /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* __restrict is known in EGCS 1.2 and above. */
|
||||||
|
#if !__GNUC_PREREQ (2,92)
|
||||||
|
# define __restrict /* Ignore */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
|
||||||
|
array_name[restrict]
|
||||||
|
GCC 3.1 supports this. */
|
||||||
|
#if __GNUC_PREREQ (3,1) && !defined __GNUG__
|
||||||
|
# define __restrict_arr __restrict
|
||||||
|
#else
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# define __restrict_arr /* Not supported in old GCC. */
|
||||||
|
# else
|
||||||
|
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||||
|
# define __restrict_arr restrict
|
||||||
|
# else
|
||||||
|
/* Some other non-C99 compiler. */
|
||||||
|
# define __restrict_arr /* Not supported. */
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* sys/cdefs.h */
|
|
@ -0,0 +1,88 @@
|
||||||
|
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
|
||||||
|
#ifndef __dj_include_stdarg_h_
|
||||||
|
#define __dj_include_stdarg_h_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(push,8)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _VA_LIST_DEFINED
|
||||||
|
#ifdef _M_ALPHA
|
||||||
|
typedef struct {
|
||||||
|
char *a0; /* pointer to first homed integer argument */
|
||||||
|
int offset; /* byte offset of next parameter */
|
||||||
|
} va_list;
|
||||||
|
#else
|
||||||
|
typedef char * va_list;
|
||||||
|
#endif
|
||||||
|
#define _VA_LIST_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
|
||||||
|
|
||||||
|
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
|
||||||
|
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
|
||||||
|
#define va_end(ap) ( ap = (va_list)0 )
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __dj_ENFORCE_ANSI_FREESTANDING
|
||||||
|
|
||||||
|
#ifdef __dj_include_varargs_h_
|
||||||
|
#error stdarg.h and varargs.h are mutually exclusive
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/djtypes.h>
|
||||||
|
|
||||||
|
__DJ_va_list
|
||||||
|
#undef __DJ_va_list
|
||||||
|
#define __DJ_va_list
|
||||||
|
|
||||||
|
#define __dj_va_rounded_size(T) \
|
||||||
|
(((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
|
||||||
|
|
||||||
|
#define va_arg(ap, T) \
|
||||||
|
(ap = (va_list) ((char *) (ap) + __dj_va_rounded_size (T)), \
|
||||||
|
*((T *) (void *) ((char *) (ap) - __dj_va_rounded_size (T))))
|
||||||
|
|
||||||
|
#define va_end(ap)
|
||||||
|
|
||||||
|
#define va_start(ap, last_arg) \
|
||||||
|
(ap = ((va_list) __builtin_next_arg (last_arg)))
|
||||||
|
|
||||||
|
#ifndef __STRICT_ANSI__
|
||||||
|
|
||||||
|
#ifndef _POSIX_SOURCE
|
||||||
|
|
||||||
|
#endif // !_POSIX_SOURCE
|
||||||
|
#endif // !__STRICT_ANSI__
|
||||||
|
#endif // !__dj_ENFORCE_ANSI_FREESTANDING
|
||||||
|
|
||||||
|
#ifndef __dj_ENFORCE_FUNCTION_CALLS
|
||||||
|
#endif //!__dj_ENFORCE_FUNCTION_CALLS
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !__dj_include_stdarg_h_ */
|
|
@ -0,0 +1,330 @@
|
||||||
|
#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
|
||||||
|
&& !defined(__STDDEF_H__)) \
|
||||||
|
|| defined(__need_wchar_t) || defined(__need_size_t) \
|
||||||
|
|| defined(__need_ptrdiff_t) || defined(__need_NULL) \
|
||||||
|
|| defined(__need_wint_t)
|
||||||
|
|
||||||
|
/* Any one of these symbols __need_* means that GNU libc
|
||||||
|
wants us just to define one data type. So don't define
|
||||||
|
the symbols that indicate this file's entire job has been done. */
|
||||||
|
#if (!defined(__need_wchar_t) && !defined(__need_size_t) \
|
||||||
|
&& !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
|
||||||
|
&& !defined(__need_wint_t))
|
||||||
|
#define _STDDEF_H
|
||||||
|
#define _STDDEF_H_
|
||||||
|
/* snaroff@next.com says the NeXT needs this. */
|
||||||
|
#define _ANSI_STDDEF_H
|
||||||
|
/* Irix 5.1 needs this. */
|
||||||
|
#define __STDDEF_H__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __sys_stdtypes_h
|
||||||
|
/* This avoids lossage on SunOS but only if stdtypes.h comes first.
|
||||||
|
There's no way to win with the other order! Sun lossage. */
|
||||||
|
|
||||||
|
/* On 4.3bsd-net2, make sure ansi.h is included, so we have
|
||||||
|
one less case to deal with in the following. */
|
||||||
|
#if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__)
|
||||||
|
#include <machine/ansi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
|
||||||
|
defined if the corresponding type is *not* defined.
|
||||||
|
FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */
|
||||||
|
#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
|
||||||
|
#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
|
||||||
|
#define _SIZE_T_
|
||||||
|
#endif
|
||||||
|
#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
|
||||||
|
#define _PTRDIFF_T_
|
||||||
|
#endif
|
||||||
|
/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
|
||||||
|
instead of _WCHAR_T_. */
|
||||||
|
#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
|
||||||
|
#ifndef _BSD_WCHAR_T_
|
||||||
|
#define _WCHAR_T
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/* Undef _FOO_T_ if we are supposed to define foo_t. */
|
||||||
|
#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
|
||||||
|
#undef _PTRDIFF_T_
|
||||||
|
#undef _BSD_PTRDIFF_T_
|
||||||
|
#endif
|
||||||
|
#if defined (__need_size_t) || defined (_STDDEF_H_)
|
||||||
|
#undef _SIZE_T_
|
||||||
|
#undef _BSD_SIZE_T_
|
||||||
|
#endif
|
||||||
|
#if defined (__need_wchar_t) || defined (_STDDEF_H_)
|
||||||
|
#undef _WCHAR_T_
|
||||||
|
#undef _BSD_WCHAR_T_
|
||||||
|
#endif
|
||||||
|
#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
|
||||||
|
|
||||||
|
/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
|
||||||
|
Just ignore it. */
|
||||||
|
#if defined (__sequent__) && defined (_PTRDIFF_T_)
|
||||||
|
#undef _PTRDIFF_T_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* On VxWorks, <type/vxTypesBase.h> may have defined macros like
|
||||||
|
_TYPE_size_t which will typedef size_t. fixincludes patched the
|
||||||
|
vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
|
||||||
|
not defined, and so that defining this macro defines _GCC_SIZE_T.
|
||||||
|
If we find that the macros are still defined at this point, we must
|
||||||
|
invoke them so that the type is defined as expected. */
|
||||||
|
#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
|
||||||
|
_TYPE_ptrdiff_t;
|
||||||
|
#undef _TYPE_ptrdiff_t
|
||||||
|
#endif
|
||||||
|
#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
|
||||||
|
_TYPE_size_t;
|
||||||
|
#undef _TYPE_size_t
|
||||||
|
#endif
|
||||||
|
#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
|
||||||
|
_TYPE_wchar_t;
|
||||||
|
#undef _TYPE_wchar_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* In case nobody has defined these types, but we aren't running under
|
||||||
|
GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
|
||||||
|
__WCHAR_TYPE__ have reasonable values. This can happen if the
|
||||||
|
parts of GCC is compiled by an older compiler, that actually
|
||||||
|
include gstddef.h, such as collect2. */
|
||||||
|
|
||||||
|
/* Signed type of difference of two pointers. */
|
||||||
|
|
||||||
|
/* Define this type if we are doing the whole job,
|
||||||
|
or if we want this type in particular. */
|
||||||
|
#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
|
||||||
|
#ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
|
||||||
|
#ifndef _T_PTRDIFF_
|
||||||
|
#ifndef _T_PTRDIFF
|
||||||
|
#ifndef __PTRDIFF_T
|
||||||
|
#ifndef _PTRDIFF_T_
|
||||||
|
#ifndef _BSD_PTRDIFF_T_
|
||||||
|
#ifndef ___int_ptrdiff_t_h
|
||||||
|
#ifndef _GCC_PTRDIFF_T
|
||||||
|
#define _PTRDIFF_T
|
||||||
|
#define _T_PTRDIFF_
|
||||||
|
#define _T_PTRDIFF
|
||||||
|
#define __PTRDIFF_T
|
||||||
|
#define _PTRDIFF_T_
|
||||||
|
#define _BSD_PTRDIFF_T_
|
||||||
|
#define ___int_ptrdiff_t_h
|
||||||
|
#define _GCC_PTRDIFF_T
|
||||||
|
#ifndef __PTRDIFF_TYPE__
|
||||||
|
#define __PTRDIFF_TYPE__ long int
|
||||||
|
#endif
|
||||||
|
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||||
|
#endif /* _GCC_PTRDIFF_T */
|
||||||
|
#endif /* ___int_ptrdiff_t_h */
|
||||||
|
#endif /* _BSD_PTRDIFF_T_ */
|
||||||
|
#endif /* _PTRDIFF_T_ */
|
||||||
|
#endif /* __PTRDIFF_T */
|
||||||
|
#endif /* _T_PTRDIFF */
|
||||||
|
#endif /* _T_PTRDIFF_ */
|
||||||
|
#endif /* _PTRDIFF_T */
|
||||||
|
|
||||||
|
/* If this symbol has done its job, get rid of it. */
|
||||||
|
#undef __need_ptrdiff_t
|
||||||
|
|
||||||
|
#endif /* _STDDEF_H or __need_ptrdiff_t. */
|
||||||
|
|
||||||
|
/* Unsigned type of `sizeof' something. */
|
||||||
|
|
||||||
|
/* Define this type if we are doing the whole job,
|
||||||
|
or if we want this type in particular. */
|
||||||
|
#if defined (_STDDEF_H) || defined (__need_size_t)
|
||||||
|
#ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
|
||||||
|
#ifndef _SYS_SIZE_T_H
|
||||||
|
#ifndef _T_SIZE_
|
||||||
|
#ifndef _T_SIZE
|
||||||
|
#ifndef __SIZE_T_
|
||||||
|
#ifndef _SIZE_T_
|
||||||
|
#ifndef _BSD_SIZE_T_
|
||||||
|
#ifndef _SIZE_T_DEFINED_
|
||||||
|
#ifndef _SIZE_T_DEFINED
|
||||||
|
#ifndef ___int_size_t_h
|
||||||
|
#ifndef _GCC_SIZE_T
|
||||||
|
#ifndef _SIZET_
|
||||||
|
#ifndef __size_t
|
||||||
|
#define _SIZE_T
|
||||||
|
#define _SYS_SIZE_T_H
|
||||||
|
#define _T_SIZE_
|
||||||
|
#define _T_SIZE
|
||||||
|
#define __SIZE_T_
|
||||||
|
#define _SIZE_T_
|
||||||
|
#define _BSD_SIZE_T_
|
||||||
|
#define _SIZE_T_DEFINED_
|
||||||
|
#define _SIZE_T_DEFINED
|
||||||
|
#define ___int_size_t_h
|
||||||
|
#define _GCC_SIZE_T
|
||||||
|
#define _SIZET_
|
||||||
|
#define __size_t
|
||||||
|
#ifndef __SIZE_TYPE__
|
||||||
|
#define __SIZE_TYPE__ unsigned int
|
||||||
|
#endif
|
||||||
|
#if !(defined (__GNUG__) && defined (size_t))
|
||||||
|
#ifndef _DONESIZET
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
#define _DONESIZET
|
||||||
|
#endif
|
||||||
|
#endif /* !(defined (__GNUG__) && defined (size_t)) */
|
||||||
|
#endif /* __size_t */
|
||||||
|
#endif /* _SIZET_ */
|
||||||
|
#endif /* _GCC_SIZE_T */
|
||||||
|
#endif /* ___int_size_t_h */
|
||||||
|
#endif /* _SIZE_T_DEFINED */
|
||||||
|
#endif /* _SIZE_T_DEFINED_ */
|
||||||
|
#endif /* _BSD_SIZE_T_ */
|
||||||
|
#endif /* _SIZE_T_ */
|
||||||
|
#endif /* __SIZE_T */
|
||||||
|
#endif /* _T_SIZE */
|
||||||
|
#endif /* _T_SIZE_ */
|
||||||
|
#endif /* _SYS_SIZE_T_H */
|
||||||
|
#endif /* _SIZE_T */
|
||||||
|
#undef __need_size_t
|
||||||
|
#endif /* _STDDEF_H or __need_size_t. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Wide character type.
|
||||||
|
Locale-writers should change this as necessary to
|
||||||
|
be big enough to hold unique values not between 0 and 127,
|
||||||
|
and not (wchar_t) -1, for each defined multibyte character. */
|
||||||
|
|
||||||
|
/* Define this type if we are doing the whole job,
|
||||||
|
or if we want this type in particular. */
|
||||||
|
#if defined (_STDDEF_H) || defined (__need_wchar_t)
|
||||||
|
#ifndef _WCHAR_T
|
||||||
|
#ifndef _T_WCHAR_
|
||||||
|
#ifndef _T_WCHAR
|
||||||
|
#ifndef __WCHAR_T
|
||||||
|
#ifndef _WCHAR_T_
|
||||||
|
#ifndef _BSD_WCHAR_T_
|
||||||
|
#ifndef _WCHAR_T_DEFINED_
|
||||||
|
#ifndef _WCHAR_T_DEFINED
|
||||||
|
#ifndef _WCHAR_T_H
|
||||||
|
#ifndef ___int_wchar_t_h
|
||||||
|
#ifndef __INT_WCHAR_T_H
|
||||||
|
#ifndef _GCC_WCHAR_T
|
||||||
|
#define _WCHAR_T
|
||||||
|
#define _T_WCHAR_
|
||||||
|
#define _T_WCHAR
|
||||||
|
#define __WCHAR_T
|
||||||
|
#define _WCHAR_T_
|
||||||
|
#define _BSD_WCHAR_T_
|
||||||
|
#define _WCHAR_T_DEFINED_
|
||||||
|
#define _WCHAR_T_DEFINED
|
||||||
|
#define _WCHAR_T_H
|
||||||
|
#define ___int_wchar_t_h
|
||||||
|
#define __INT_WCHAR_T_H
|
||||||
|
#define _GCC_WCHAR_T
|
||||||
|
|
||||||
|
/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
|
||||||
|
instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
|
||||||
|
symbols in the _FOO_T_ family, stays defined even after its
|
||||||
|
corresponding type is defined). If we define wchar_t, then we
|
||||||
|
must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
|
||||||
|
we undef _WCHAR_T_, then we must also define rune_t, since
|
||||||
|
headers like runetype.h assume that if machine/ansi.h is included,
|
||||||
|
and _BSD_WCHAR_T_ is not defined, then rune_t is available.
|
||||||
|
machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
|
||||||
|
the same type." */
|
||||||
|
#ifdef _BSD_WCHAR_T_
|
||||||
|
#undef _BSD_WCHAR_T_
|
||||||
|
#ifdef _BSD_RUNE_T_
|
||||||
|
#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
|
||||||
|
typedef _BSD_RUNE_T_ rune_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __WCHAR_TYPE__
|
||||||
|
#define __WCHAR_TYPE__ int
|
||||||
|
#endif
|
||||||
|
#ifndef __cplusplus
|
||||||
|
typedef __WCHAR_TYPE__ wchar_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#undef __need_wchar_t
|
||||||
|
#endif /* _STDDEF_H or __need_wchar_t. */
|
||||||
|
|
||||||
|
#if defined (_STDDEF_H) || defined (__need_wint_t)
|
||||||
|
#ifndef _WINT_T
|
||||||
|
#define _WINT_T
|
||||||
|
|
||||||
|
#ifndef __WINT_TYPE__
|
||||||
|
#define __WINT_TYPE__ unsigned int
|
||||||
|
#endif
|
||||||
|
typedef __WINT_TYPE__ wint_t;
|
||||||
|
#endif
|
||||||
|
#undef __need_wint_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
|
||||||
|
are already defined. */
|
||||||
|
#ifdef _ANSI_H_
|
||||||
|
/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
|
||||||
|
are probably typos and should be removed before 2.8 is released. */
|
||||||
|
#ifdef _GCC_PTRDIFF_T_
|
||||||
|
#undef _PTRDIFF_T_
|
||||||
|
#undef _BSD_PTRDIFF_T_
|
||||||
|
#endif
|
||||||
|
#ifdef _GCC_SIZE_T_
|
||||||
|
#undef _SIZE_T_
|
||||||
|
#undef _BSD_SIZE_T_
|
||||||
|
#endif
|
||||||
|
#ifdef _GCC_WCHAR_T_
|
||||||
|
#undef _WCHAR_T_
|
||||||
|
#undef _BSD_WCHAR_T_
|
||||||
|
#endif
|
||||||
|
/* The following ones are the real ones. */
|
||||||
|
#ifdef _GCC_PTRDIFF_T
|
||||||
|
#undef _PTRDIFF_T_
|
||||||
|
#undef _BSD_PTRDIFF_T_
|
||||||
|
#endif
|
||||||
|
#ifdef _GCC_SIZE_T
|
||||||
|
#undef _SIZE_T_
|
||||||
|
#undef _BSD_SIZE_T_
|
||||||
|
#endif
|
||||||
|
#ifdef _GCC_WCHAR_T
|
||||||
|
#undef _WCHAR_T_
|
||||||
|
#undef _BSD_WCHAR_T_
|
||||||
|
#endif
|
||||||
|
#endif /* _ANSI_H_ */
|
||||||
|
|
||||||
|
#endif /* __sys_stdtypes_h */
|
||||||
|
|
||||||
|
/* A null pointer constant. */
|
||||||
|
|
||||||
|
#if defined (_STDDEF_H) || defined (__need_NULL)
|
||||||
|
#undef NULL /* in case <stdio.h> has defined it. */
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#define NULL (__null)
|
||||||
|
#else /* G++ */
|
||||||
|
#define NULL (0)
|
||||||
|
#endif /* G++ */
|
||||||
|
#endif /* NULL not defined and <stddef.h> or need NULL. */
|
||||||
|
#undef __need_NULL
|
||||||
|
|
||||||
|
#ifdef _STDDEF_H
|
||||||
|
|
||||||
|
/* Offset of member MEMBER in a struct of type TYPE. */
|
||||||
|
|
||||||
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||||
|
|
||||||
|
#endif /* _STDDEF_H was defined this time */
|
||||||
|
|
||||||
|
#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
|
||||||
|
|| __need_XXX was not defined before */
|
|
@ -0,0 +1,68 @@
|
||||||
|
#ifndef __STDIO_H__
|
||||||
|
#define __STDIO_H__ 1
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
|
||||||
|
//int sprintf(char*, const char *format, ...);
|
||||||
|
int __cdecl sprintf(char *, const char *, ...);
|
||||||
|
|
||||||
|
//#include <tamtypes.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define _O_RDONLY (0x00000001)
|
||||||
|
#define _O_WRONLY (0x00000002)
|
||||||
|
#define _O_RDWR (0x00000003)
|
||||||
|
#define _O_NBLOCK (0x00000010)
|
||||||
|
#define _O_APPEND (0x00000100)
|
||||||
|
#define _O_CREAT (0x00000200)
|
||||||
|
#define _O_TRUNC (0x00000400)
|
||||||
|
#define _O_EXCL (0x00000800)
|
||||||
|
#define _O_TEMPORARY (0x00001000)
|
||||||
|
#define _O_TEXT (0x00004000)
|
||||||
|
#define _O_BINARY (0x00008000)
|
||||||
|
|
||||||
|
#define O_RDONLY _O_RDONLY
|
||||||
|
#define O_WRONLY _O_WRONLY
|
||||||
|
#define O_RDWR _O_RDWR
|
||||||
|
#define O_NBLOCK _O_NBLOCK
|
||||||
|
#define O_APPEND _O_APPEND
|
||||||
|
#define O_CREAT _O_CREAT
|
||||||
|
#define O_EXCL _O_EXCL
|
||||||
|
#define O_TRUNC _O_TRUNC
|
||||||
|
#define O_TEMPORARY _O_TEMPORARY
|
||||||
|
#define O_TEXT _O_TEXT
|
||||||
|
#define O_BINARY _O_BINARY
|
||||||
|
|
||||||
|
|
||||||
|
#define SEEK_SET 0
|
||||||
|
#define SEEK_CUR 1
|
||||||
|
#define SEEK_END 2
|
||||||
|
|
||||||
|
extern u32 LastErrorCode;
|
||||||
|
|
||||||
|
int _open( char *filename, int oflag, int permission );
|
||||||
|
int _read( int handle, void *buffer, unsigned int count );
|
||||||
|
int _write( int handle, void* buffer, unsigned int count );
|
||||||
|
int _close( int handle );
|
||||||
|
int _lseek( int handle, u32 offset, int base );
|
||||||
|
|
||||||
|
int nprintf(const char *format, ...);
|
||||||
|
int printf(const char *format, ...);
|
||||||
|
//int sprintf(char*, const char *format, ...);
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif // __STDIO_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
/* <stdlib.h>
|
||||||
|
*
|
||||||
|
* ANSI-C Standard Library definitions
|
||||||
|
*/
|
||||||
|
#define __IEEE_FLOAT 1 // BIGBOY
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _STDLIB_H
|
||||||
|
#define _STDLIB_H
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
/* note: no !defined(__STDC__) handling, deliberately */
|
||||||
|
#include <defs.h>
|
||||||
|
|
||||||
|
#ifndef _STDDEF_H
|
||||||
|
#include <stddef.h> /* get size_t, NULL */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
char *itoa(int i, char* string, int radix);
|
||||||
|
|
||||||
|
/*
|
||||||
|
These exit macro values work with either exit() or return from main(),
|
||||||
|
and avoid unnecessary warnings from the DCL command intrepretor. They
|
||||||
|
don't match VAX C's <stdlib.h>, which has 0 and 2 respectively. Using 0
|
||||||
|
for success works with VAXCRTL's exit() but requires additional compiler
|
||||||
|
support in main() (which VAX C neglects to provide). 2 always provokes
|
||||||
|
"%NONAME-E-NOMSG, Message number 00000002"; similarly for unfixed 0.
|
||||||
|
*/
|
||||||
|
#define EXIT_SUCCESS 1 /* SS$_NORMAL, STS$K_SUCCESS */
|
||||||
|
#define EXIT_FAILURE 0x10000002 /* (STS$K_ERROR | STS$M_INHIB_MSG) */
|
||||||
|
|
||||||
|
#define RAND_MAX 2147483647 /* 0x7FFFFFFF */
|
||||||
|
#define lrand48() rand()
|
||||||
|
|
||||||
|
#if (__GNUC__ == 2 && !__STRICT_ANSI__)
|
||||||
|
#if (__GNUC_MINOR__ >= 5)
|
||||||
|
void abort(void) __asm ("decc$abort") __attribute__((noreturn));
|
||||||
|
void exit(int) __asm ("decc$exit") __attribute__((noreturn));
|
||||||
|
void _exit(int) __attribute__((noreturn));
|
||||||
|
#else
|
||||||
|
volatile void abort(void) __asm ("decc$abort");
|
||||||
|
volatile void exit(int) __asm ("decc$exit");
|
||||||
|
volatile void _exit(int);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
void abort(void);
|
||||||
|
void exit(int i);
|
||||||
|
void _exit(int i);
|
||||||
|
#endif
|
||||||
|
int atexit(void (*)(void));
|
||||||
|
|
||||||
|
void *bsearch(const void *,const void *,size_t,size_t,
|
||||||
|
int (*)(const void *,const void *));
|
||||||
|
|
||||||
|
void qsort(void *,size_t,size_t,int (*)(const void *,const void *)); // __asm ("decc$qsort");
|
||||||
|
|
||||||
|
int rand(void);
|
||||||
|
int srand(int); /* routine to initialize rand() */
|
||||||
|
|
||||||
|
/* These are the functions that actually do things. The `random', `srandom',
|
||||||
|
`initstate' and `setstate' functions are those from BSD Unices.
|
||||||
|
The `rand' and `srand' functions are required by the ANSI standard.
|
||||||
|
We provide both interfaces to the same random number generator. */
|
||||||
|
/* Return a random long integer between 0 and RAND_MAX inclusive. */
|
||||||
|
extern long int __random (void);
|
||||||
|
/* Seed the random number generator with the given number. */
|
||||||
|
extern void __srandom (unsigned int __seed);
|
||||||
|
|
||||||
|
|
||||||
|
char *getenv(const char *); // __asm ("decc$getenv");
|
||||||
|
int system(const char *);
|
||||||
|
|
||||||
|
/* math related routines */
|
||||||
|
#ifndef _DIV_T
|
||||||
|
#define _DIV_T
|
||||||
|
typedef struct DIV_T { int quot, rem; } div_t;
|
||||||
|
#endif
|
||||||
|
#ifndef _LDIV_T
|
||||||
|
#define _LDIV_T
|
||||||
|
typedef struct LDIV_T { long quot, rem; } ldiv_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# define ___fdecl(_func,_arglist)
|
||||||
|
#if __IEEE_FLOAT
|
||||||
|
# define ___gdecl(_func, _arglist) _func _arglist { __asm{ nop } }
|
||||||
|
#elif __G_FLOAT
|
||||||
|
# define ___gdecl(_func, _arglist) _func _arglist __asm("decc$g" #_func)
|
||||||
|
#else
|
||||||
|
# error "No floating format defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int abs(int);
|
||||||
|
int atoi (const char *i);
|
||||||
|
long atol(const char * i);
|
||||||
|
double atof(const char * i);
|
||||||
|
div_t div(int i,int i2);
|
||||||
|
long labs(long);
|
||||||
|
ldiv_t ldiv(long,long);
|
||||||
|
double strtod(const char *i,char **i2);
|
||||||
|
long strtol(const char *i,char **i2,int i3);
|
||||||
|
unsigned long strtoul(const char *i,char **i2,int i3);
|
||||||
|
|
||||||
|
/* memory manipulation routines; note: cfree() is gone; see also <malloc.h> */
|
||||||
|
void* malloc (size_t i);
|
||||||
|
void* calloc (size_t i, size_t i2);
|
||||||
|
void* realloc (void *i, size_t i2);
|
||||||
|
void free (void * i);
|
||||||
|
|
||||||
|
#undef ___gdecl
|
||||||
|
#undef ___fdecl
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif /*_STDLIB_H*/
|
|
@ -0,0 +1,193 @@
|
||||||
|
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ANSI Standard: 4.11 STRING HANDLING <string.h>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _STRING_H
|
||||||
|
|
||||||
|
#define _STRING_H 1
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
/* Get size_t and NULL from <stddef.h>. */
|
||||||
|
#define __need_ptrdiff_t
|
||||||
|
#define __need_size_t
|
||||||
|
#define __need_NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Copy N bytes of SRC to DEST. */
|
||||||
|
extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,
|
||||||
|
size_t __n));
|
||||||
|
/* Copy N bytes of SRC to DEST, guaranteeing
|
||||||
|
correct behavior for overlapping strings. */
|
||||||
|
extern __ptr_t memmove __P ((__ptr_t __dest, __const __ptr_t __src,
|
||||||
|
size_t __n));
|
||||||
|
|
||||||
|
/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
|
||||||
|
Return the position in DEST one byte past where C was copied,
|
||||||
|
or NULL if C was not found in the first N bytes of SRC. */
|
||||||
|
extern __ptr_t __memccpy __P ((__ptr_t __dest, __const __ptr_t __src,
|
||||||
|
int __c, size_t __n));
|
||||||
|
#if defined (__USE_SVID) || defined (__USE_BSD)
|
||||||
|
extern __ptr_t memccpy __P ((__ptr_t __dest, __const __ptr_t __src,
|
||||||
|
int __c, size_t __n));
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
#define memccpy(dest, src, c, n) __memccpy((dest), (src), (c), (n))
|
||||||
|
#endif /* Optimizing. */
|
||||||
|
#endif /* SVID. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Set N bytes of S to C. */
|
||||||
|
extern __ptr_t memset __P ((__ptr_t __s, int __c, size_t __n));
|
||||||
|
|
||||||
|
/* Compare N bytes of S1 and S2. */
|
||||||
|
extern int memcmp __P ((__const __ptr_t __s1, __const __ptr_t __s2,
|
||||||
|
size_t __n));
|
||||||
|
|
||||||
|
/* Search N bytes of S for C. */
|
||||||
|
extern __ptr_t memchr __P ((__const __ptr_t __s, int __c, size_t __n));
|
||||||
|
|
||||||
|
|
||||||
|
/* Copy SRC to DEST. */
|
||||||
|
extern char *strcpy __P ((char *__dest, __const char *__src));
|
||||||
|
/* Copy no more than N characters of SRC to DEST. */
|
||||||
|
extern char *strncpy __P ((char *__dest, __const char *__src, size_t __n));
|
||||||
|
|
||||||
|
/* Append SRC onto DEST. */
|
||||||
|
extern char *strcat __P ((char *__dest, __const char *__src));
|
||||||
|
/* Append no more than N characters from SRC onto DEST. */
|
||||||
|
extern char *strncat __P ((char *__dest, __const char *__src, size_t __n));
|
||||||
|
|
||||||
|
/* Compare S1 and S2. */
|
||||||
|
extern int strcmp __P ((__const char *__s1, __const char *__s2));
|
||||||
|
/* Compare N characters of S1 and S2. */
|
||||||
|
extern int strncmp __P ((__const char *__s1, __const char *__s2, size_t __n));
|
||||||
|
|
||||||
|
/* Compare the collated forms of S1 and S2. */
|
||||||
|
extern int strcoll __P ((__const char *__s1, __const char *__s2));
|
||||||
|
/* Put a transformation of SRC into no more than N bytes of DEST. */
|
||||||
|
extern size_t strxfrm __P ((char *__dest, __const char *__src, size_t __n));
|
||||||
|
|
||||||
|
#if defined (__USE_SVID) || defined (__USE_BSD)
|
||||||
|
/* Duplicate S, returning an identical malloc'd string. */
|
||||||
|
extern char *strdup __P ((__const char *__s));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Find the first occurrence of C in S. */
|
||||||
|
extern char *strchr __P ((__const char *__s, int __c));
|
||||||
|
/* Find the last occurrence of C in S. */
|
||||||
|
extern char *strrchr __P ((__const char *__s, int __c));
|
||||||
|
|
||||||
|
/* Return the length of the initial segment of S which
|
||||||
|
consists entirely of characters not in REJECT. */
|
||||||
|
extern size_t strcspn __P ((__const char *__s, __const char *__reject));
|
||||||
|
/* Return the length of the initial segment of S which
|
||||||
|
consists entirely of characters in ACCEPT. */
|
||||||
|
extern size_t strspn __P ((__const char *__s, __const char *__accept));
|
||||||
|
/* Find the first occurence in S of any character in ACCEPT. */
|
||||||
|
extern char *strpbrk __P ((__const char *__s, __const char *__accept));
|
||||||
|
/* Find the first occurence of NEEDLE in HAYSTACK. */
|
||||||
|
extern char *strstr __P ((__const char *__haystack, __const char *__needle));
|
||||||
|
|
||||||
|
/* Divide S into tokens separated by characters in DELIM. */
|
||||||
|
extern char *strtok __P ((char *__s, __const char *__delim));
|
||||||
|
|
||||||
|
#ifdef __USE_GNU
|
||||||
|
/* Find the first occurence of NEEDLE in HAYSTACK.
|
||||||
|
NEEDLE is NEEDLELEN bytes long;
|
||||||
|
HAYSTACK is HAYSTACKLEN bytes long. */
|
||||||
|
extern __ptr_t memmem __P ((__const __ptr_t __haystack, size_t __haystacklen,
|
||||||
|
__const __ptr_t __needle, size_t __needlelen));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return the length of S. */
|
||||||
|
extern size_t strlen __P ((__const char *__s));
|
||||||
|
|
||||||
|
/* Return a string describing the meaning of the errno code in ERRNUM. */
|
||||||
|
extern char *strerror __P ((int __errnum));
|
||||||
|
|
||||||
|
#ifdef __USE_BSD
|
||||||
|
/* Find the first occurrence of C in S (same as strchr). */
|
||||||
|
extern char *index __P ((__const char *__s, int __c));
|
||||||
|
|
||||||
|
/* Find the last occurrence of C in S (same as strrchr). */
|
||||||
|
extern char *rindex __P ((__const char *__s, int __c));
|
||||||
|
|
||||||
|
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
|
||||||
|
extern void bcopy __P ((__const __ptr_t __src, __ptr_t __dest, size_t __n));
|
||||||
|
|
||||||
|
/* Set N bytes of S to 0. */
|
||||||
|
extern void bzero __P ((__ptr_t __s, size_t __n));
|
||||||
|
|
||||||
|
/* Compare N bytes of S1 and S2 (same as memcmp). */
|
||||||
|
extern int bcmp __P ((__const __ptr_t __s1, __const __ptr_t __s2, size_t __n));
|
||||||
|
|
||||||
|
/* Return the position of the first bit set in I, or 0 if none are set.
|
||||||
|
The least-significant bit is position 1, the most-significant 32. */
|
||||||
|
extern int ffs __P ((int __i));
|
||||||
|
|
||||||
|
/* Compare S1 and S2, ignoring case. */
|
||||||
|
extern int strcasecmp __P ((__const char *__s1, __const char *__s2));
|
||||||
|
|
||||||
|
/* Return the next DELIM-delimited token from *STRINGP,
|
||||||
|
terminating it with a '\0', and update *STRINGP to point past it. */
|
||||||
|
extern char *strsep __P ((char **__stringp, __const char *__delim));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Copy no more than N characters of SRC to DEST, returning the address of
|
||||||
|
the last character written into DEST. */
|
||||||
|
extern char *__stpncpy __P ((char *__dest, __const char *__src, size_t __n));
|
||||||
|
|
||||||
|
#ifdef __USE_GNU
|
||||||
|
/* Compare no more than N chars of S1 and S2, ignoring case. */
|
||||||
|
extern int strncasecmp __P ((__const char *__s1, __const char *__s2,
|
||||||
|
size_t __n));
|
||||||
|
|
||||||
|
/* Return a string describing the meaning of the signal number in SIG. */
|
||||||
|
extern char *strsignal __P ((int __sig));
|
||||||
|
|
||||||
|
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
|
||||||
|
extern char *stpcpy __P ((char *__dest, __const char *__src));
|
||||||
|
|
||||||
|
/* Copy no more than N characters of SRC to DEST, returning the address of
|
||||||
|
the last character written into DEST. */
|
||||||
|
extern char *stpncpy __P ((char *__dest, __const char *__src, size_t __n));
|
||||||
|
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
#define stpncpy(dest, src, n) __stpncpy ((dest), (src), (n))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Sautee STRING briskly. */
|
||||||
|
extern char *strfry __P ((char *__string));
|
||||||
|
|
||||||
|
/* Frobnicate N bytes of S. */
|
||||||
|
extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* string.h */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, write to the Free
|
||||||
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
|
02111-1307 USA. */
|
||||||
|
|
||||||
|
#ifndef _ENDIAN_H
|
||||||
|
#define _ENDIAN_H 1
|
||||||
|
|
||||||
|
#include <features.h>
|
||||||
|
|
||||||
|
/* Definitions for byte order, according to significance of bytes,
|
||||||
|
from low addresses to high addresses. The value is what you get by
|
||||||
|
putting '4' in the most significant byte, '3' in the second most
|
||||||
|
significant byte, '2' in the second least significant byte, and '1'
|
||||||
|
in the least significant byte, and then writing down one digit for
|
||||||
|
each byte, starting with the byte at the lowest address at the left,
|
||||||
|
and proceeding to the byte with the highest address at the right. */
|
||||||
|
|
||||||
|
#define __LITTLE_ENDIAN 1234
|
||||||
|
#define __BIG_ENDIAN 4321
|
||||||
|
#define __PDP_ENDIAN 3412
|
||||||
|
|
||||||
|
/* This file defines `__BYTE_ORDER' for the particular machine. */
|
||||||
|
#include <bits/endian.h>
|
||||||
|
|
||||||
|
/* Some machines may need to use a different endianness for floating point
|
||||||
|
values. */
|
||||||
|
#ifndef __FLOAT_WORD_ORDER
|
||||||
|
# define __FLOAT_WORD_ORDER __BYTE_ORDER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __USE_BSD
|
||||||
|
# define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||||
|
# define BIG_ENDIAN __BIG_ENDIAN
|
||||||
|
# define PDP_ENDIAN __PDP_ENDIAN
|
||||||
|
# define BYTE_ORDER __BYTE_ORDER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
# define __LONG_LONG_PAIR(HI, LO) LO, HI
|
||||||
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||||
|
# define __LONG_LONG_PAIR(HI, LO) HI, LO
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* endian.h */
|
|
@ -0,0 +1 @@
|
||||||
|
#include <misc/sys/cdefs.h>
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||||
|
#ifndef __DJ_sys_djtypes_h_
|
||||||
|
#define __DJ_sys_djtypes_h_
|
||||||
|
|
||||||
|
#define __DJ_clock_t typedef int clock_t;
|
||||||
|
#define __DJ_gid_t typedef int gid_t;
|
||||||
|
#define __DJ_off_t typedef int off_t;
|
||||||
|
#define __DJ_pid_t typedef int pid_t;
|
||||||
|
#define __DJ_size_t typedef long unsigned int size_t;
|
||||||
|
#define __DJ_ssize_t typedef int ssize_t;
|
||||||
|
#define __DJ_time_t typedef unsigned int time_t;
|
||||||
|
#define __DJ_uid_t typedef int uid_t;
|
||||||
|
#define __DJ_va_list typedef void *va_list;
|
||||||
|
#define __DJ_wchar_t typedef int wchar_t;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,85 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : openxdk.h
|
||||||
|
// *
|
||||||
|
// * note : Welcome To Heaven
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef OPENXDK_H
|
||||||
|
#define OPENXDK_H
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * OpenXDK Version Number
|
||||||
|
// ******************************************************************
|
||||||
|
#define OPENXDK_VERSION "0.1.0-Pre1"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * OpenXDK Full Title
|
||||||
|
// ******************************************************************
|
||||||
|
#define OPENXDK_TITLE "OpenXDK " OPENXDK_VERSION
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Humor caustik with some of his favorite typedefs
|
||||||
|
// ******************************************************************
|
||||||
|
typedef signed int sint;
|
||||||
|
typedef unsigned int uint;
|
||||||
|
|
||||||
|
typedef char int08;
|
||||||
|
typedef short int16;
|
||||||
|
typedef long int32;
|
||||||
|
|
||||||
|
typedef unsigned char uint08;
|
||||||
|
typedef unsigned short uint16;
|
||||||
|
typedef unsigned long uint32;
|
||||||
|
|
||||||
|
typedef signed char sint08;
|
||||||
|
typedef signed short sint16;
|
||||||
|
typedef signed long sint32;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Humor Bigboy with some of his favorite typedefs :)
|
||||||
|
// ******************************************************************
|
||||||
|
typedef unsigned char byte;
|
||||||
|
typedef unsigned char u8;
|
||||||
|
typedef signed char s8;
|
||||||
|
typedef unsigned short u16;
|
||||||
|
typedef signed short s16;
|
||||||
|
typedef unsigned int u32;
|
||||||
|
typedef signed int s32;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XBox Kernel
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xboxkrnl/xboxkrnl.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XHal
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xhal/xhal.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XVGA
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xvga/xvga.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XUSB (being removed...)
|
||||||
|
// ******************************************************************
|
||||||
|
//#include "xusb/xusb.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XINPUT (Gamepad Support)
|
||||||
|
// ******************************************************************
|
||||||
|
//#include "xinput/xinput.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : dbg.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Debug* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_DBG_H
|
||||||
|
#define XBOXKRNL_DBG_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *DbgBreakPoint;
|
||||||
|
XBSYSAPI VOID *DbgBreakPointWithStatus;
|
||||||
|
XBSYSAPI VOID *DbgLoadImageSymbols;
|
||||||
|
XBSYSAPI VOID *DbgPrint;
|
||||||
|
XBSYSAPI VOID *DbgPrompt;
|
||||||
|
XBSYSAPI VOID *DbgUnLoadImageSymbols;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : ex.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Executive* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_EX_H
|
||||||
|
#define XBOXKRNL_EX_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ExAcquireReadWriteLockExclusive;
|
||||||
|
XBSYSAPI VOID *ExAcquireReadWriteLockShared;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ExAllocatePool
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Allocates pool memory
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(14) PVOID NTAPI ExAllocatePool
|
||||||
|
(
|
||||||
|
IN ULONG NumberOfBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ExAllocatePoolWithTag
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Allocates pool memory with a tag
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(15) PVOID NTAPI ExAllocatePoolWithTag
|
||||||
|
(
|
||||||
|
IN SIZE_T NumberOfBytes,
|
||||||
|
IN ULONG Tag
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ExEventObjectType;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ExFreePool
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Deallocates a block of pool memory
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(17) PVOID NTAPI ExFreePool
|
||||||
|
(
|
||||||
|
IN PVOID P
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ExInitializeReadWriteLock;
|
||||||
|
XBSYSAPI VOID *ExInterlockedAddLargeInteger;
|
||||||
|
XBSYSAPI VOID *ExInterlockedAddLargeStatistic;
|
||||||
|
XBSYSAPI VOID *ExInterlockedCompareExchange64;
|
||||||
|
XBSYSAPI VOID *ExMutantObjectType;
|
||||||
|
XBSYSAPI VOID *ExQueryPoolBlockSize;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ExQueryNonVolatileSetting
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(24) NTSTATUS NTAPI ExQueryNonVolatileSetting
|
||||||
|
(
|
||||||
|
IN DWORD ValueIndex,
|
||||||
|
OUT DWORD *Type,
|
||||||
|
OUT PUCHAR Value,
|
||||||
|
IN SIZE_T ValueLength,
|
||||||
|
OUT PSIZE_T ResultLength OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ExReadWriteRefurbInfo;
|
||||||
|
XBSYSAPI VOID *ExRaiseException;
|
||||||
|
XBSYSAPI VOID *ExRaiseStatus;
|
||||||
|
XBSYSAPI VOID *ExReleaseReadWriteLock;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ExSaveNonVolatileSetting
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(29) NTSTATUS NTAPI ExSaveNonVolatileSetting
|
||||||
|
(
|
||||||
|
IN DWORD ValueIndex,
|
||||||
|
OUT DWORD *Type,
|
||||||
|
IN PUCHAR Value,
|
||||||
|
IN SIZE_T ValueLength
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ExSemaphoreObjectType;
|
||||||
|
XBSYSAPI VOID *ExTimerObjectType;
|
||||||
|
XBSYSAPI VOID *ExfInterlockedInsertHeadList;
|
||||||
|
XBSYSAPI VOID *ExfInterlockedInsertTailList;
|
||||||
|
XBSYSAPI VOID *ExfInterlockedRemoveHeadList;
|
||||||
|
XBSYSAPI VOID *InterlockedCompareExchange;
|
||||||
|
XBSYSAPI VOID *InterlockedDecrement;
|
||||||
|
XBSYSAPI VOID *InterlockedIncrement;
|
||||||
|
XBSYSAPI VOID *InterlockedExchange;
|
||||||
|
XBSYSAPI VOID *InterlockedExchangeAdd;
|
||||||
|
XBSYSAPI VOID *InterlockedFlushSList;
|
||||||
|
XBSYSAPI VOID *InterlockedPopEntrySList;
|
||||||
|
XBSYSAPI VOID *InterlockedPushEntrySList;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : hal.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Hardware Abstraction Layer* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_HAL_H
|
||||||
|
#define XBOXKRNL_HAL_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *HalReadSMCTrayState;
|
||||||
|
XBSYSAPI VOID *HalClearSoftwareInterrupt;
|
||||||
|
XBSYSAPI VOID *HalDisableSystemInterrupt;
|
||||||
|
XBSYSAPI VOID *HalDiskCachePartitionCount;
|
||||||
|
XBSYSAPI VOID *HalDiskModelNumber;
|
||||||
|
XBSYSAPI VOID *HalDiskSerialNumber;
|
||||||
|
XBSYSAPI VOID *HalEnableSystemInterrupt;
|
||||||
|
XBSYSAPI VOID *HalGetInterruptVector;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * HalReadSMBusValue
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(45) VOID NTAPI HalReadSMBusValue
|
||||||
|
(
|
||||||
|
ULONG BusNumber,
|
||||||
|
ULONG SlotNumber,
|
||||||
|
ULONG RegisterNumber,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Length,
|
||||||
|
BOOLEAN WritePCISpace
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * HalReadWritePCISpace
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(46) VOID NTAPI HalReadWritePCISpace
|
||||||
|
(
|
||||||
|
IN ULONG BusNumber,
|
||||||
|
IN ULONG SlotNumber,
|
||||||
|
IN ULONG RegisterNumber,
|
||||||
|
IN PVOID Buffer,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN BOOLEAN WritePCISpace
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *HalRegisterShutdownNotification;
|
||||||
|
XBSYSAPI VOID *HalRequestSoftwareInterrupt;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * HalReturnToFirmware
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Reboot / Shutdown / Etc
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(49) VOID DECLSPEC_NORETURN HalReturnToFirmware
|
||||||
|
(
|
||||||
|
RETURN_FIRMWARE Routine
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * HalWriteSMBusValue
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(50) ULONG NTAPI HalWriteSMBusValue
|
||||||
|
(
|
||||||
|
UCHAR Address,
|
||||||
|
UCHAR Command,
|
||||||
|
BOOLEAN WordFlag,
|
||||||
|
ULONG Value
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * HalBootSMCVideoMode
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(356) DWORD HalBootSMCVideoMode;
|
||||||
|
|
||||||
|
XBSYSAPI VOID *HalIsResetOrShutdownPending;
|
||||||
|
XBSYSAPI VOID *HalInitiateShutdown;
|
||||||
|
XBSYSAPI VOID *HalEnableSecureTrayEject;
|
||||||
|
XBSYSAPI VOID *HalWriteSMCScratchRegister;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * READ_PORT_BUFFER_UCHAR
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(329) VOID NTAPI READ_PORT_BUFFER_UCHAR
|
||||||
|
(
|
||||||
|
IN PUCHAR Port,
|
||||||
|
IN PUCHAR Buffer,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * READ_PORT_BUFFER_USHORT
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(330) VOID NTAPI READ_PORT_BUFFER_USHORT
|
||||||
|
(
|
||||||
|
IN PUSHORT Port,
|
||||||
|
IN PUSHORT Buffer,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * READ_PORT_BUFFER_ULONG
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(331) VOID NTAPI READ_PORT_BUFFER_ULONG
|
||||||
|
(
|
||||||
|
IN PULONG Port,
|
||||||
|
IN PULONG Buffer,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * WRITE_PORT_BUFFER_UCHAR
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(332) VOID NTAPI WRITE_PORT_BUFFER_UCHAR
|
||||||
|
(
|
||||||
|
IN PUCHAR Port,
|
||||||
|
IN PUCHAR Buffer,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * WRITE_PORT_BUFFER_USHORT
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(333) VOID NTAPI WRITE_PORT_BUFFER_USHORT
|
||||||
|
(
|
||||||
|
IN PUSHORT Port,
|
||||||
|
IN PUSHORT Buffer,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * WRITE_PORT_BUFFER_ULONG
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(334) VOID NTAPI WRITE_PORT_BUFFER_ULONG
|
||||||
|
(
|
||||||
|
IN PULONG Port,
|
||||||
|
IN PULONG Buffer,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : io.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *I/O Manager* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_IO_H
|
||||||
|
#define XBOXKRNL_IO_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *IoAllocateIrp;
|
||||||
|
XBSYSAPI VOID *IoBuildAsynchronousFsdRequest;
|
||||||
|
XBSYSAPI VOID *IoBuildDeviceIoControlRequest;
|
||||||
|
XBSYSAPI VOID *IoBuildSynchronousFsdRequest;
|
||||||
|
XBSYSAPI VOID *IoCheckShareAccess;
|
||||||
|
XBSYSAPI VOID *IoCompletionObjectType;
|
||||||
|
XBSYSAPI VOID *IoCreateDevice;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IoCreateFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(66) NTSTATUS NTAPI IoCreateFile
|
||||||
|
(
|
||||||
|
OUT PHANDLE FileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN PLARGE_INTEGER AllocationSize,
|
||||||
|
IN ULONG FileAttributes,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG Disposition,
|
||||||
|
IN ULONG CreateOptions,
|
||||||
|
IN ULONG Options
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IoCreateSymbolicLink
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(67) NTSTATUS NTAPI IoCreateSymbolicLink
|
||||||
|
(
|
||||||
|
IN PSTRING SymbolicLinkName,
|
||||||
|
IN PSTRING DeviceName
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *IoDeleteDevice;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * IoDeleteSymbolicLink
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(69) NTSTATUS NTAPI IoDeleteSymbolicLink
|
||||||
|
(
|
||||||
|
IN PSTRING SymbolicLinkName
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *IoDeviceObjectType;
|
||||||
|
XBSYSAPI VOID *IoFileObjectType;
|
||||||
|
XBSYSAPI VOID *IoFreeIrp;
|
||||||
|
XBSYSAPI VOID *IoInitializeIrp;
|
||||||
|
XBSYSAPI VOID *IoInvalidDeviceRequest;
|
||||||
|
XBSYSAPI VOID *IoQueryFileInformation;
|
||||||
|
XBSYSAPI VOID *IoQueryVolumeInformation;
|
||||||
|
XBSYSAPI VOID *IoQueueThreadIrp;
|
||||||
|
XBSYSAPI VOID *IoRemoveShareAccess;
|
||||||
|
XBSYSAPI VOID *IoSetIoCompletion;
|
||||||
|
XBSYSAPI VOID *IoSetShareAccess;
|
||||||
|
XBSYSAPI VOID *IoStartNextPacket;
|
||||||
|
XBSYSAPI VOID *IoStartNextPacketByKey;
|
||||||
|
XBSYSAPI VOID *IoStartPacket;
|
||||||
|
XBSYSAPI VOID *IoSynchronousDeviceIoControlRequest;
|
||||||
|
XBSYSAPI VOID *IoSynchronousFsdRequest;
|
||||||
|
XBSYSAPI VOID *IofCallDriver;
|
||||||
|
XBSYSAPI VOID *IofCompleteRequest;
|
||||||
|
XBSYSAPI VOID *IoDismountVolume;
|
||||||
|
XBSYSAPI VOID *IoDismountVolumeByName;
|
||||||
|
XBSYSAPI VOID *IoMarkIrpMustComplete;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : kernel.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef KERNEL_H
|
||||||
|
#define KERNEL_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeAlertResumeThread;
|
||||||
|
XBSYSAPI VOID *KeAlertThread;
|
||||||
|
XBSYSAPI VOID *KeBoostPriorityThread;
|
||||||
|
XBSYSAPI VOID *KeBugCheck;
|
||||||
|
XBSYSAPI VOID *KeBugCheckEx;
|
||||||
|
XBSYSAPI VOID *KeCancelTimer;
|
||||||
|
XBSYSAPI VOID *KeConnectInterrupt;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeDelayExecutionThread
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(99) NTSTATUS NTAPI KeDelayExecutionThread
|
||||||
|
(
|
||||||
|
IN KPROCESSOR_MODE WaitMode,
|
||||||
|
IN BOOLEAN Alertable,
|
||||||
|
IN PLARGE_INTEGER Interval
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeDisconnectInterrupt;
|
||||||
|
XBSYSAPI VOID *KeEnterCriticalRegion;
|
||||||
|
XBSYSAPI VOID *KeGetCurrentIrql;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeGetCurrentThread
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI VOID *KeGetCurrentThread;
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeInitializeApc;
|
||||||
|
XBSYSAPI VOID *KeInitializeDeviceQueue;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeInitializeDpc
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(107) VOID NTAPI KeInitializeDpc
|
||||||
|
(
|
||||||
|
KDPC *Dpc,
|
||||||
|
PKDEFERRED_ROUTINE DeferredRoutine,
|
||||||
|
PVOID DeferredContext
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeInitializeEvent;
|
||||||
|
XBSYSAPI VOID *KeInitializeInterrupt;
|
||||||
|
XBSYSAPI VOID *KeInitializeMutant;
|
||||||
|
XBSYSAPI VOID *KeInitializeQueue;
|
||||||
|
XBSYSAPI VOID *KeInitializeSemaphore;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeInitializeTimerEx
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(113) VOID NTAPI KeInitializeTimerEx
|
||||||
|
(
|
||||||
|
IN PKTIMER Timer,
|
||||||
|
IN TIMER_TYPE Type
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeInsertByKeyDeviceQueue;
|
||||||
|
XBSYSAPI VOID *KeInsertDeviceQueue;
|
||||||
|
XBSYSAPI VOID *KeInsertHeadQueue;
|
||||||
|
XBSYSAPI VOID *KeInsertQueue;
|
||||||
|
XBSYSAPI VOID *KeInsertQueueApc;
|
||||||
|
XBSYSAPI VOID *KeInsertQueueDpc;
|
||||||
|
XBSYSAPI VOID *KeInterruptTime;
|
||||||
|
XBSYSAPI VOID *KeIsExecutingDpc;
|
||||||
|
XBSYSAPI VOID *KeLeaveCriticalRegion;
|
||||||
|
XBSYSAPI VOID *KePulseEvent;
|
||||||
|
XBSYSAPI VOID *KeQueryBasePriorityThread;
|
||||||
|
XBSYSAPI VOID *KeQueryInterruptTime;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeQueryPerformanceCounter
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(126) ULONGLONG NTAPI KeQueryPerformanceCounter();
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeQueryPerformanceFrequency
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(127) ULONGLONG NTAPI KeQueryPerformanceFrequency();
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeQuerySystemTime
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(128) VOID NTAPI KeQuerySystemTime
|
||||||
|
(
|
||||||
|
PLARGE_INTEGER CurrentTime
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeRaiseIrqlToDpcLevel;
|
||||||
|
XBSYSAPI VOID *KeRaiseIrqlToSynchLevel;
|
||||||
|
XBSYSAPI VOID *KeReleaseMutant;
|
||||||
|
XBSYSAPI VOID *KeReleaseSemaphore;
|
||||||
|
XBSYSAPI VOID *KeRemoveByKeyDeviceQueue;
|
||||||
|
XBSYSAPI VOID *KeRemoveDeviceQueue;
|
||||||
|
XBSYSAPI VOID *KeRemoveEntryDeviceQueue;
|
||||||
|
XBSYSAPI VOID *KeRemoveQueue;
|
||||||
|
XBSYSAPI VOID *KeRemoveQueueDpc;
|
||||||
|
XBSYSAPI VOID *KeResetEvent;
|
||||||
|
XBSYSAPI VOID *KeRestoreFloatingPointState;
|
||||||
|
XBSYSAPI VOID *KeResumeThread;
|
||||||
|
XBSYSAPI VOID *KeRundownQueue;
|
||||||
|
XBSYSAPI VOID *KeSaveFloatingPointState;
|
||||||
|
|
||||||
|
//XBSYSAPI VOID *KeSetBasePriorityThread;
|
||||||
|
XBSYSAPI EXPORTNUM(143) BOOLEAN NTAPI KeSetBasePriorityThread
|
||||||
|
(
|
||||||
|
IN PKTHREAD Thread,
|
||||||
|
IN PVOID Priority
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeSetDisableBoostThread;
|
||||||
|
XBSYSAPI VOID *KeSetEvent;
|
||||||
|
XBSYSAPI VOID *KeSetEventBoostPriority;
|
||||||
|
XBSYSAPI VOID *KeSetPriorityProcess;
|
||||||
|
|
||||||
|
//XBSYSAPI VOID *KeSetPriorityThread;
|
||||||
|
XBSYSAPI EXPORTNUM(148) BOOLEAN NTAPI KeSetPriorityThread
|
||||||
|
(
|
||||||
|
IN PKTHREAD Thread,
|
||||||
|
IN PVOID Priority
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeSetTimer
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(149) BOOLEAN NTAPI KeSetTimer
|
||||||
|
(
|
||||||
|
IN PKTIMER Timer,
|
||||||
|
IN LARGE_INTEGER DueTime,
|
||||||
|
IN PKDPC Dpc OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeSetTimerEx
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(150) BOOLEAN NTAPI KeSetTimerEx
|
||||||
|
(
|
||||||
|
IN PKTIMER Timer,
|
||||||
|
IN LARGE_INTEGER DueTime,
|
||||||
|
IN LONG Period OPTIONAL,
|
||||||
|
IN PKDPC Dpc OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeStallExecutionProcessor;
|
||||||
|
XBSYSAPI VOID *KeSuspendThread;
|
||||||
|
XBSYSAPI VOID *KeSynchronizeExecution;
|
||||||
|
XBSYSAPI VOID *KeSystemTime;
|
||||||
|
XBSYSAPI VOID *KeTestAlertThread;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KeTickCount
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(156) volatile DWORD KeTickCount;
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KeTimeIncrement;
|
||||||
|
XBSYSAPI VOID *KeWaitForMultipleObjects;
|
||||||
|
XBSYSAPI VOID *KeWaitForSingleObject;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : mm.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Memory Manager* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_MM_H
|
||||||
|
#define XBOXKRNL_MM_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmGlobalData;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmAllocateContiguousMemory
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Allocates a range of physically contiguous, cache-aligned
|
||||||
|
// * memory from nonpaged pool (main pool on xbox).
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(165) PVOID NTAPI MmAllocateContiguousMemory
|
||||||
|
(
|
||||||
|
IN ULONG NumberOfBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmAllocateContiguousMemoryEx
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(166) PVOID NTAPI MmAllocateContiguousMemoryEx
|
||||||
|
(
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN PHYSICAL_ADDRESS LowestAcceptableAddress,
|
||||||
|
IN PHYSICAL_ADDRESS HighestAcceptableAddress,
|
||||||
|
IN ULONG Alignment OPTIONAL,
|
||||||
|
IN ULONG ProtectionType
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmAllocateSystemMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(167) PVOID NTAPI MmAllocateSystemMemory
|
||||||
|
(
|
||||||
|
ULONG NumberOfBytes,
|
||||||
|
ULONG Protect
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmClaimGpuInstanceMemory;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmCreateKernelStack
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(169) PVOID NTAPI MmCreateKernelStack
|
||||||
|
(
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN ULONG Unknown
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmDeleteKernelStack
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(170) VOID NTAPI MmDeleteKernelStack
|
||||||
|
(
|
||||||
|
IN PVOID EndAddress,
|
||||||
|
IN PVOID BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmFreeContiguousMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(171) VOID NTAPI MmFreeContiguousMemory
|
||||||
|
(
|
||||||
|
IN PVOID BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmFreeSystemMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(172) NTSTATUS NTAPI MmFreeSystemMemory
|
||||||
|
(
|
||||||
|
PVOID BaseAddress,
|
||||||
|
ULONG NumberOfBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmGetPhysicalAddress
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(173) PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress
|
||||||
|
(
|
||||||
|
IN PVOID BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmIsAddressValid;
|
||||||
|
|
||||||
|
//XBSYSAPI VOID *MmLockUnlockBufferPages;
|
||||||
|
XBSYSAPI EXPORTNUM(175) PHYSICAL_ADDRESS NTAPI MmLockUnlockBufferPages
|
||||||
|
(
|
||||||
|
IN PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN ULONG Protect
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmLockUnlockPhysicalPage;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmMapIoSpace
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(177) PVOID NTAPI MmMapIoSpace
|
||||||
|
(
|
||||||
|
IN PHYSICAL_ADDRESS PhysicalAddress,
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN ULONG Protect
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmPersistContiguousMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(178) VOID NTAPI MmPersistContiguousMemory
|
||||||
|
(
|
||||||
|
IN PVOID BaseAddress,
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN BOOLEAN Persist
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmQueryAddressProtect;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmQueryAllocationSize
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(180) ULONG NTAPI MmQueryAllocationSize
|
||||||
|
(
|
||||||
|
IN PVOID BaseAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmQueryStatistics
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(181) NTSTATUS NTAPI MmQueryStatistics
|
||||||
|
(
|
||||||
|
OUT PMM_STATISTICS MemoryStatistics
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MmSetAddressProtect
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(182) VOID NTAPI MmSetAddressProtect
|
||||||
|
(
|
||||||
|
IN PVOID BaseAddress,
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN ULONG NewProtect
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmUnmapIoSpace;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,412 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : nt.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *NT* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_NT_H
|
||||||
|
#define XBOXKRNL_NT_H
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtAllocateVirtualMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(184) NTSTATUS NTAPI NtAllocateVirtualMemory
|
||||||
|
(
|
||||||
|
IN OUT PVOID *BaseAddress,
|
||||||
|
IN ULONG ZeroBits,
|
||||||
|
IN OUT PULONG AllocationSize,
|
||||||
|
IN DWORD AllocationType,
|
||||||
|
IN DWORD Protect
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtCancelTimer;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtClearEvent
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(186) NTSTATUS NTAPI NtClearEvent
|
||||||
|
(
|
||||||
|
IN HANDLE EventHandle
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtClose
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Closes an object handle
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(187) NTSTATUS NTAPI NtClose
|
||||||
|
(
|
||||||
|
IN HANDLE Handle
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtCreateDirectoryObject;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtCreateEvent
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(189) NTSTATUS NTAPI NtCreateEvent
|
||||||
|
(
|
||||||
|
OUT PHANDLE EventHandle,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
||||||
|
IN EVENT_TYPE EventType,
|
||||||
|
IN BOOLEAN InitialState
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtCreateFile
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Causes a new file or directory to be created, or opens and
|
||||||
|
// * existing file, device, directory, or volume, giving the caller
|
||||||
|
// * a handle for the file object.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(190) NTSTATUS NTAPI NtCreateFile
|
||||||
|
(
|
||||||
|
OUT PHANDLE FileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN PLARGE_INTEGER AllocationSize OPTIONAL,
|
||||||
|
IN ULONG FileAttributes,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG CreateDisposition,
|
||||||
|
IN ULONG CreateOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtCreateIoCompletion;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtCreateMutant
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(192) NTSTATUS NTAPI NtCreateMutant
|
||||||
|
(
|
||||||
|
OUT PHANDLE MutantHandle,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN BOOLEAN InitialOwner
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtCreateSemaphore
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(193) NTSTATUS NTAPI NtCreateSemaphore
|
||||||
|
(
|
||||||
|
OUT PHANDLE SemaphoreHandle,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
IN ULONG InitialCount,
|
||||||
|
IN ULONG MaximumCount
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtCreateTimer;
|
||||||
|
XBSYSAPI VOID *NtDeleteFile;
|
||||||
|
XBSYSAPI VOID *NtDeviceIoControlFile;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtDuplicateObject
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(197) NTSTATUS NTAPI NtDuplicateObject
|
||||||
|
(
|
||||||
|
PVOID SourceHandle,
|
||||||
|
PVOID *TargetHandle,
|
||||||
|
DWORD Options
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtFlushBuffersFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(198) NTSTATUS NTAPI NtFlushBuffersFile
|
||||||
|
(
|
||||||
|
PVOID FileHandle,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtFreeVirtualMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(199) NTSTATUS NTAPI NtFreeVirtualMemory
|
||||||
|
(
|
||||||
|
IN OUT PVOID *BaseAddress,
|
||||||
|
IN OUT PULONG FreeSize,
|
||||||
|
IN ULONG FreeType
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtFsControlFile;
|
||||||
|
XBSYSAPI VOID *NtOpenDirectoryObject;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtOpenFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(202) NTSTATUS NTAPI NtOpenFile
|
||||||
|
(
|
||||||
|
OUT PHANDLE FileHandle,
|
||||||
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN ULONG ShareAccess,
|
||||||
|
IN ULONG OpenOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtOpenSymbolicLinkObject;
|
||||||
|
XBSYSAPI VOID *NtProtectVirtualMemory;
|
||||||
|
XBSYSAPI VOID *NtPulseEvent;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtQueueApcThread
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(206) NTSTATUS NTAPI NtQueueApcThread
|
||||||
|
(
|
||||||
|
IN HANDLE ThreadHandle,
|
||||||
|
IN PIO_APC_ROUTINE ApcRoutine,
|
||||||
|
IN PVOID ApcRoutineContext OPTIONAL,
|
||||||
|
IN PIO_STATUS_BLOCK ApcStatusBlock OPTIONAL,
|
||||||
|
IN ULONG ApcReserved OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtQueryDirectoryFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(207) NTSTATUS NTAPI NtQueryDirectoryFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
IN HANDLE Event OPTIONAL,
|
||||||
|
IN PVOID ApcRoutine, // Todo: define this routine's prototype
|
||||||
|
IN PVOID ApcContext,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT FILE_DIRECTORY_INFORMATION *FileInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN FILE_INFORMATION_CLASS FileInformationClass,
|
||||||
|
IN PSTRING FileMask,
|
||||||
|
IN BOOLEAN RestartScan
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtQueryDirectoryObject;
|
||||||
|
XBSYSAPI VOID *NtQueryEvent;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtQueryFullAttributesFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(210) NTSTATUS NTAPI NtQueryFullAttributesFile
|
||||||
|
(
|
||||||
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
OUT PVOID Attributes
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtQueryInformationFile
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Return various kinds of information about a given file object.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(211) NTSTATUS NTAPI NtQueryInformationFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT PVOID FileInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN FILE_INFORMATION_CLASS FileInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtQueryIoCompletion;
|
||||||
|
XBSYSAPI VOID *NtQueryMutant;
|
||||||
|
XBSYSAPI VOID *NtQuerySemaphore;
|
||||||
|
XBSYSAPI VOID *NtQuerySymbolicLinkObject;
|
||||||
|
XBSYSAPI VOID *NtQueryTimer;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtQueryVirtualMemory
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(217) NTSTATUS NTAPI NtQueryVirtualMemory
|
||||||
|
(
|
||||||
|
IN PVOID BaseAddress,
|
||||||
|
OUT PMEMORY_BASIC_INFORMATION Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtQueryVolumeInformationFile
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(218) NTSTATUS NTAPI NtQueryVolumeInformationFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT PFILE_FS_SIZE_INFORMATION FileInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN FS_INFORMATION_CLASS FileInformationClass
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtReadFile
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Read data from an opened file.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(219) NTSTATUS NTAPI NtReadFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle, // TODO: correct paramters
|
||||||
|
IN HANDLE Event OPTIONAL,
|
||||||
|
IN PVOID ApcRoutine OPTIONAL,
|
||||||
|
IN PVOID ApcContext,
|
||||||
|
OUT PVOID IoStatusBlock,
|
||||||
|
OUT PVOID Buffer,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN PLARGE_INTEGER ByteOffset OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtReadFileScatter;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtReleaseMutant
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(221) NTSTATUS NTAPI NtReleaseMutant
|
||||||
|
(
|
||||||
|
IN HANDLE MutantHandle,
|
||||||
|
OUT PLONG PreviousCount
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtReleaseSemaphore
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(222) NTSTATUS NTAPI NtReleaseSemaphore
|
||||||
|
(
|
||||||
|
IN HANDLE SemaphoreHandle,
|
||||||
|
IN ULONG ReleaseCount,
|
||||||
|
OUT PULONG PreviousCount
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtRemoveIoCompletion;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtResumeThread
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(224) NTSTATUS NTAPI NtResumeThread
|
||||||
|
(
|
||||||
|
IN HANDLE ThreadHandle,
|
||||||
|
OUT PULONG PreviousSuspendCount
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtSetEvent
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(225) NTSTATUS NTAPI NtSetEvent
|
||||||
|
(
|
||||||
|
IN HANDLE EventHandle,
|
||||||
|
OUT PLONG PreviousState
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtSetInformationFile
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Changes various kinds of information about a given file object.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(226) NTSTATUS NTAPI NtSetInformationFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle, // TODO: correct paramters
|
||||||
|
OUT PVOID IoStatusBlock,
|
||||||
|
IN PVOID FileInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN ULONG FileInformationClass
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtSetIoCompletion;
|
||||||
|
XBSYSAPI VOID *NtSetSystemTime;
|
||||||
|
XBSYSAPI VOID *NtSetTimerEx;
|
||||||
|
XBSYSAPI VOID *NtSignalAndWaitForSingleObjectEx;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtSuspendThread
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(231) NTSTATUS NTAPI NtSuspendThread
|
||||||
|
(
|
||||||
|
IN HANDLE ThreadHandle,
|
||||||
|
OUT PULONG PreviousSuspendCount OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtUserIoApcDispatcher
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(232) VOID NTAPI NtUserIoApcDispatcher
|
||||||
|
(
|
||||||
|
PVOID ApcContext,
|
||||||
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
ULONG Reserved
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtWaitForSingleObject
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Put the current thread into a wait state until the given
|
||||||
|
// * dispatcher object is set to a signaled state or (optionally)
|
||||||
|
// * until the wait times out.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(233) NTSTATUS NTAPI NtWaitForSingleObject
|
||||||
|
(
|
||||||
|
IN HANDLE Handle,
|
||||||
|
IN BOOLEAN Alertable,
|
||||||
|
IN PVOID Timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtWaitForSingleObjectEx
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(234) NTSTATUS NTAPI NtWaitForSingleObjectEx
|
||||||
|
(
|
||||||
|
IN HANDLE Handle,
|
||||||
|
IN CHAR WaitMode,
|
||||||
|
IN BOOLEAN Alertable,
|
||||||
|
IN PLARGE_INTEGER Timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtWaitForMultipleObjectsEx
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(235) NTSTATUS NTAPI NtWaitForMultipleObjectsEx
|
||||||
|
(
|
||||||
|
IN ULONG Count,
|
||||||
|
IN HANDLE *Handles,
|
||||||
|
IN WAIT_TYPE WaitType,
|
||||||
|
IN CHAR WaitMode,
|
||||||
|
IN BOOLEAN Alertable,
|
||||||
|
IN PLARGE_INTEGER Timeout
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtWriteFile
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Write data to an opened file.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(236) NTSTATUS NTAPI NtWriteFile
|
||||||
|
(
|
||||||
|
IN HANDLE FileHandle, // TODO: correct paramters
|
||||||
|
IN PVOID Event,
|
||||||
|
IN PVOID ApcRoutine,
|
||||||
|
IN PVOID ApcContext,
|
||||||
|
OUT PVOID IoStatusBlock,
|
||||||
|
IN PVOID Buffer,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN PLARGE_INTEGER ByteOffset
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *NtWriteFileGather;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NtYieldExecution
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(238) VOID NTAPI NtYieldExecution();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : ob.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Object Manager* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_OB_H
|
||||||
|
#define XBOXKRNL_OB_H
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ObCreateObject;
|
||||||
|
XBSYSAPI VOID *ObDirectoryObjectType;
|
||||||
|
XBSYSAPI VOID *ObInsertObject;
|
||||||
|
XBSYSAPI VOID *ObMakeTemporaryObject;
|
||||||
|
XBSYSAPI VOID *ObOpenObjectByName;
|
||||||
|
XBSYSAPI VOID *ObOpenObjectByPointer;
|
||||||
|
XBSYSAPI VOID *ObpObjectHandleTable;
|
||||||
|
|
||||||
|
|
||||||
|
//XBSYSAPI VOID *ObReferenceObjectByHandle;
|
||||||
|
XBSYSAPI EXPORTNUM(246) BOOLEAN NTAPI ObReferenceObjectByHandle
|
||||||
|
( unsigned int a,
|
||||||
|
unsigned int b,
|
||||||
|
unsigned int c
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
XBSYSAPI VOID *ObReferenceObjectByName;
|
||||||
|
XBSYSAPI VOID *ObReferenceObjectByPointer;
|
||||||
|
XBSYSAPI VOID *ObSymbolicLinkObjectType;
|
||||||
|
XBSYSAPI VOID *ObfDereferenceObject;
|
||||||
|
XBSYSAPI VOID *ObfReferenceObject;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : ps.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Process Structure* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_PS_H
|
||||||
|
#define XBOXKRNL_PS_H
|
||||||
|
|
||||||
|
//XBSYSAPI VOID *PsCreateSystemThread;
|
||||||
|
|
||||||
|
XBSYSAPI EXPORTNUM(254) NTSTATUS NTAPI PsCreateSystemThread
|
||||||
|
(
|
||||||
|
PULONG lpThreadAttributes, // SD
|
||||||
|
DWORD dwStackSize, // initial stack size
|
||||||
|
PKSTART_ROUTINE lpStartAddress, // thread function
|
||||||
|
VOID* lpParameter, // thread argument
|
||||||
|
DWORD dwCreationFlags, // creation option
|
||||||
|
DWORD* lpThreadId // thread identifier
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * PsCreateSystemThreadEx
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(255) NTSTATUS NTAPI PsCreateSystemThreadEx
|
||||||
|
(
|
||||||
|
OUT PHANDLE ThreadHandle,
|
||||||
|
IN ULONG ThreadExtraSize,
|
||||||
|
IN ULONG KernelStackSize,
|
||||||
|
IN ULONG TlsDataSize,
|
||||||
|
OUT PULONG ThreadId OPTIONAL,
|
||||||
|
IN PVOID StartContext1,
|
||||||
|
IN PVOID StartContext2,
|
||||||
|
IN BOOLEAN CreateSuspended,
|
||||||
|
IN BOOLEAN DebugStack,
|
||||||
|
IN PKSTART_ROUTINE StartRoutine
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *PsQueryStatistics;
|
||||||
|
XBSYSAPI VOID *PsSetCreateThreadNotifyRoutine;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * PsTerminateSystemThread
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(258) VOID NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus);
|
||||||
|
|
||||||
|
//XBSYSAPI VOID *PsThreadObjectType;
|
||||||
|
XBSYSAPI EXPORTNUM(259) volatile DWORD PsThreadObjectType;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,257 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : ps.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel *Run-time Library* Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOXKRNL_RTL_H
|
||||||
|
#define XBOXKRNL_RTL_H
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlAnsiStringToUnicodeString
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(260) NTSTATUS NTAPI RtlAnsiStringToUnicodeString
|
||||||
|
(
|
||||||
|
PUNICODE_STRING DestinationString,
|
||||||
|
PSTRING SourceString,
|
||||||
|
UCHAR AllocateDestinationString
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlAppendStringToString
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(261) NTSTATUS NTAPI RtlAppendStringToString
|
||||||
|
(
|
||||||
|
IN PSTRING Destination,
|
||||||
|
IN PSTRING Source
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlAppendUnicodeStringToString;
|
||||||
|
XBSYSAPI VOID *RtlAppendUnicodeToString;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlAssert
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(264) VOID NTAPI RtlAssert
|
||||||
|
(
|
||||||
|
PVOID FailedAssertion,
|
||||||
|
PVOID FileName,
|
||||||
|
ULONG LineNumber,
|
||||||
|
PCHAR Message
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlCaptureContext;
|
||||||
|
XBSYSAPI VOID *RtlCaptureStackBackTrace;
|
||||||
|
XBSYSAPI VOID *RtlCharToInteger;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlCompareMemory
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * compare block of memory, return number of equivalent bytes.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(268) SIZE_T NTAPI RtlCompareMemory
|
||||||
|
(
|
||||||
|
IN CONST VOID *Source1,
|
||||||
|
IN CONST VOID *Source2,
|
||||||
|
IN SIZE_T Length
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlCompareMemoryUlong;
|
||||||
|
XBSYSAPI VOID *RtlCompareString;
|
||||||
|
XBSYSAPI VOID *RtlCompareUnicodeString;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlCopyString
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Copy Source to Destination
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(272) VOID NTAPI RtlCopyString
|
||||||
|
(
|
||||||
|
IN OUT PVOID Destination, // TODO: should be STRING
|
||||||
|
IN PVOID Source OPTIONAL // TODO: should be STRING
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlCopyUnicodeString;
|
||||||
|
XBSYSAPI VOID *RtlCreateUnicodeString;
|
||||||
|
XBSYSAPI VOID *RtlDowncaseUnicodeChar;
|
||||||
|
XBSYSAPI VOID *RtlDowncaseUnicodeString;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlEnterCriticalSection
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(277) VOID NTAPI RtlEnterCriticalSection
|
||||||
|
(
|
||||||
|
IN PRTL_CRITICAL_SECTION CriticalSection
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlEnterCriticalSectionAndRegion;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlEnterCriticalSection
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(279) BOOLEAN NTAPI RtlEqualString
|
||||||
|
(
|
||||||
|
IN PSTRING String1,
|
||||||
|
IN PSTRING String2,
|
||||||
|
IN BOOLEAN CaseSensitive
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlEqualUnicodeString;
|
||||||
|
XBSYSAPI VOID *RtlExtendedIntegerMultiply;
|
||||||
|
XBSYSAPI VOID *RtlExtendedLargeIntegerDivide;
|
||||||
|
XBSYSAPI VOID *RtlExtendedMagicDivide;
|
||||||
|
XBSYSAPI VOID *RtlFillMemory;
|
||||||
|
XBSYSAPI VOID *RtlFillMemoryUlong;
|
||||||
|
XBSYSAPI VOID *RtlFreeAnsiString;
|
||||||
|
XBSYSAPI VOID *RtlFreeUnicodeString;
|
||||||
|
XBSYSAPI VOID *RtlGetCallersAddress;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlInitAnsiString
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Initialize a counted ANSI string.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(289) VOID NTAPI RtlInitAnsiString
|
||||||
|
(
|
||||||
|
IN OUT PANSI_STRING DestinationString,
|
||||||
|
IN PCSZ SourceString
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlInitUnicodeString;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlInitializeCriticalSection
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(291) VOID NTAPI RtlInitializeCriticalSection
|
||||||
|
(
|
||||||
|
IN PRTL_CRITICAL_SECTION CriticalSection
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlIntegerToChar;
|
||||||
|
XBSYSAPI VOID *RtlIntegerToUnicodeString;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlLeaveCriticalSection
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(294) VOID NTAPI RtlLeaveCriticalSection
|
||||||
|
(
|
||||||
|
IN PRTL_CRITICAL_SECTION CriticalSection
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlLeaveCriticalSectionAndRegion;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlLowerChar
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(296) CHAR NTAPI RtlLowerChar(CHAR Character);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlMapGenericMask;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlMoveMemory
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Move memory either forward or backward, aligned or unaligned,
|
||||||
|
// * in 4-byte blocks, followed by any remaining blocks.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(298) VOID NTAPI RtlMoveMemory
|
||||||
|
(
|
||||||
|
IN VOID UNALIGNED *Destination,
|
||||||
|
IN CONST VOID UNALIGNED *Source,
|
||||||
|
IN SIZE_T Length
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlMultiByteToUnicodeN;
|
||||||
|
XBSYSAPI VOID *RtlMultiByteToUnicodeSize;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlNtStatusToDosError
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(301) ULONG NTAPI RtlNtStatusToDosError
|
||||||
|
(
|
||||||
|
IN NTSTATUS Status
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlRaiseException;
|
||||||
|
XBSYSAPI VOID *RtlRaiseStatus;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlTimeFieldsToTime
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(304) BOOLEAN NTAPI RtlTimeFieldsToTime
|
||||||
|
(
|
||||||
|
IN PTIME_FIELDS TimeFields,
|
||||||
|
OUT PLARGE_INTEGER Time
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlTimeToTimeFields
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(305) VOID NTAPI RtlTimeToTimeFields
|
||||||
|
(
|
||||||
|
IN PLARGE_INTEGER Time,
|
||||||
|
OUT PTIME_FIELDS TimeFields
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlTryEnterCriticalSection
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(306) BOOLEAN NTAPI RtlTryEnterCriticalSection
|
||||||
|
(
|
||||||
|
IN PRTL_CRITICAL_SECTION CriticalSection
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlUlongByteSwap;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlUnicodeStringToAnsiString
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(308) NTSTATUS NTAPI RtlUnicodeStringToAnsiString
|
||||||
|
(
|
||||||
|
IN OUT PSTRING DestinationString,
|
||||||
|
IN PUNICODE_STRING SourceString,
|
||||||
|
IN BOOLEAN AllocateDestinationString
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlUnicodeStringToInteger;
|
||||||
|
XBSYSAPI VOID *RtlUnicodeToMultiByteN;
|
||||||
|
XBSYSAPI VOID *RtlUnicodeToMultiByteSize;
|
||||||
|
XBSYSAPI VOID *RtlUnwind;
|
||||||
|
XBSYSAPI VOID *RtlUpcaseUnicodeChar;
|
||||||
|
XBSYSAPI VOID *RtlUpcaseUnicodeString;
|
||||||
|
XBSYSAPI VOID *RtlUpcaseUnicodeToMultiByteN;
|
||||||
|
XBSYSAPI VOID *RtlUpperChar;
|
||||||
|
XBSYSAPI VOID *RtlUpperString;
|
||||||
|
XBSYSAPI VOID *RtlUshortByteSwap;
|
||||||
|
XBSYSAPI VOID *RtlWalkFrameChain;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * RtlZeroMemory
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Fill a block of memory with zeros.
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(320) VOID NTAPI RtlZeroMemory
|
||||||
|
(
|
||||||
|
IN VOID UNALIGNED *Destination,
|
||||||
|
IN SIZE_T Length
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *RtlRip;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xbox.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Kernel Declarations
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XBOX_H
|
||||||
|
#define XBOX_H
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * AvGetSavedDataAddress
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(1) PVOID NTAPI AvGetSavedDataAddress();
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * AvSendTVEncoderOption
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(2) VOID NTAPI AvSendTVEncoderOption
|
||||||
|
(
|
||||||
|
IN PVOID RegisterBase,
|
||||||
|
IN ULONG Option,
|
||||||
|
IN ULONG Param,
|
||||||
|
OUT ULONG *Result
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * AvSetDisplayMode
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(4) ULONG NTAPI AvSetDisplayMode
|
||||||
|
(
|
||||||
|
IN PVOID RegisterBase,
|
||||||
|
IN ULONG Step,
|
||||||
|
IN ULONG Mode,
|
||||||
|
IN ULONG Format,
|
||||||
|
IN ULONG Pitch,
|
||||||
|
IN ULONG FrameBuffer
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * AvSetSavedDataAddress
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(4) VOID NTAPI AvSetSavedDataAddress
|
||||||
|
(
|
||||||
|
IN PVOID Address
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *FscGetCacheSize;
|
||||||
|
XBSYSAPI VOID *FscInvalidateIdleBlocks;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * FscSetCacheSize
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(37) LONG NTAPI FscSetCacheSize(ULONG uCachePages);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KdDebuggerEnabled;
|
||||||
|
XBSYSAPI VOID *KdDebuggerNotPresent;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KfRaiseIrql
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(160) UCHAR NTAPI KfRaiseIrql
|
||||||
|
(
|
||||||
|
IN UCHAR NewIrql
|
||||||
|
);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * KfLowerIrql
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(161) UCHAR NTAPI KfLowerIrql
|
||||||
|
(
|
||||||
|
IN UCHAR NewIrql
|
||||||
|
);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *KiBugCheckData;
|
||||||
|
XBSYSAPI VOID *KiUnlockDispatcherDatabase;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * LaunchDataPage (actually a pointer)
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(164) PLAUNCH_DATA_PAGE LaunchDataPage;
|
||||||
|
|
||||||
|
XBSYSAPI VOID *PhyGetLinkState;
|
||||||
|
XBSYSAPI VOID *PhyInitialize;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XboxEEPROMKey
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(321) UCHAR XboxEEPROMKey[16];
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XboxHardwareInfo
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(322) XBOX_HARDWARE_INFO XboxHardwareInfo;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XboxHDKey
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(323) UCHAR XboxHDKey[16];
|
||||||
|
|
||||||
|
XBSYSAPI VOID *XboxKrnlVersion;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XboxSignatureKey
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(325) BYTE XboxSignatureKey[16];
|
||||||
|
|
||||||
|
XBSYSAPI VOID *XeImageFileName;
|
||||||
|
XBSYSAPI VOID *XeLoadSection;
|
||||||
|
XBSYSAPI VOID *XeUnloadSection;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XcSHAInit
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(335) VOID NTAPI XcSHAInit(UCHAR *pbSHAContext);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XcSHAUpdate
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(336) VOID NTAPI XcSHAUpdate(UCHAR *pbSHAContext, UCHAR *pbInput, ULONG dwInputLength);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XcSHAFinal
|
||||||
|
// ******************************************************************
|
||||||
|
XBSYSAPI EXPORTNUM(337) VOID NTAPI XcSHAFinal(UCHAR *pbSHAContext, UCHAR *pbDigest);
|
||||||
|
|
||||||
|
XBSYSAPI VOID *XcRC4Key;
|
||||||
|
XBSYSAPI VOID *XcRC4Crypt;
|
||||||
|
XBSYSAPI VOID *XcHMAC;
|
||||||
|
XBSYSAPI VOID *XcPKEncPublic;
|
||||||
|
XBSYSAPI VOID *XcPKDecPrivate;
|
||||||
|
XBSYSAPI VOID *XcPKGetKeyLen;
|
||||||
|
XBSYSAPI VOID *XcVerifyPKCS1Signature;
|
||||||
|
XBSYSAPI VOID *XcModExp;
|
||||||
|
XBSYSAPI VOID *XcDESKeyParity;
|
||||||
|
XBSYSAPI VOID *XcKeyTable;
|
||||||
|
XBSYSAPI VOID *XcBlockCrypt;
|
||||||
|
XBSYSAPI VOID *XcBlockCryptCBC;
|
||||||
|
XBSYSAPI VOID *XcCryptService;
|
||||||
|
XBSYSAPI VOID *XcUpdateCrypto;
|
||||||
|
XBSYSAPI VOID *XboxLANKey;
|
||||||
|
XBSYSAPI VOID *XboxAlternateSignatureKeys;
|
||||||
|
XBSYSAPI VOID *XePublicKeyData;
|
||||||
|
XBSYSAPI VOID *IdexChannelObject;
|
||||||
|
XBSYSAPI VOID *xsnprintf; // prefixed with "x" to avoid xlibc collisions
|
||||||
|
XBSYSAPI VOID *xsprintf; // ""
|
||||||
|
XBSYSAPI VOID *xvsnprintf; // ""
|
||||||
|
XBSYSAPI VOID *xvsprintf; // ""
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,58 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : bitmap.h
|
||||||
|
// *
|
||||||
|
// * note : Simple 2D Bitmap library
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef XBITMAP_H
|
||||||
|
#define XBITMAP_H
|
||||||
|
|
||||||
|
#include "openxdk.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//you shouldn't need to mess with this if you use the functions in this lib,
|
||||||
|
//but feel free to :)
|
||||||
|
//data = the raw 32-bit bitmap data
|
||||||
|
//w = width in pixels
|
||||||
|
//h = height in pixels
|
||||||
|
//pitch = memory distance between rows, in pixels (you don't need to care)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32 *data;
|
||||||
|
int w, h;
|
||||||
|
int pitch; // pitch is in pixels, not bytes as many libs do
|
||||||
|
// will in most cases be same as w
|
||||||
|
} Bitmap;
|
||||||
|
|
||||||
|
|
||||||
|
//creates a 32-bit bitmap, sized WxH
|
||||||
|
Bitmap *create_bitmap(int w, int h);
|
||||||
|
|
||||||
|
//gets the screen bitmap, so you can draw to it easily
|
||||||
|
//you have to have inited VGA before calling this
|
||||||
|
//also currently UNTESTED, but should work :D
|
||||||
|
Bitmap *get_screen_bitmap();
|
||||||
|
|
||||||
|
//destroys a bitmap
|
||||||
|
void destroy_bitmap(Bitmap *bmp);
|
||||||
|
|
||||||
|
//image loaders
|
||||||
|
Bitmap *load_tga(char *filename);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,62 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : blit.c
|
||||||
|
// *
|
||||||
|
// * note : blitter with clipping, uses any one of the blitters from
|
||||||
|
// * blitters.h per scanline
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef XBLIT_H
|
||||||
|
#define XBLIT_H
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
#include "xgfx2d/bitmap.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// INSTRUCTIONS
|
||||||
|
// ************
|
||||||
|
// pass in a blitter from blitters.h
|
||||||
|
// dx,dy = destination x,y
|
||||||
|
// sx,sy = source x,y
|
||||||
|
// sw,sh = width and height of the copy
|
||||||
|
// blitter = copying method, check blitters.h
|
||||||
|
// parameter = if a blitter method needs a parameter pass it here,
|
||||||
|
// else pass 0
|
||||||
|
// Sample:
|
||||||
|
// blit(source,dest,10,10,0,0,20,20,alphavalue_blit,128)
|
||||||
|
// will blit the topleft 20x20 of source to 10,10 in dest,
|
||||||
|
// blended ~50% (128/255)
|
||||||
|
void blit(Bitmap *dest, Bitmap *src,
|
||||||
|
int dx, int dy,
|
||||||
|
int sx, int sy, int sw, int sh,
|
||||||
|
void (*blitter)(uint32*,uint32*,int,int),
|
||||||
|
int parameter);
|
||||||
|
|
||||||
|
// just copies entire source bitmap to 0,0 of dest
|
||||||
|
void full_blit(Bitmap *dest, Bitmap *src,
|
||||||
|
void (*blitter)(uint32*,uint32*,int,int),
|
||||||
|
int parameter);
|
||||||
|
|
||||||
|
// shortcut to copy entire source bitmap to a coordinate in dest
|
||||||
|
// use for simple sprites
|
||||||
|
void blit_at(Bitmap *dest, Bitmap *src,
|
||||||
|
int x, int y,
|
||||||
|
void (*blitter)(uint32*,uint32*,int,int),
|
||||||
|
int parameter);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,51 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : blitters.h
|
||||||
|
// *
|
||||||
|
// * note : A bunch of fast MMX blitters of various kinds
|
||||||
|
// * Alpha blending, additive blending, you name it
|
||||||
|
// * Many non-ASM substitutes needs writing if we're gonna
|
||||||
|
// * support GNU C
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef XBLITTERS_H
|
||||||
|
#define XBLITTERS_H
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
#include "xgfx2d/bitmap.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DECLARE_BLITTER(name,parameter) \
|
||||||
|
void name (uint32 *s, uint32 *d, int len, int parameter)
|
||||||
|
|
||||||
|
|
||||||
|
//you're supposed to pass these ones into blit, check blit.h
|
||||||
|
|
||||||
|
DECLARE_BLITTER(normal_blit,none); //just a straight blit
|
||||||
|
DECLARE_BLITTER(sprite_blit,none); //ignores 0xFF00FF
|
||||||
|
DECLARE_BLITTER(additive_blit,none); //adds images together
|
||||||
|
DECLARE_BLITTER(additive_alpha_blit,alpha); //adds image multiplied with alpha to the other one
|
||||||
|
DECLARE_BLITTER(alpha_blit,none); //alpha from image! yes, a true alpha blender
|
||||||
|
DECLARE_BLITTER(alphavalue_blit,alpha); //1 alpha value for the entire image
|
||||||
|
DECLARE_BLITTER(alphavalue_sprite_blit,none); //1 alpha value for the entire image, ignores black
|
||||||
|
DECLARE_BLITTER(alphavalue50_blit,none); //50% alpha value for the entire image (faster?)
|
||||||
|
DECLARE_BLITTER(multiply_blit,none); //like multiply in photoshop
|
||||||
|
DECLARE_BLITTER(invert_blit,none); //odd :)
|
||||||
|
DECLARE_BLITTER(subtractive_blit,none); //subtracts one image from the other
|
||||||
|
DECLARE_BLITTER(colorize_sprite_blit,color); //uhm, for drawing colored fonts
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : charmap.h
|
||||||
|
// *
|
||||||
|
// * note : Character map format : U16 per entry
|
||||||
|
// *
|
||||||
|
// * TxPPPIII_CCCCCCCC
|
||||||
|
// * T = character touched flag
|
||||||
|
// * x = unused
|
||||||
|
// * P = paper colour
|
||||||
|
// * I = Ink colour
|
||||||
|
// * C = character
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __CHARMAP_H_
|
||||||
|
#define __CHARMAP_H_
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// **************************************************************************************************************
|
||||||
|
//
|
||||||
|
// constants: #defines, enums etc.
|
||||||
|
//
|
||||||
|
// **************************************************************************************************************
|
||||||
|
#define CHARMAP_DEBUG 0x80000000 // character map debug mode, force update after every write
|
||||||
|
// slow, but visible. Does NOT update on single character outs
|
||||||
|
|
||||||
|
#define MAP_TOUCHED 0x8000 // this character has been touched, and needs redrawing
|
||||||
|
|
||||||
|
#define FONT_WIDTH 8 // our assumed character width
|
||||||
|
#define FONT_HEIGHT 15 // and height. These could be variable for user fonts
|
||||||
|
|
||||||
|
#define CHARMAP_BLACK (0) // Genaral character attribute colours
|
||||||
|
#define CHARMAP_BLUE (1)
|
||||||
|
#define CHARMAP_GREEN (2)
|
||||||
|
#define CHARMAP_RED (3)
|
||||||
|
#define CHARMAP_CYAN (4)
|
||||||
|
#define CHARMAP_YELLOW (5)
|
||||||
|
#define CHARMAP_PINK (6)
|
||||||
|
#define CHARMAP_WHITE (7)
|
||||||
|
|
||||||
|
#define INK_BLACK (0<<8) // INK attribute colours
|
||||||
|
#define INK_BLUE (1<<8)
|
||||||
|
#define INK_GREEN (2<<8)
|
||||||
|
#define INK_RED (3<<8)
|
||||||
|
#define INK_CYAN (4<<8)
|
||||||
|
#define INK_YELLOW (5<<8)
|
||||||
|
#define INK_PINK (6<<8)
|
||||||
|
#define INK_WHITE (7<<8)
|
||||||
|
|
||||||
|
#define PAPER_BLACK (0<<11) // PAPER attribute colours
|
||||||
|
#define PAPER_BLUE (1<<11)
|
||||||
|
#define PAPER_GREEN (2<<11)
|
||||||
|
#define PAPER_RED (3<<11)
|
||||||
|
#define PAPER_CYAN (4<<11)
|
||||||
|
#define PAPER_YELLOW (5<<11)
|
||||||
|
#define PAPER_PINK (6<<11)
|
||||||
|
#define PAPER_WHITE (7<<11)
|
||||||
|
|
||||||
|
// **************************************************************************************************************
|
||||||
|
//
|
||||||
|
// Structures
|
||||||
|
//
|
||||||
|
// **************************************************************************************************************
|
||||||
|
|
||||||
|
// Charmap structure
|
||||||
|
typedef struct SCharMap
|
||||||
|
{
|
||||||
|
u32 Flags; // system flags and options
|
||||||
|
u8* pBitmap; // pointer to our screen bitmap (pix width*pix height)
|
||||||
|
u16* pCharMap; // pointer to actuall character array
|
||||||
|
s32 x,y; // screen X,Y
|
||||||
|
s32 width,height; // width and height
|
||||||
|
s32 pixwidth,pixheight; // pixel width and height
|
||||||
|
|
||||||
|
u16 attrib_char; // clear attrib and character
|
||||||
|
|
||||||
|
s32 curx,cury; // current Cursor X,Y
|
||||||
|
s32 wx1,wy1,wx2,wy2; // Text window
|
||||||
|
|
||||||
|
}SCharMap,*PCharMap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// **************************************************************************************************************
|
||||||
|
//
|
||||||
|
// Public functions
|
||||||
|
//
|
||||||
|
// **************************************************************************************************************
|
||||||
|
void charmap_init( s32 baseX, s32 baseY, s32 width, s32 height );
|
||||||
|
void charmap_set_flags( u32 flags );
|
||||||
|
void charmap_display( void );
|
||||||
|
void charmap_clear( void );
|
||||||
|
void charmap_print( char *pStr );
|
||||||
|
void charmap_printf( const char *format, ...);
|
||||||
|
void charmap_printat( s32 x, s32 y, char *pStr );
|
||||||
|
void charmap_outchar( char Ch );
|
||||||
|
void charmap_newline( void );
|
||||||
|
void charmap_scroll_window( void );
|
||||||
|
void charmap_setink( u8 ink );
|
||||||
|
void charmap_setpaper( u8 paper );
|
||||||
|
void charmap_set_window( s32 x1,s32 y1,s32 x2, s32 y2 );
|
||||||
|
void charmap_home( void );
|
||||||
|
void charmap_move_cursor( s32 x, s32 y);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //__CHARMAP_H_
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : drawprim.h
|
||||||
|
// *
|
||||||
|
// * note : A bunch of drawing primitives
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XDRAWPRIM_H
|
||||||
|
#define XDRAWPRIM_H
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
#include "xgfx2d/bitmap.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//simple straightforward functions
|
||||||
|
void clear(Bitmap *bmp, uint32 col);
|
||||||
|
void putpixel(Bitmap *bmp, int x, int y, uint32 color);
|
||||||
|
void line(Bitmap *bmp, int x1, int y1, int x2, int y2, uint32 color);
|
||||||
|
|
||||||
|
//horizontal line from x1 to x2 at y
|
||||||
|
void hline(Bitmap *bmp, int x1, int y, int x2, uint32 color);
|
||||||
|
//vertical line from y1 to y2 at x
|
||||||
|
void vline(Bitmap *bmp, int x, int y1, int y2, uint32 color);
|
||||||
|
|
||||||
|
//rectangle (boundary)
|
||||||
|
void rect(Bitmap *bmp, int x1, int y1, int x2, int y2, uint32 color);
|
||||||
|
|
||||||
|
//filled rectangle
|
||||||
|
void rectfill(Bitmap *bmp, int x1, int y1, int x2, int y2, uint32 color);
|
||||||
|
|
||||||
|
//circle (not filled)
|
||||||
|
void circle(Bitmap *bmp, int x, int y, int radius, uint32 color);
|
||||||
|
|
||||||
|
//more advanced stuff:
|
||||||
|
|
||||||
|
//antialiased pixel
|
||||||
|
//use this for smooth scrolling starfields and stuff :)
|
||||||
|
//this one takes floats
|
||||||
|
void aa_pixel_float(Bitmap *bmp, float x,float y,int color);
|
||||||
|
//this one takes x and y in 16.16 fixed point (slightly faster)
|
||||||
|
void aa_pixel(Bitmap *bmp, int x, int y, int color);
|
||||||
|
|
||||||
|
// draws a single alpha blended pixel, used by bilinear_pixel and aa_line
|
||||||
|
//this one takes x and y in 16.16 fixed point
|
||||||
|
void alpha_pixel(Bitmap *bmp, int x, int y, uint32 sc, int alpha);
|
||||||
|
|
||||||
|
// nice antialiased line drawer
|
||||||
|
// alpha from 0..255, means transparency
|
||||||
|
void aa_line(Bitmap *bmp, float x1, float y1, float x2, float y2, uint32 color, int alpha);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xfile.h
|
||||||
|
// *
|
||||||
|
// * note : XBox File Access
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
// * TODO: most of this belongs in a different .h
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XFILE_H
|
||||||
|
#define XFILE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "xboxkrnl\xboxkrnl.h"
|
||||||
|
|
||||||
|
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
|
||||||
|
#define INVALID_FILE_SIZE ((HANDLE)-1)
|
||||||
|
#define DELETE (0x00010000L)
|
||||||
|
|
||||||
|
#ifndef PAGE_SIZE
|
||||||
|
#define PAGE_SIZE 4096
|
||||||
|
#endif
|
||||||
|
#define ALIGN_SIZE (0x10000) // NT's allocation alignment size (64k)
|
||||||
|
|
||||||
|
// PAGE_ALIGN:
|
||||||
|
// Returns an address rounded down to the nearest page boundary.
|
||||||
|
// Differences from NT: None.
|
||||||
|
#define NT_SUCCESS(Status) ((NTSTATUS) (Status) >= 0)
|
||||||
|
#define PAGE_ALIGN(Va) ((PVOID)((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1)))
|
||||||
|
|
||||||
|
|
||||||
|
// Initializes an OBJECT_ATTRIBUTES. I added this because it's familiar to
|
||||||
|
// NT kernel mode programmers. I just changed it to the XBOX style.
|
||||||
|
// Works as if it were this function:
|
||||||
|
#define InitializeObjectAttributes( p, n, a, r ) { \
|
||||||
|
(p)->RootDirectory = r; \
|
||||||
|
(p)->Attributes = a; \
|
||||||
|
(p)->ObjectName = n; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//unsure where these really belong
|
||||||
|
#define MAX_PATH (2048)
|
||||||
|
#define ERROR_NEGATIVE_SEEK (131)
|
||||||
|
#define ERROR_INVALID_NAME (123)
|
||||||
|
#define ERROR_OPEN_FAILED (110)
|
||||||
|
#define ERROR_DRIVE_LOCKED (108)
|
||||||
|
#define ERROR_HANDLE_DISK_FULL (39)
|
||||||
|
#define ERROR_ALREADY_EXISTS (183)
|
||||||
|
#define ERROR_INVALID_PARAMETER (1)
|
||||||
|
#define ERROR_FILE_NOT_FOUND (2)
|
||||||
|
#define ERROR_TOO_MANY_OPEN_FILES (4)
|
||||||
|
#define ERROR_INVALID_HANDLE (6)
|
||||||
|
#define ERROR_NOT_ENOUGH_MEMORY (0x100000)
|
||||||
|
#define NO_ERROR (0)
|
||||||
|
|
||||||
|
typedef char* LPCSTR;
|
||||||
|
|
||||||
|
// ==============================================
|
||||||
|
// end stuff that belong in some xboxwindows.h
|
||||||
|
// ==============================================
|
||||||
|
|
||||||
|
// these structs need to be here as they are used as parameters
|
||||||
|
typedef struct SSecurity_Attributes{
|
||||||
|
u32 nLength;
|
||||||
|
void* lpSecurityDescriptor;
|
||||||
|
u32 bInheritHandle;
|
||||||
|
} SSecurity_Attributes, *PSecurity_Attributes ;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _OVERLAPPED {
|
||||||
|
u32 Internal;
|
||||||
|
u32 InternalHigh;
|
||||||
|
u32 Offset;
|
||||||
|
u32 OffsetHigh;
|
||||||
|
HANDLE hEvent;
|
||||||
|
} OVERLAPPED, *LPOVERLAPPED;
|
||||||
|
|
||||||
|
|
||||||
|
// Standard
|
||||||
|
#define FILE_FLAG_WRITE_THROUGH (0x80000000)
|
||||||
|
#define FILE_FLAG_OVERLAPPED (0x40000000)
|
||||||
|
#define FILE_FLAG_NO_BUFFERING (0x20000000)
|
||||||
|
#define FILE_FLAG_RANDOM_ACCESS (0x10000000)
|
||||||
|
#define FILE_FLAG_SEQUENTIAL_SCAN (0x08000000)
|
||||||
|
#define FILE_FLAG_DELETE_ON_CLOSE (0x04000000)
|
||||||
|
#define FILE_FLAG_BACKUP_SEMANTICS (0x02000000)
|
||||||
|
#define FILE_FLAG_POSIX_SEMANTICS (0x01000000)
|
||||||
|
#define FILE_FLAG_OPEN_REPARSE_POINT (0x00200000)
|
||||||
|
#define FILE_FLAG_OPEN_NO_RECALL (0x00100000)
|
||||||
|
|
||||||
|
#define CREATE_NEW (0x00000001)
|
||||||
|
#define CREATE_ALWAYS (0x00000002)
|
||||||
|
#define OPEN_EXISTING (0x00000003)
|
||||||
|
#define OPEN_ALWAYS (0x00000004)
|
||||||
|
#define TRUNCATE_EXISTING (0x00000005)
|
||||||
|
|
||||||
|
|
||||||
|
#define GENERIC_READ (0x80000000)
|
||||||
|
#define GENERIC_WRITE (0x40000000)
|
||||||
|
|
||||||
|
#define FILE_BEGIN (0x00000000)
|
||||||
|
#define FILE_CURRENT (0x00000001)
|
||||||
|
#define FILE_END (0x00000002)
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE CreateFile(char* lpFilename,
|
||||||
|
u32 dwDesiredAccess,
|
||||||
|
u32 dwShareMode,
|
||||||
|
SSecurity_Attributes *lpSecurityAttributes,
|
||||||
|
u32 dwCreationDisposition,
|
||||||
|
u32 dwFlagsAndAttributes,
|
||||||
|
HANDLE hTemplateFile
|
||||||
|
);
|
||||||
|
int ReadFile( HANDLE hFile, // file handle
|
||||||
|
void* lpBuffer, // Dest buffer to put file
|
||||||
|
u32 nNumberOfBytesToRead, // read "n" bytes
|
||||||
|
u32* lpNumberOfBytesRead, // pointer to a place to store bytes read
|
||||||
|
LPOVERLAPPED lpOverlapped // NULL unless overlap
|
||||||
|
);
|
||||||
|
|
||||||
|
int WriteFile( HANDLE hFile,
|
||||||
|
PVOID lpBuffer,
|
||||||
|
u32 nNumberOfBytesToWrite,
|
||||||
|
u32* lpNumberOfBytesWritten,
|
||||||
|
LPOVERLAPPED lpOverlapped
|
||||||
|
);
|
||||||
|
|
||||||
|
int CloseHandle(HANDLE Handle);
|
||||||
|
int GetFileSizeEx(HANDLE hFile, PLARGE_INTEGER lpFileSize);
|
||||||
|
int SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char* GetLastErrorMessage( void );
|
||||||
|
void SetLastError( u32 ErrorCode );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xfile_def.h
|
||||||
|
// *
|
||||||
|
// * note : internal typedefs / structs / etc for xfile
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XFILE_DEF_H
|
||||||
|
#define XFILE_DEF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// DEVICE_TYPEs (I took a guess as to which the XBOX might have.)
|
||||||
|
#define FILE_DEVICE_CD_ROM (0x00000002)
|
||||||
|
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM (0x00000003)
|
||||||
|
#define FILE_DEVICE_CONTROLLER (0x00000004)
|
||||||
|
#define FILE_DEVICE_DISK (0x00000007)
|
||||||
|
#define FILE_DEVICE_DISK_FILE_SYSTEM (0x00000008)
|
||||||
|
#define FILE_DEVICE_FILE_SYSTEM (0x00000009)
|
||||||
|
#define FILE_DEVICE_NULL (0x00000015)
|
||||||
|
#define FILE_DEVICE_SCREEN (0x0000001c)
|
||||||
|
#define FILE_DEVICE_SOUND (0x0000001d)
|
||||||
|
#define FILE_DEVICE_UNKNOWN (0x00000022)
|
||||||
|
#define FILE_DEVICE_VIDEO (0x00000023)
|
||||||
|
#define FILE_DEVICE_VIRTUAL_DISK (0x00000024)
|
||||||
|
#define FILE_DEVICE_FULLSCREEN_VIDEO (0x00000034)
|
||||||
|
|
||||||
|
#define FILE_ATTRIBUTE_READONLY (0x00000001)
|
||||||
|
#define FILE_ATTRIBUTE_HIDDEN (0x00000002)
|
||||||
|
#define FILE_ATTRIBUTE_SYSTEM (0x00000004)
|
||||||
|
#define FILE_ATTRIBUTE_DIRECTORY (0x00000010)
|
||||||
|
#define FILE_ATTRIBUTE_ARCHIVE (0x00000020)
|
||||||
|
#define FILE_ATTRIBUTE_NORMAL (0x00000080)
|
||||||
|
#define FILE_ATTRIBUTE_TEMPORARY (0x00000100)
|
||||||
|
#define FILE_FLAG_WRITE_THROUGH (0x80000000)
|
||||||
|
#define FILE_FLAG_RANDOM_ACCESS (0x10000000)
|
||||||
|
|
||||||
|
// NtCreateFile/NtOpenFile stuff
|
||||||
|
#define FILE_SUPERSEDED 0x00000000
|
||||||
|
#define FILE_OPENED 0x00000001
|
||||||
|
#define FILE_CREATED 0x00000002
|
||||||
|
#define FILE_OVERWRITTEN 0x00000003
|
||||||
|
#define FILE_EXISTS 0x00000004
|
||||||
|
#define FILE_DOES_NOT_EXIST 0x00000005
|
||||||
|
|
||||||
|
// Flags for OBJECT_ATTRIBUTES::Attributes
|
||||||
|
#define OBJ_INHERIT (0x00000002L)
|
||||||
|
#define OBJ_PERMANENT (0x00000010L)
|
||||||
|
#define OBJ_EXCLUSIVE (0x00000020L)
|
||||||
|
#define OBJ_CASE_INSENSITIVE (0x00000040L)
|
||||||
|
#define OBJ_OPENIF (0x00000080L)
|
||||||
|
#define OBJ_OPENLINK (0x00000100L)
|
||||||
|
#define OBJ_KERNEL_HANDLE (0x00000200L)
|
||||||
|
#define OBJ_VALID_ATTRIBUTES (0x000003F2L)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * File pointer information (SetFilePointer, etc)
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _FILE_POSITION_INFORMATION
|
||||||
|
{
|
||||||
|
LARGE_INTEGER CurrentByteOffset;
|
||||||
|
}
|
||||||
|
FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Access times and normal attributes (only set is known to be
|
||||||
|
// * supported - use FILE_NETWORK_OPEN_INFORMATION if you want to
|
||||||
|
// * query this information.
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _FILE_BASIC_INFORMATION
|
||||||
|
{
|
||||||
|
LARGE_INTEGER CreationTime;
|
||||||
|
LARGE_INTEGER LastAccessTime;
|
||||||
|
LARGE_INTEGER LastWriteTime;
|
||||||
|
LARGE_INTEGER ChangeTime;
|
||||||
|
ULONG FileAttributes;
|
||||||
|
}
|
||||||
|
FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Access times and normal attributes
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _FILE_NETWORK_OPEN_INFORMATION
|
||||||
|
{
|
||||||
|
LARGE_INTEGER CreationTime; // 000 Time file was created
|
||||||
|
LARGE_INTEGER LastAccessTime; // 008 Time file was last accessed
|
||||||
|
LARGE_INTEGER LastWriteTime; // 010 Time file was last opened for writing?
|
||||||
|
LARGE_INTEGER ChangeTime; // 018 Time file was last changed?
|
||||||
|
LARGE_INTEGER AllocationSize; // 020 Size of the file in the file system (including slack space)
|
||||||
|
LARGE_INTEGER EndOfFile; // 028 What we'd normally call the file size
|
||||||
|
ULONG FileAttributes; // 030 File attributes
|
||||||
|
ULONG Unknown; // 034 Unknown
|
||||||
|
}
|
||||||
|
FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
|
||||||
|
|
||||||
|
LARGE_INTEGER AddU64(PLARGE_INTEGER A, PLARGE_INTEGER B);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // XFILE_DEF_H
|
|
@ -0,0 +1,44 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xhal.h
|
||||||
|
// *
|
||||||
|
// * note : XBox Hardware Abstraction Layer
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XHAL_H
|
||||||
|
#define XHAL_H
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XVGA
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xvga.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XFile
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xfile.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * XOHCI
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xohci.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * The user application starts here
|
||||||
|
// ******************************************************************
|
||||||
|
extern VOID XBoxStartup();
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,282 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xnvidia.h
|
||||||
|
// *
|
||||||
|
// * note : XBox NVidia Chip
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XNVIDIA_H
|
||||||
|
#define XNVIDIA_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Accessible Functions
|
||||||
|
// ******************************************************************
|
||||||
|
void NVSetScreenAddress(void);
|
||||||
|
void NVSetBPP(int mode);
|
||||||
|
int NVSetVideoMode(u32 dwResolution, u32 dwPixelFormat );
|
||||||
|
int NVSetFlickerFilter(DWORD dwLevel);
|
||||||
|
void NVSetClippingRectangle(u32 x1,u32 y1,u32 x2,u32 y2);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * AvSetDisplayMode pixel formats
|
||||||
|
// ******************************************************************
|
||||||
|
#define PIXEL_16BITS_555 0x10
|
||||||
|
#define PIXEL_16BITS_565 0x11
|
||||||
|
#define PIXEL_32BITS 0x12
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * AvSetDisplayMode resolutions (only 640 is tested)
|
||||||
|
// ******************************************************************
|
||||||
|
#define RESOLUTION_640 0x20010101
|
||||||
|
#define RESOLUTION_720 0x20020101
|
||||||
|
#define RESOLUTION_800 0x20030101
|
||||||
|
#define RESOLUTION_1024 0x200B0101
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Parameters for AvSendTVEncoderOption
|
||||||
|
// ******************************************************************
|
||||||
|
#define AV_OPTION_SET_MACROVISION 0x01
|
||||||
|
#define AV_OPTION_CONFIRM_MACROVISION 0x0A
|
||||||
|
#define AV_OPTION_SET_FLICKER_FILTER 0x0B
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NVidia registers base / offsets
|
||||||
|
// ******************************************************************
|
||||||
|
#define NV_REGBASE (0xFD000000)
|
||||||
|
#define NV_PMC (0x000000)
|
||||||
|
#define NV_PFIFO (0x002000)
|
||||||
|
#define NV_FB (0x100000)
|
||||||
|
#define NV_EXTDEV (0x101000)
|
||||||
|
#define NV_CRTC (0x600000)
|
||||||
|
#define NV_RAMDAC (0x680000)
|
||||||
|
#define NV_FIFO (0x800000)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * CRTC register accessors
|
||||||
|
// ******************************************************************
|
||||||
|
#define CRTC_WRITE(a,b) *((volatile u8*) (NV_REGBASE + NV_CRTC + (a))) = (b)
|
||||||
|
#define CRTC_READ(a) (*((volatile u8*) (NV_REGBASE + NV_CRTC + (a))))
|
||||||
|
#define CRTC_WRITEL(a,b) *((volatile u32*) (NV_REGBASE + NV_CRTC + (a))) = (b)
|
||||||
|
#define CRTC_READL(a) (*((volatile u32*) (NV_REGBASE + NV_CRTC + (a))))
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Macros to get pointers to FIFO regs
|
||||||
|
// ******************************************************************
|
||||||
|
#define NVPTR_ROP ((PNV_ROP)(NV_REGBASE + NV_FIFO + 0x0000))
|
||||||
|
#define NVPTR_PATTERN ((PNV_PATTERN)(NV_REGBASE + NV_FIFO + 0x4000))
|
||||||
|
#define NVPTR_CLIP ((PNV_CLIP)(NV_REGBASE + NV_FIFO + 0x2000))
|
||||||
|
#define NVPTR_SCREENBLT ((PNV_SCREENBLT)(NV_REGBASE + NV_FIFO + 0x8000))
|
||||||
|
#define NVPTR_BLIT ((PNV_BLIT)(NV_REGBASE + NV_FIFO + 0x6000))
|
||||||
|
#define NVPTR_BITMAP ((PNV_BITMAP)(NV_REGBASE + NV_FIFO + 0xA000))
|
||||||
|
#define NVPTR_LINE ((PNV_LINE)(NV_REGBASE + NV_FIFO + 0xC000))
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Registers
|
||||||
|
// ******************************************************************
|
||||||
|
#define NV_INPUT_STATUS (0x13DA)
|
||||||
|
#define NV_CRTC_FB_ADDR (0x800) // Display start address
|
||||||
|
#define NV_CRTC_INDEX (0x13D4)
|
||||||
|
#define NV_CRTC_DATA (0x13D5)
|
||||||
|
#define NV_CRTC_REGS_LOCK 0x1F
|
||||||
|
#define NV_CRTC_UNLOCK_VALUE 0x57
|
||||||
|
#define NV_CRTC_LOCK_VALUE 0x99
|
||||||
|
#define NV_CRTC_PIXEL (0x28)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Pixel / TV Mode bits
|
||||||
|
// ******************************************************************
|
||||||
|
#define NV_TV 0x80
|
||||||
|
#define NV_VGA 0x00
|
||||||
|
#define NV_PAL 0x40
|
||||||
|
#define NV_NTSC 0x00
|
||||||
|
#define NV_VGA 0x00 // format
|
||||||
|
#define NV_8BPP 0x01
|
||||||
|
#define NV_16BPP 0x02
|
||||||
|
#define NV_32BPP 0x03
|
||||||
|
#define NV_BPP_MASK (~0x03) //
|
||||||
|
|
||||||
|
|
||||||
|
//-- FIFO Regs -----------------------------------------------------------------
|
||||||
|
|
||||||
|
// Macro to wait until the GPU has enough FIFO slots
|
||||||
|
#define NV_WAIT_FIFO(Ptr, Cnt) while( ( ((Ptr)->FifoFree) / 4) < (Cnt) );
|
||||||
|
|
||||||
|
// FIFO + 0x0000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused;
|
||||||
|
ULONG Reserved1[0x0BB];
|
||||||
|
ULONG Rop3;
|
||||||
|
} NV_ROP, *PNV_ROP;
|
||||||
|
|
||||||
|
// FIFO + 0x4000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused;
|
||||||
|
ULONG Reserved1[0x0BD];
|
||||||
|
ULONG Shape;
|
||||||
|
ULONG Reserved2[0x001];
|
||||||
|
ULONG Color0;
|
||||||
|
ULONG Color1;
|
||||||
|
ULONG Monochrome[2];
|
||||||
|
} NV_PATTERN, *PNV_PATTERN;
|
||||||
|
|
||||||
|
// FIFO + 0x2000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused;
|
||||||
|
ULONG Reserved1[0x0BB];
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG WidthHeight;
|
||||||
|
} NV_CLIP, *PNV_CLIP;
|
||||||
|
|
||||||
|
/*
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused[1];
|
||||||
|
ULONG Reserved1[0x0BC];
|
||||||
|
ULONG Color;
|
||||||
|
ULONG Reserved3[0x03E];
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG WidthHeight;
|
||||||
|
} NV_RECTANGLE, *PNV_RECTANGLE;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// FIFO + 0x8000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused;
|
||||||
|
ULONG Reserved1[0x0BB];
|
||||||
|
ULONG TopLeftSrc;
|
||||||
|
ULONG TopLeftDst;
|
||||||
|
ULONG WidthHeight;
|
||||||
|
} NV_SCREENBLT, *PNV_SCREENBLT;
|
||||||
|
|
||||||
|
// FIFO + 0x6000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused[1];
|
||||||
|
ULONG Reserved1[0x0BC];
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG WidthHeight;
|
||||||
|
ULONG WidthHeightIn;
|
||||||
|
ULONG Reserved2[0x03C];
|
||||||
|
ULONG Pixels;
|
||||||
|
} NV_BLIT, *PNV_BLIT;
|
||||||
|
|
||||||
|
// FIFO + 0xA000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused;
|
||||||
|
ULONG Reserved1[0x0BB];
|
||||||
|
ULONG Reserved2[0x03F];
|
||||||
|
ULONG Color1A;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG WidthHeight;
|
||||||
|
} UnclippedRectangle[64];
|
||||||
|
ULONG Reserved3[0x07D];
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG BottomRight;
|
||||||
|
} ClipB;
|
||||||
|
ULONG Color1B;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG BottomRight;
|
||||||
|
} ClippedRectangle[64];
|
||||||
|
ULONG Reserved4[0x07B];
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG BottomRight;
|
||||||
|
} ClipC;
|
||||||
|
ULONG Color1C;
|
||||||
|
ULONG WidthHeightC;
|
||||||
|
ULONG PointC;
|
||||||
|
ULONG MonochromeData1C;
|
||||||
|
ULONG Reserved5[0x0F9];
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG BottomRight;
|
||||||
|
} ClipD;
|
||||||
|
ULONG Color1D;
|
||||||
|
ULONG WidthHeightInD;
|
||||||
|
ULONG WidthHeightOutD;
|
||||||
|
ULONG PointD;
|
||||||
|
ULONG MonochromeData1D;
|
||||||
|
ULONG Reserved6[0x0F8];
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG TopLeft;
|
||||||
|
ULONG BottomRight;
|
||||||
|
} ClipE;
|
||||||
|
ULONG Color0E;
|
||||||
|
ULONG Color1E;
|
||||||
|
ULONG WidthHeightInE;
|
||||||
|
ULONG WidthHeightOutE;
|
||||||
|
ULONG PointE;
|
||||||
|
ULONG MonochromeData01E;
|
||||||
|
} NV_BITMAP, *PNV_BITMAP;
|
||||||
|
|
||||||
|
// FIFO + 0xC000
|
||||||
|
typedef volatile struct
|
||||||
|
{
|
||||||
|
ULONG Reserved0[4];
|
||||||
|
USHORT FifoFree;
|
||||||
|
USHORT Unused[1];
|
||||||
|
ULONG Reserved1[0x0BC];
|
||||||
|
ULONG Color; // source color 0304-0307
|
||||||
|
ULONG Reserved2[0x03E];
|
||||||
|
struct { // start aliased methods in array 0400-
|
||||||
|
ULONG Point0; // y_x S16_S16 in pixels 0- 3
|
||||||
|
ULONG Point1; // y_x S16_S16 in pixels 4- 7
|
||||||
|
} Lin[16]; // end of aliased methods in array -047f
|
||||||
|
struct { // start aliased methods in array 0480-
|
||||||
|
ULONG Point0X; // in pixels, 0 at left 0- 3
|
||||||
|
ULONG Point0Y; // in pixels, 0 at top 4- 7
|
||||||
|
ULONG Point1X; // in pixels, 0 at left 8- b
|
||||||
|
ULONG Point1Y; // in pixels, 0 at top c- f
|
||||||
|
} Lin32[8]; // end of aliased methods in array -04ff
|
||||||
|
ULONG PolyLin[32]; // y_x S16_S16 in pixels 0500-057f
|
||||||
|
struct { // start aliased methods in array 0580-
|
||||||
|
ULONG x; // in pixels, 0 at left 0- 3
|
||||||
|
ULONG y; // in pixels, 0 at top 4- 7
|
||||||
|
} PolyLin32[16]; // end of aliased methods in array -05ff
|
||||||
|
struct { // start aliased methods in array 0600-
|
||||||
|
ULONG Color; // source color 0- 3
|
||||||
|
ULONG Point; // y_x S16_S16 in pixels 4- 7
|
||||||
|
} ColorPolyLin[16]; // end of aliased methods in array -067f
|
||||||
|
} NV_LINE, *PNV_LINE;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // XNVIDIA_H
|
|
@ -0,0 +1,293 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xohci.h
|
||||||
|
// *
|
||||||
|
// * note : XBox USB Open Host Controller Interface
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XOHCI_H
|
||||||
|
#define XOHCI_H
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * external functions
|
||||||
|
// ******************************************************************
|
||||||
|
void xohci_init();
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * OHCI (PCI)
|
||||||
|
// ******************************************************************
|
||||||
|
#include "xohci_pci.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * struct : ed (Endpoint Descriptor)
|
||||||
|
// ******************************************************************
|
||||||
|
#pragma pack(16)
|
||||||
|
typedef struct _xohci_ed
|
||||||
|
{
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 0
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_function_addr : 7;
|
||||||
|
uint32 m_endpoint_numb : 4;
|
||||||
|
uint32 m_direction : 2;
|
||||||
|
uint32 m_speed : 1;
|
||||||
|
uint32 m_skip : 1;
|
||||||
|
uint32 m_format : 1;
|
||||||
|
uint32 m_max_packet_size : 11;
|
||||||
|
uint32 m_reserved0 : 5;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 1
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_reserved1 : 4;
|
||||||
|
uint32 m_tail_p : 28;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 2
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_halted : 1;
|
||||||
|
uint32 m_toggle_carry : 1;
|
||||||
|
uint32 m_zero_bit : 2;
|
||||||
|
uint32 m_head_p : 28;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 1
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_reserved3 : 4;
|
||||||
|
uint32 m_next_ed : 28;
|
||||||
|
}
|
||||||
|
xohci_ed;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Endpoint Descriptor Flags
|
||||||
|
// ******************************************************************
|
||||||
|
#define ED_DIRECTION_IN 0
|
||||||
|
#define ED_DIRECTION_OUT 1
|
||||||
|
#define ED_SPEED_FULL 0
|
||||||
|
#define ED_SPEED_LOW 1
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * struct : td (Transfer Descriptor)
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Since XBox controllers are not isochronous, we do not need
|
||||||
|
// * to support that transfer type. therefore, we also do not need
|
||||||
|
// * to align this structure to 32 bytes, as general transfer desc
|
||||||
|
// * only require 16 byte alignment
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#pragma pack(16)
|
||||||
|
typedef struct _xohci_td
|
||||||
|
{
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 0
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_reserved18 : 18; // (NA)
|
||||||
|
uint32 m_buffer_rounding : 1; // (RO) R
|
||||||
|
uint32 m_direction_pid : 2; // (RO) DP
|
||||||
|
uint32 m_delay_int : 3; // (RO) DI
|
||||||
|
uint32 m_data_toggle : 2; // (RW) T
|
||||||
|
uint32 m_error_count : 2; // (RW) EC
|
||||||
|
uint32 m_condition_code : 4; // (RW) CC
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 1
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_current_buffer : 32; // (RW) CBP
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 2
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_zero4 : 4; // (00) Should be Zero
|
||||||
|
uint32 m_next_td : 28; // (RW) NextTD
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * DWord 1
|
||||||
|
// ******************************************************************
|
||||||
|
uint32 m_buffer_end : 32; // (RO) BE
|
||||||
|
}
|
||||||
|
xohci_td;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Transfer Descriptor Flags
|
||||||
|
// ******************************************************************
|
||||||
|
#define TD_DP_SETUP 0x00
|
||||||
|
#define TD_DP_OUT 0x01
|
||||||
|
#define TD_DP_IN 0x02
|
||||||
|
#define TD_T_DATA0 0x02
|
||||||
|
#define TD_T_DATA1 0x03
|
||||||
|
#define TD_T_TOGGLE 0x00
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Condition Code Values
|
||||||
|
// ******************************************************************
|
||||||
|
#define TD_CC_NOERROR 0x0000
|
||||||
|
#define TD_CC_CRC 0x0001
|
||||||
|
#define TD_CC_BITSTUFFING 0x0002
|
||||||
|
#define TD_CC_DATATOGGLEM 0x0003
|
||||||
|
#define TD_CC_STALL 0x0004
|
||||||
|
#define TD_DEVNOTRESP 0x0005
|
||||||
|
#define TD_PIDCHECKFAIL 0x0006
|
||||||
|
#define TD_UNEXPECTEDPID 0x0007
|
||||||
|
#define TD_DATAOVERRUN 0x0008
|
||||||
|
#define TD_DATAUNDERRUN 0x0009
|
||||||
|
#define TD_BUFFEROVERRUN 0x000C
|
||||||
|
#define TD_BUFFERUNDERRUN 0x000D
|
||||||
|
#define TD_NOTACCESSED 0x000F
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * struct : xohci_hcca (Host Controller Communications Area)
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Note: This must be 256-byte aligned
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct _xohci_hcca
|
||||||
|
{
|
||||||
|
uint32 int_table[32]; // (RO) HccaInterruptTable
|
||||||
|
uint16 frame_number; // (WO) HccaFrameNumber
|
||||||
|
uint16 pad1; // (WO) HccaPad1
|
||||||
|
uint32 done_head; // (WO) HccaDoneHead
|
||||||
|
uint08 reserved[116]; // (RW) Reserved for use by Host Controller
|
||||||
|
// less than 256 bytes..why?
|
||||||
|
}
|
||||||
|
xohci_hcca;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * class : ohci_regs (OHCI Host Controller Operational Registers)
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * NOTE: These fields must be accessed using the functions:
|
||||||
|
// *
|
||||||
|
// * WRITE_REGISTER_* and READ_REGISTER_*
|
||||||
|
// *
|
||||||
|
// * NOTE: These should fall naturally on a 32 byte boundary
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _xohci_regs
|
||||||
|
{
|
||||||
|
uint32 hc_revision;
|
||||||
|
uint32 hc_control;
|
||||||
|
uint32 hc_cmdstatus;
|
||||||
|
uint32 hc_int_status;
|
||||||
|
uint32 hc_int_enable;
|
||||||
|
uint32 hc_int_disable;
|
||||||
|
|
||||||
|
uint32 hc_hcca;
|
||||||
|
uint32 hc_period_cur;
|
||||||
|
uint32 hc_control_head;
|
||||||
|
uint32 hc_control_cur;
|
||||||
|
uint32 hc_bulk_head;
|
||||||
|
uint32 hc_bulk_cur;
|
||||||
|
uint32 hc_done_head;
|
||||||
|
|
||||||
|
uint32 hc_fm_interval;
|
||||||
|
uint32 hc_fm_remaining;
|
||||||
|
uint32 hc_fm_number;
|
||||||
|
uint32 hc_periodic_start;
|
||||||
|
uint32 hc_ls_threshold;
|
||||||
|
|
||||||
|
uint32 hc_rh_descriptor_a;
|
||||||
|
uint32 hc_rh_descriptor_b;
|
||||||
|
uint32 hc_rh_status;
|
||||||
|
uint32 hc_rh_port_status[15];
|
||||||
|
}
|
||||||
|
xohci_regs;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * global pointer to OHCI Host Controller Operational Registers
|
||||||
|
// ******************************************************************
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING - so its definition was moved to
|
||||||
|
// xohci.c
|
||||||
|
extern xohci_regs *g_xohci_regs;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * hc_control register masks
|
||||||
|
// ******************************************************************
|
||||||
|
#define XOHCI_CTRL_CBSR (3 << 0) // control/bulk service ratio
|
||||||
|
#define XOHCI_CTRL_PLE (1 << 2) // periodic list enable
|
||||||
|
#define XOHCI_CTRL_IE (1 << 3) // isochronous enable
|
||||||
|
#define XOHCI_CTRL_CLE (1 << 4) // control list enable
|
||||||
|
#define XOHCI_CTRL_BLE (1 << 5) // bulk list enable
|
||||||
|
#define XOHCI_CTRL_HCFS (3 << 6) // host controller functional state
|
||||||
|
#define XOHCI_CTRL_IR (1 << 8) // interrupt routing
|
||||||
|
#define XOHCI_CTRL_RWC (1 << 9) // remote wakeup connected
|
||||||
|
#define XOHCI_CTRL_RWE (1 << 10) // remote wakeup enable
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * pre-shifted values for HC_CONTROL_FUNCTIONAL_STATE
|
||||||
|
// ******************************************************************
|
||||||
|
#define XOHCI_USB_RESET (0 << 6)
|
||||||
|
#define XOHCI_USB_RESUME (1 << 6)
|
||||||
|
#define XOHCI_USB_OPERATIONAL (2 << 6)
|
||||||
|
#define XOHCI_USB_SUSPEND (3 << 6)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * hc_cmdstatus register masks
|
||||||
|
// ******************************************************************
|
||||||
|
#define XOHCI_HCR (1 << 0) // host controller reset
|
||||||
|
#define XOHCI_CLF (1 << 1) // control list filled
|
||||||
|
#define XOHCI_BLF (1 << 2) // bulk list filled
|
||||||
|
#define XOHCI_OCR (1 << 3) // ownership change request
|
||||||
|
#define XOHCI_SOC (3 << 16) // scheduling overrun count
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * interrupt register masks (status/enable/disable regs)
|
||||||
|
// ******************************************************************
|
||||||
|
#define XOHCI_INTR_SO (1 << 0) // scheduling overrun
|
||||||
|
#define XOHCI_INTR_WDH (1 << 1) // writeback of done_head
|
||||||
|
#define XOHCI_INTR_SF (1 << 2) // start frame
|
||||||
|
#define XOHCI_INTR_RD (1 << 3) // resume detect
|
||||||
|
#define XOHCI_INTR_UE (1 << 4) // unrecoverable error
|
||||||
|
#define XOHCI_INTR_FNO (1 << 5) // frame number overflow
|
||||||
|
#define XOHCI_INTR_RHSC (1 << 6) // root hub status change
|
||||||
|
#define XOHCI_INTR_OC (1 << 30) // ownership change
|
||||||
|
#define XOHCI_INTR_MIE (1 << 31) // master interrupt enable
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * struct : xohci
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * Packages up all of our variables
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _xohci
|
||||||
|
{
|
||||||
|
xohci_hcca *m_hcca;
|
||||||
|
uint32 m_hcca_dma;
|
||||||
|
uint32 m_disabled;
|
||||||
|
}
|
||||||
|
xohci;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * global variables
|
||||||
|
// ******************************************************************
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING
|
||||||
|
// ERROR DURING LINKING - so its definition was moved to
|
||||||
|
// xohci.c
|
||||||
|
extern xohci g_xohci;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,29 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xohci_pci.h
|
||||||
|
// *
|
||||||
|
// * note : XBox USB Open Host Controller Interface (PCI)
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XOHCI_PCI_H
|
||||||
|
#define XOHCI_PCI_H
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * external functions
|
||||||
|
// ******************************************************************
|
||||||
|
void xohci_pci_init();
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,119 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xvga.h
|
||||||
|
// *
|
||||||
|
// * note : XBox VGA
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XVGA_H
|
||||||
|
#define XVGA_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "openxdk.h"
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * User Variables
|
||||||
|
// ******************************************************************
|
||||||
|
extern u32 g_ScreenWidth; // Current Screen Width
|
||||||
|
extern u32 g_ScreenHeight; // Current Screen Height
|
||||||
|
extern u32 g_nFlags;
|
||||||
|
extern u32 g_nInk;
|
||||||
|
extern u32 g_nPaper;
|
||||||
|
extern u32 g_nFontFlags;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ScreenInfo (returned by GetScreen())
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _ScreenInfo
|
||||||
|
{
|
||||||
|
u32 ScreenAddress;
|
||||||
|
u32 lpitch;
|
||||||
|
}
|
||||||
|
ScreenInfo;
|
||||||
|
|
||||||
|
// **************************************************************
|
||||||
|
// * User Functions
|
||||||
|
// **************************************************************
|
||||||
|
void vga_init_mode(int Mode); // Init VGA screen to a selected mode
|
||||||
|
void vga_vsync(void); // Wait for vertical blank
|
||||||
|
void vga_flip(void); // Flip buffers
|
||||||
|
ScreenInfo vga_get_screen_info(void); // get screen base address
|
||||||
|
|
||||||
|
// **************************************************************
|
||||||
|
// * For debugging purposes (serious 2D should use xgfx2d lib)
|
||||||
|
// **************************************************************
|
||||||
|
void vga_clear( void ); // Clear screen
|
||||||
|
void vga_box( int x1,int y1, int x2,int y2 ); // Draw wireframe BOX (WHITE)
|
||||||
|
void vga_print( int x, int y, char* pText ); // Draw text using SYSTEM font (32bit modes only just now)
|
||||||
|
void vga_testpattern( int shift); // Draw a test pattern/colour to the screen
|
||||||
|
|
||||||
|
// **************************************************************
|
||||||
|
// * Misc things... will be used later
|
||||||
|
// **************************************************************
|
||||||
|
void vga_set_color( int reg, int R, int G, int B );
|
||||||
|
void vga_set_reg( int port, int reg, int data );
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Pixel resolutions
|
||||||
|
// ******************************************************************
|
||||||
|
#define RES_320X200 (1) // Hardware mode *NOT YET*
|
||||||
|
#define RES_320X240 (2) // Software emulated
|
||||||
|
#define RES_640X200 (3) // Hardware mode *NOT YET*
|
||||||
|
#define RES_640X240 (4) // Hardware mode *NOT YET*
|
||||||
|
#define RES_640X400 (5) // Hardware mode *NOT YET*
|
||||||
|
#define RES_640X480 (6) // Hardware mode *NOT YET*
|
||||||
|
#define RES_720X480 (7) // Hardware mode *NOT YET*
|
||||||
|
#define RES_800X600 (8) // Hardware mode *NOT YET*
|
||||||
|
#define RES_1024X768 (9) // Hardware mode *NOT YET*
|
||||||
|
#define RES_MASK (15)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Bit depths
|
||||||
|
// ******************************************************************
|
||||||
|
#define _32BITCOLOUR (0x00000000)
|
||||||
|
#define _16BITCOLOUR (0x00000010)
|
||||||
|
#define _8BITCOLOUR (0x00000020)
|
||||||
|
#define COLOUR_MASK (0x00000030)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Extra display flags
|
||||||
|
// ******************************************************************
|
||||||
|
#define _DISPLAY_DEBUG (0x80000000) // display into debug mode (single buffer system)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Easy to use screen modes
|
||||||
|
// ******************************************************************
|
||||||
|
#define MODE_320x200x32 (RES_320X200|_32BITCOLOUR) // not yet
|
||||||
|
#define MODE_320x240x32 (RES_320X240|_32BITCOLOUR)
|
||||||
|
#define MODE_640x200x32 (RES_320X200|_32BITCOLOUR) // not yet
|
||||||
|
#define MODE_640x240x32 (RES_320X240|_32BITCOLOUR)
|
||||||
|
#define MODE_640x400x32 (RES_640X400|_32BITCOLOUR) // not yet
|
||||||
|
#define MODE_640x480x32 (RES_640X480|_32BITCOLOUR) // not yet
|
||||||
|
#define MODE_320x200x16 (RES_320X200|_16BITCOLOUR) // not yet
|
||||||
|
#define MODE_320x240x16 (RES_320X240|_16BITCOLOUR) // not yet
|
||||||
|
#define MODE_640x200x16 (RES_320X200|_16BITCOLOUR) // not yet
|
||||||
|
#define MODE_640x240x16 (RES_320X240|_16BITCOLOUR) // not yet
|
||||||
|
#define MODE_640x400x16 (RES_640X400|_16BITCOLOUR) // not yet
|
||||||
|
#define MODE_640x480x16 (RES_640X480|_16BITCOLOUR) // not yet
|
||||||
|
|
||||||
|
// this is really to be used with the character map, so debug can be seen as soon as its output.. single buffered.
|
||||||
|
#define MODE_640x480x32_DEBUG (RES_640X480|_32BITCOLOUR|_DISPLAY_DEBUG) // not yet
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * For print
|
||||||
|
// ******************************************************************
|
||||||
|
#define FONT_SOLID (1) // render font with SOLID background (with paper colour)
|
||||||
|
#define FONT_WRAP (2) // Wrap PRINT's when they go off the screen
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // XVGA_H
|
|
@ -0,0 +1,150 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xvga_def.h
|
||||||
|
// *
|
||||||
|
// * note : XBox VGA (#defines)
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XVGA_DEF_H
|
||||||
|
#define XVGA_DEF_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern u8 SystemFont[]; // handy to use system font
|
||||||
|
extern u8 *pFont; // point to the system Font by default. You can change it to your own
|
||||||
|
extern u32 pScreenBuffer[]; // Our screen (software emulated for LOW res just now)
|
||||||
|
extern u32 FrontBuffer; // Current screen address (visible)
|
||||||
|
extern u32 BackBuffer; // Current back buffer
|
||||||
|
extern u32 _FrontBuffer; // Current screen address (visible)
|
||||||
|
extern u32 _BackBuffer; // Current back buffer
|
||||||
|
extern u32 _Framebuffer;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Internal
|
||||||
|
// ******************************************************************
|
||||||
|
#define XBV_BASE 0xfd601000
|
||||||
|
#define XBV_ATTR_REG_INDEX 0xfd6013c0
|
||||||
|
#define XBV_ATTR_REG_DATA 0xfd6013c1
|
||||||
|
#define XBV_ATTR_REG_INDEX2 0xfd6013c2
|
||||||
|
#define XBV_ATTR_REG_INDEX3 0xfd6013c3
|
||||||
|
#define XBV_CRTC_REG_INDEX 0xfd6013d4
|
||||||
|
#define XBV_CRTC_REG_DATA 0xfd6013d5
|
||||||
|
#define XBV_GRA_REG_INDEX 0xfd0C03ce
|
||||||
|
#define XBV_GRA_REG_DATA 0xfd0C03cf
|
||||||
|
#define XBV_SEQ_REG_INDEX 0xfd0C03c4
|
||||||
|
#define XBV_SEQ_REG_DATA 0xfd0C03c5
|
||||||
|
#define XBV_MISC_REG 0xfd0C03c2
|
||||||
|
#define VBL 0xfd6013da
|
||||||
|
|
||||||
|
#define XBV_COLOUR_REG 0xfd6013c8
|
||||||
|
#define XBV_COLOUR_DATA 0xfd6013c9
|
||||||
|
|
||||||
|
#define XBOX_SCREENRAM 0x8003d000 // Xbox screen RAM starts here (power on default)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * System flags
|
||||||
|
// ******************************************************************
|
||||||
|
#define XHAL_320SCREEN (1) // Software emulation of 320x??? mode
|
||||||
|
#define YHAL_200SCREEN (2) // Center 200 screen inside a 240 one
|
||||||
|
|
||||||
|
// This might be able to be safely removed now
|
||||||
|
extern int _fltused;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Register
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
short port;
|
||||||
|
unsigned char index;
|
||||||
|
unsigned char value;
|
||||||
|
}
|
||||||
|
Register;
|
||||||
|
|
||||||
|
#define ATTRCON_ADDR 0x3c0
|
||||||
|
#define MISC_ADDR 0x3c2
|
||||||
|
#define VGAENABLE_ADDR 0x3c3
|
||||||
|
#define SEQ_ADDR 0x3c4
|
||||||
|
#define GRACON_ADDR 0x3ce
|
||||||
|
#define CRTC_ADDR 0x3d4
|
||||||
|
#define STATUS_ADDR 0x3da
|
||||||
|
|
||||||
|
/*
|
||||||
|
xxxxADDR defines the base port number used to access VGA component xxxx,
|
||||||
|
and is defined for xxxx =
|
||||||
|
ATTRCON - Attribute Controller
|
||||||
|
MISC - Miscellaneous Register
|
||||||
|
VGAENABLE - VGA Enable Register
|
||||||
|
SEQ - Sequencer
|
||||||
|
GRACON - Graphics Controller
|
||||||
|
CRTC - Cathode Ray Tube Controller
|
||||||
|
STATUS - Status Register
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * VGA Registers
|
||||||
|
// ******************************************************************
|
||||||
|
#define VGAREG_ACTL_ADDRESS 0x3c0
|
||||||
|
#define VGAREG_ACTL_WRITE_DATA 0x3c0
|
||||||
|
#define VGAREG_ACTL_READ_DATA 0x3c1
|
||||||
|
|
||||||
|
#define VGAREG_INPUT_STATUS 0x3c2
|
||||||
|
#define VGAREG_WRITE_MISC_OUTPUT 0x3c2
|
||||||
|
#define VGAREG_VIDEO_ENABLE 0x3c3
|
||||||
|
#define VGAREG_SEQU_ADDRESS 0x3c4
|
||||||
|
#define VGAREG_SEQU_DATA 0x3c5
|
||||||
|
|
||||||
|
#define VGAREG_PEL_MASK 0x3c6
|
||||||
|
#define VGAREG_DAC_STATE 0x3c7
|
||||||
|
#define VGAREG_DAC_READ_ADDRESS 0x3c7
|
||||||
|
#define VGAREG_DAC_WRITE_ADDRESS 0x3c8
|
||||||
|
#define VGAREG_DAC_DATA 0x3c9
|
||||||
|
|
||||||
|
#define VGAREG_READ_FEATURE_CTL 0x3ca
|
||||||
|
#define VGAREG_READ_MISC_OUTPUT 0x3cc
|
||||||
|
|
||||||
|
#define VGAREG_GRDC_ADDRESS 0x3ce
|
||||||
|
#define VGAREG_GRDC_DATA 0x3cf
|
||||||
|
|
||||||
|
#define VGAREG_MDA_CRTC_ADDRESS 0x3b4
|
||||||
|
#define VGAREG_MDA_CRTC_DATA 0x3b5
|
||||||
|
#define VGAREG_VGA_CRTC_ADDRESS 0x3d4
|
||||||
|
#define VGAREG_VGA_CRTC_DATA 0x3d5
|
||||||
|
|
||||||
|
#define VGAREG_MDA_WRITE_FEATURE_CTL 0x3ba
|
||||||
|
#define VGAREG_VGA_WRITE_FEATURE_CTL 0x3da
|
||||||
|
#define VGAREG_ACTL_RESET 0x3da
|
||||||
|
|
||||||
|
#define VGAREG_MDA_MODECTL 0x3b8
|
||||||
|
#define VGAREG_CGA_MODECTL 0x3d8
|
||||||
|
#define VGAREG_CGA_PALETTE 0x3d9
|
||||||
|
|
||||||
|
/* Video memory */
|
||||||
|
#define VGAMEM_GRAPH 0xA000
|
||||||
|
#define VGAMEM_CTEXT 0xB800
|
||||||
|
#define VGAMEM_MTEXT 0xB000
|
||||||
|
|
||||||
|
Register Mode320x200[];
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * functions needed for xvga.c
|
||||||
|
// ******************************************************************
|
||||||
|
void outportb(int port, unsigned char data);
|
||||||
|
void readyVgaRegs(void);
|
||||||
|
void outReg(Register r);
|
||||||
|
void vga_set_reg( int port, int reg, int data );
|
||||||
|
void vga_set_color( int reg, int R, int G, int B );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // XVGA_DEF_H
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,407 @@
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* File: hub.h */
|
||||||
|
/* bkenwright@xbdev.net - www.xbdev.net */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __HUB__
|
||||||
|
#define __HUB__
|
||||||
|
|
||||||
|
#include "ohci.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* USB CONSTANTS */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Device and/or Interface Class codes
|
||||||
|
*/
|
||||||
|
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||||
|
#define USB_CLASS_AUDIO 1
|
||||||
|
#define USB_CLASS_COMM 2
|
||||||
|
#define USB_CLASS_HID 3
|
||||||
|
#define USB_CLASS_PRINTER 7
|
||||||
|
#define USB_CLASS_MASS_STORAGE 8
|
||||||
|
#define USB_CLASS_HUB 9
|
||||||
|
#define USB_CLASS_DATA 10
|
||||||
|
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Descriptor types
|
||||||
|
*/
|
||||||
|
#define USB_DT_DEVICE 0x01
|
||||||
|
#define USB_DT_CONFIG 0x02
|
||||||
|
#define USB_DT_STRING 0x03
|
||||||
|
#define USB_DT_INTERFACE 0x04
|
||||||
|
#define USB_DT_ENDPOINT 0x05
|
||||||
|
|
||||||
|
#define USB_DT_HUB 0x29
|
||||||
|
#define USB_DT_HID 0x21
|
||||||
|
#define USB_DT_REPORT 0x22
|
||||||
|
#define USB_DT_PHYSICAL 0x23
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Descriptor sizes per descriptor type
|
||||||
|
*/
|
||||||
|
#define USB_DT_DEVICE_SIZE 18
|
||||||
|
#define USB_DT_CONFIG_SIZE 9
|
||||||
|
#define USB_DT_INTERFACE_SIZE 9
|
||||||
|
#define USB_DT_ENDPOINT_SIZE 7
|
||||||
|
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||||
|
#define USB_DT_HUB_NONVAR_SIZE 7
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB Request Type and Endpoint Directions
|
||||||
|
*/
|
||||||
|
#define USB_DIR_OUT 0
|
||||||
|
#define USB_DIR_IN 0x80
|
||||||
|
|
||||||
|
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||||
|
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||||
|
|
||||||
|
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||||
|
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||||
|
#define USB_ENDPOINT_XFER_ISOC 1
|
||||||
|
#define USB_ENDPOINT_XFER_BULK 2
|
||||||
|
#define USB_ENDPOINT_XFER_INT 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB Packet IDs (PIDs)
|
||||||
|
*/
|
||||||
|
#define USB_PID_OUT 0xe1
|
||||||
|
#define USB_PID_IN 0x69
|
||||||
|
#define USB_PID_SETUP 0x2d
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard requests
|
||||||
|
*/
|
||||||
|
#define USB_REQ_GET_STATUS 0x00
|
||||||
|
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||||
|
/* 0x02 is reserved */
|
||||||
|
#define USB_REQ_SET_FEATURE 0x03
|
||||||
|
/* 0x04 is reserved */
|
||||||
|
#define USB_REQ_SET_ADDRESS 0x05
|
||||||
|
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||||
|
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||||
|
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||||
|
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||||
|
#define USB_REQ_GET_INTERFACE 0x0A
|
||||||
|
#define USB_REQ_SET_INTERFACE 0x0B
|
||||||
|
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HIDD requests
|
||||||
|
*/
|
||||||
|
#define USB_REQ_GET_REPORT 0x01
|
||||||
|
#define USB_REQ_GET_IDLE 0x02
|
||||||
|
#define USB_REQ_GET_PROTOCOL 0x03
|
||||||
|
#define USB_REQ_SET_REPORT 0x09
|
||||||
|
#define USB_REQ_SET_IDLE 0x0A
|
||||||
|
#define USB_REQ_SET_PROTOCOL 0x0B
|
||||||
|
|
||||||
|
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||||
|
#define USB_TYPE_CLASS (0x01 << 5)
|
||||||
|
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||||
|
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||||
|
|
||||||
|
#define USB_RECIP_DEVICE 0x00
|
||||||
|
#define USB_RECIP_INTERFACE 0x01
|
||||||
|
#define USB_RECIP_ENDPOINT 0x02
|
||||||
|
#define USB_RECIP_OTHER 0x03
|
||||||
|
|
||||||
|
#define USB_HID_RPT_INPUT 0x01
|
||||||
|
#define USB_HID_RPT_OUTPUT 0x02
|
||||||
|
#define USB_HID_RPT_FEATURE 0x03
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Request target types.
|
||||||
|
*/
|
||||||
|
#define USB_RT_DEVICE 0x00
|
||||||
|
#define USB_RT_INTERFACE 0x01
|
||||||
|
#define USB_RT_ENDPOINT 0x02
|
||||||
|
|
||||||
|
#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
|
||||||
|
#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
|
||||||
|
|
||||||
|
#define USB_RT_HIDD (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* HUB CONTANTS */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub Class feature numbers
|
||||||
|
*/
|
||||||
|
#define C_HUB_LOCAL_POWER 0
|
||||||
|
#define C_HUB_OVER_CURRENT 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Port feature numbers
|
||||||
|
*/
|
||||||
|
#define USB_PORT_FEAT_CONNECTION 0
|
||||||
|
#define USB_PORT_FEAT_ENABLE 1
|
||||||
|
#define USB_PORT_FEAT_SUSPEND 2
|
||||||
|
#define USB_PORT_FEAT_OVER_CURRENT 3
|
||||||
|
#define USB_PORT_FEAT_RESET 4
|
||||||
|
#define USB_PORT_FEAT_POWER 8
|
||||||
|
#define USB_PORT_FEAT_LOWSPEED 9
|
||||||
|
#define USB_PORT_FEAT_C_CONNECTION 16
|
||||||
|
#define USB_PORT_FEAT_C_ENABLE 17
|
||||||
|
#define USB_PORT_FEAT_C_SUSPEND 18
|
||||||
|
#define USB_PORT_FEAT_C_OVER_CURRENT 19
|
||||||
|
#define USB_PORT_FEAT_C_RESET 20
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack( push, 1 )
|
||||||
|
struct usb_port_status
|
||||||
|
{
|
||||||
|
__u16 wPortStatus;
|
||||||
|
__u16 wPortChange;
|
||||||
|
};
|
||||||
|
#pragma pack( pop )
|
||||||
|
|
||||||
|
|
||||||
|
/* wPortStatus bits */
|
||||||
|
#define USB_PORT_STAT_CONNECTION 0x0001
|
||||||
|
#define USB_PORT_STAT_ENABLE 0x0002
|
||||||
|
#define USB_PORT_STAT_SUSPEND 0x0004
|
||||||
|
#define USB_PORT_STAT_OVERCURRENT 0x0008
|
||||||
|
#define USB_PORT_STAT_RESET 0x0010
|
||||||
|
#define USB_PORT_STAT_POWER 0x0100
|
||||||
|
#define USB_PORT_STAT_LOW_SPEED 0x0200
|
||||||
|
|
||||||
|
/* wPortChange bits */
|
||||||
|
#define USB_PORT_STAT_C_CONNECTION 0x0001
|
||||||
|
#define USB_PORT_STAT_C_ENABLE 0x0002
|
||||||
|
#define USB_PORT_STAT_C_SUSPEND 0x0004
|
||||||
|
#define USB_PORT_STAT_C_OVERCURRENT 0x0008
|
||||||
|
#define USB_PORT_STAT_C_RESET 0x0010
|
||||||
|
|
||||||
|
/* wHubCharacteristics (masks) */
|
||||||
|
#define HUB_CHAR_LPSM 0x0003
|
||||||
|
#define HUB_CHAR_COMPOUND 0x0004
|
||||||
|
#define HUB_CHAR_OCPM 0x0018
|
||||||
|
|
||||||
|
#pragma pack( push, 1 )
|
||||||
|
struct usb_hub_status
|
||||||
|
{
|
||||||
|
__u16 wHubStatus;
|
||||||
|
__u16 wHubChange;
|
||||||
|
};
|
||||||
|
#pragma pack( pop )
|
||||||
|
|
||||||
|
/*
|
||||||
|
*Hub Status & Hub Change bit masks
|
||||||
|
*/
|
||||||
|
#define HUB_STATUS_LOCAL_POWER 0x0001
|
||||||
|
#define HUB_STATUS_OVERCURRENT 0x0002
|
||||||
|
|
||||||
|
#define HUB_CHANGE_LOCAL_POWER 0x0001
|
||||||
|
#define HUB_CHANGE_OVERCURRENT 0x0002
|
||||||
|
|
||||||
|
/* Hub descriptor */
|
||||||
|
#pragma pack( push, 1 )
|
||||||
|
struct usb_hub_descriptor
|
||||||
|
{
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
__u8 bNbrPorts;
|
||||||
|
__u16 wHubCharacteristics;
|
||||||
|
__u8 bPwrOn2PwrGood;
|
||||||
|
__u8 bHubContrCurrent;
|
||||||
|
__u8 DeviceRemovable;
|
||||||
|
__u8 PortPowerCtrlMask;
|
||||||
|
};
|
||||||
|
#pragma pack( pop )
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct usb_hub_descriptor_t
|
||||||
|
{
|
||||||
|
__u8 bDescLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
__u8 bNbrPorts;
|
||||||
|
__u16 wHubCharacteristics;
|
||||||
|
#define UHD_PWR 0x0003
|
||||||
|
#define UHD_PWR_GANGED 0x0000
|
||||||
|
#define UHD_PWR_INDIVIDUAL 0x0001
|
||||||
|
#define UHD_PWR_NO_SWITCH 0x0002
|
||||||
|
#define UHD_COMPOUND 0x0004
|
||||||
|
#define UHD_OC 0x0018
|
||||||
|
#define UHD_OC_GLOBAL 0x0000
|
||||||
|
#define UHD_OC_INDIVIDUAL 0x0008
|
||||||
|
#define UHD_OC_NONE 0x0010
|
||||||
|
#define UHD_TT_THINK 0x0060
|
||||||
|
#define UHD_TT_THINK_8 0x0000
|
||||||
|
#define UHD_TT_THINK_16 0x0020
|
||||||
|
#define UHD_TT_THINK_24 0x0040
|
||||||
|
#define UHD_TT_THINK_32 0x0060
|
||||||
|
#define UHD_PORT_IND 0x0080
|
||||||
|
|
||||||
|
__u8 bPwrOn2PwrGood; // delay in 2 ms units
|
||||||
|
#define UHD_PWRON_FACTOR 2
|
||||||
|
|
||||||
|
__u8 bHubContrCurrent;
|
||||||
|
__u8 DeviceRemovable[32]; //max 255 ports
|
||||||
|
|
||||||
|
#define UHD_NOT_REMOV(desc, i) \
|
||||||
|
(((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
|
||||||
|
__u8 PortPowerCtrlMask[1]; // deprecated
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
#define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
int get_control_msg(ohci_t * ohci,
|
||||||
|
__u8 Addr,
|
||||||
|
__u8 request, // 0x06
|
||||||
|
__u8 requesttype, // 0x80
|
||||||
|
__u16 value,
|
||||||
|
__u16 index,
|
||||||
|
__u16 size,
|
||||||
|
__u8 * data );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int set_control_msg(ohci_t * ohci,
|
||||||
|
__u8 Addr,
|
||||||
|
__u8 request,
|
||||||
|
__u8 requesttype,
|
||||||
|
__u16 value,
|
||||||
|
__u16 index,
|
||||||
|
__u16 size,
|
||||||
|
__u8 * data );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//int usb_get_device_descriptor(ohci_t * ohci, __u8 Addr, int size, void *buf);
|
||||||
|
|
||||||
|
|
||||||
|
//int usb_get_hub_descriptor(ohci_t * ohci, __u8 Addr, int size, void *buf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int usb_set_configuration(ohci_t * ohci, __u8 Addr, int configuration);
|
||||||
|
|
||||||
|
|
||||||
|
void DebugHubDescriptor( usb_hub_descriptor * pDes );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#define UT_WRITE 0x00
|
||||||
|
#define UT_READ 0x80
|
||||||
|
#define UT_STANDARD 0x00
|
||||||
|
#define UT_CLASS 0x20
|
||||||
|
#define UT_VENDOR 0x40
|
||||||
|
#define UT_DEVICE 0x00
|
||||||
|
#define UT_INTERFACE 0x01
|
||||||
|
#define UT_ENDPOINT 0x02
|
||||||
|
#define UT_OTHER 0x03
|
||||||
|
|
||||||
|
#define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE)
|
||||||
|
#define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE)
|
||||||
|
#define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT)
|
||||||
|
#define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE)
|
||||||
|
#define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE)
|
||||||
|
#define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT)
|
||||||
|
#define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE)
|
||||||
|
#define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE)
|
||||||
|
#define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER)
|
||||||
|
#define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT)
|
||||||
|
#define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE)
|
||||||
|
#define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
|
||||||
|
#define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER)
|
||||||
|
#define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT)
|
||||||
|
#define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE)
|
||||||
|
#define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE)
|
||||||
|
#define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER)
|
||||||
|
#define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT)
|
||||||
|
#define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE)
|
||||||
|
#define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
|
||||||
|
#define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER)
|
||||||
|
#define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
|
||||||
|
|
||||||
|
/* Requests */
|
||||||
|
#define UR_GET_STATUS 0x00
|
||||||
|
#define UR_CLEAR_FEATURE 0x01
|
||||||
|
#define UR_SET_FEATURE 0x03
|
||||||
|
#define UR_SET_ADDRESS 0x05
|
||||||
|
#define UR_GET_DESCRIPTOR 0x06
|
||||||
|
#define UDESC_DEVICE 0x01
|
||||||
|
#define UDESC_CONFIG 0x02
|
||||||
|
#define UDESC_STRING 0x03
|
||||||
|
#define UDESC_INTERFACE 0x04
|
||||||
|
#define UDESC_ENDPOINT 0x05
|
||||||
|
#define UDESC_DEVICE_QUALIFIER 0x06
|
||||||
|
#define UDESC_OTHER_SPEED_CONFIGURATION 0x07
|
||||||
|
#define UDESC_INTERFACE_POWER 0x08
|
||||||
|
#define UDESC_OTG 0x09
|
||||||
|
#define UDESC_CS_DEVICE 0x21 /* class specific */
|
||||||
|
#define UDESC_CS_CONFIG 0x22
|
||||||
|
#define UDESC_CS_STRING 0x23
|
||||||
|
#define UDESC_CS_INTERFACE 0x24
|
||||||
|
#define UDESC_CS_ENDPOINT 0x25
|
||||||
|
#define UDESC_HUB 0x29
|
||||||
|
#define UR_SET_DESCRIPTOR 0x07
|
||||||
|
#define UR_GET_CONFIG 0x08
|
||||||
|
#define UR_SET_CONFIG 0x09
|
||||||
|
#define UR_GET_INTERFACE 0x0a
|
||||||
|
#define UR_SET_INTERFACE 0x0b
|
||||||
|
#define UR_SYNCH_FRAME 0x0c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************************/
|
||||||
|
|
||||||
|
struct devrequest
|
||||||
|
{
|
||||||
|
unsigned char requesttype; // 1 byte
|
||||||
|
unsigned char request; // 1 byte
|
||||||
|
unsigned short value; // 2 bytes
|
||||||
|
unsigned short index; // 2 bytes
|
||||||
|
unsigned short length; // 2 bytes
|
||||||
|
};// end devrequest // Total = 8 bytes
|
||||||
|
|
||||||
|
|
||||||
|
struct usbd_device
|
||||||
|
{
|
||||||
|
ohci_t * p_ohci; /* our ohci stuff */
|
||||||
|
__u8 address; /* device addess */
|
||||||
|
};// end usbd_device
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int usbd_get_desc(usbd_device * dev, int type, int index, int len, void *desc);
|
||||||
|
|
||||||
|
int usbd_do_request(usbd_device * dev, devrequest *req, void *data);
|
||||||
|
|
||||||
|
|
||||||
|
int usbd_get_hub_descriptor(usbd_device * dev, void * data);
|
||||||
|
|
||||||
|
|
||||||
|
int do_hub_work(usbd_device * dev);
|
||||||
|
|
||||||
|
|
||||||
|
int usbd_do_request_big_packet(usbd_device * dev, devrequest *req, void *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HUB__
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* File: misc.h */
|
||||||
|
/* Author: bkenwright@xbdev.net */
|
||||||
|
/* Desc: Misc functions, making our usb/gamepad code lib independent */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __XMISC__
|
||||||
|
#define __XMISC__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef unsigned char __u8;
|
||||||
|
typedef char __s8;
|
||||||
|
typedef unsigned short __u16;
|
||||||
|
typedef short __s16;
|
||||||
|
typedef unsigned long __u32;
|
||||||
|
typedef int __s32;
|
||||||
|
|
||||||
|
#define NULL 0
|
||||||
|
|
||||||
|
//#include <stdio.h>
|
||||||
|
//extern char buf[500];
|
||||||
|
//void dbg(char* str);
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* StdFunctions */
|
||||||
|
/* Didn't want our code being dependent on anything! For example Sleep(..) */
|
||||||
|
/* As its available in the xdk and the openxdk or linux?... Well I could */
|
||||||
|
/* write custom functions - giveing us the ultimate in flexiblity! */
|
||||||
|
/* We really are now a portible piece of code */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
void xSleep( long timemilliseconds );
|
||||||
|
|
||||||
|
void *xmemcpy(void *dest, const void *src, size_t n);
|
||||||
|
|
||||||
|
void *xmalloc(size_t size);
|
||||||
|
|
||||||
|
void *xmemset(void *s, int c, size_t n);
|
||||||
|
|
||||||
|
//unsigned __int64 MyGetTickCount();
|
||||||
|
unsigned int MyGetTickCount();
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Kernel Functions */
|
||||||
|
/* Here are the 2 kernal api's from the bios that we need to make this code */
|
||||||
|
/* work - everything else can be hand coded but these. As we need to use */
|
||||||
|
/* memory that isn't quite where its suppose to be! Remember where running */
|
||||||
|
/* in protected mode - so for our ohci registers, when we give them an */
|
||||||
|
/* address, it has to be the real physical address. If we where in the */
|
||||||
|
/* kernel or writing a kernel bios, we wolndt' need to worry about it..but we */
|
||||||
|
/* do here as where in the xbe! */
|
||||||
|
/* */
|
||||||
|
/* These are just wrapper's as we call the exact same function name..but */
|
||||||
|
/* without the x at the start. */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
__u32 xMmGetPhysicalAddress(__u32 BaseAddress);
|
||||||
|
void xMmLockUnlockBufferPages(__u32 MemoryAddress, __u32 NumberOfBytes, __u32 a);
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __XMISC__
|
|
@ -0,0 +1,242 @@
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* File: ohci.h */
|
||||||
|
/* */
|
||||||
|
/* Details: Original File & Design: Thomas Frei */
|
||||||
|
/* (modifications for xbox openxdk by bkenwright) */
|
||||||
|
/* (bkenwright@xbdev.net) www.xbdev.net */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __OHCI_X__
|
||||||
|
#define __OHCI_X__
|
||||||
|
|
||||||
|
#include "misc.h" // We only need this here, for the definitions of __u8, __u32 etc
|
||||||
|
// to be added in later (example):
|
||||||
|
|
||||||
|
|
||||||
|
// Example sippet of possible later improvment on structure aligment in vs
|
||||||
|
// __declspec(align(32)) struct Str1
|
||||||
|
// {
|
||||||
|
// int a, b, c, d, e;
|
||||||
|
// };
|
||||||
|
|
||||||
|
/*
|
||||||
|
typedef unsigned char __u8;
|
||||||
|
typedef char __s8;
|
||||||
|
typedef unsigned short __u16;
|
||||||
|
typedef short __s16;
|
||||||
|
typedef unsigned long __u32;
|
||||||
|
typedef int __s32;
|
||||||
|
|
||||||
|
#define NULL 0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SIZEOF_HCCA 0x100
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The HCCA (Host Controller Communications Area) is a 256 byte
|
||||||
|
* structure defined in the OHCI spec. that the host controller is
|
||||||
|
* told the base address of. It must be 256-byte aligned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define NUM_INTS 32 /* part of the OHCI standard */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack( push, 1 )
|
||||||
|
struct ohci_hcca
|
||||||
|
{
|
||||||
|
__u32 int_table[NUM_INTS]; /* Interrupt ED table */
|
||||||
|
__u16 frame_no; /* current frame number */
|
||||||
|
__u16 pad1; /* set to 0 on each frame_no change */
|
||||||
|
__u32 done_head; /* info returned for an interrupt */
|
||||||
|
__u8 reserved_for_hc[116];
|
||||||
|
};
|
||||||
|
#pragma pack( pop )
|
||||||
|
typedef struct ohci_hcca ohci_hcca_t;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Maximum number of root hub ports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_ROOT_PORTS 15
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
volatile struct ohci_regs
|
||||||
|
{
|
||||||
|
/* control and status registers */
|
||||||
|
__u32 revision;
|
||||||
|
__u32 control;
|
||||||
|
__u32 cmdstatus;
|
||||||
|
__u32 intrstatus;
|
||||||
|
__u32 intrenable;
|
||||||
|
__u32 intrdisable;
|
||||||
|
/* memory pointers */
|
||||||
|
__u32 hcca;
|
||||||
|
__u32 ed_periodcurrent;
|
||||||
|
__u32 ed_controlhead;
|
||||||
|
__u32 ed_controlcurrent;
|
||||||
|
__u32 ed_bulkhead;
|
||||||
|
__u32 ed_bulkcurrent;
|
||||||
|
__u32 donehead;
|
||||||
|
/* frame counters */
|
||||||
|
__u32 fminterval;
|
||||||
|
__u32 fmremaining;
|
||||||
|
__u32 fmnumber;
|
||||||
|
__u32 periodicstart;
|
||||||
|
__u32 lsthresh;
|
||||||
|
/* Root hub ports */
|
||||||
|
volatile struct ohci_roothub_regs
|
||||||
|
{
|
||||||
|
__u32 a;
|
||||||
|
__u32 b;
|
||||||
|
__u32 status;
|
||||||
|
__u32 portstatus[MAX_ROOT_PORTS];
|
||||||
|
} roothub;
|
||||||
|
};
|
||||||
|
#pragma pack()
|
||||||
|
typedef struct ohci_regs ohci_regs_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct ohci
|
||||||
|
{
|
||||||
|
volatile struct ohci_hcca *hcca; /* hcca */
|
||||||
|
|
||||||
|
volatile struct ohci_regs * regs; /* OHCI controller's memory */
|
||||||
|
|
||||||
|
} ohci_t;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#define SKIP 0x4000L
|
||||||
|
#define OUTV 0x0800L
|
||||||
|
#define INV 0x1000L
|
||||||
|
#define AUTOIO 0x1800L
|
||||||
|
#define LOWS 0x2000L
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#pragma block (push,1)
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct {
|
||||||
|
__u32 Format;
|
||||||
|
__u32 Tailptr;
|
||||||
|
__u32 Headptr;
|
||||||
|
__u32 NextED;
|
||||||
|
} s_Endpointdescripor;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct {
|
||||||
|
__u32 Format;
|
||||||
|
__u32 Buffer;
|
||||||
|
__u32 NextTD;
|
||||||
|
__u32 BufferEnd;
|
||||||
|
} s_Transferdescriptor;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct {
|
||||||
|
__u8 Length;
|
||||||
|
__u8 DescriptorType;
|
||||||
|
__u16 USB;
|
||||||
|
__u8 DeviceClass;
|
||||||
|
__u8 DeviceSubClass;
|
||||||
|
__u8 DeviceProtocol;
|
||||||
|
__u8 MaxPacketSize;
|
||||||
|
__u16 Vendor;
|
||||||
|
__u16 ProductID;
|
||||||
|
__u16 Device;
|
||||||
|
__u8 Manufacturer;
|
||||||
|
__u8 ProductIndex;
|
||||||
|
__u8 SerialNumber;
|
||||||
|
__u8 ConfigNumber;
|
||||||
|
} s_USB_Devicedescriptor;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct {
|
||||||
|
__u8 Length;
|
||||||
|
__u8 DescriptorType;
|
||||||
|
__u16 TotalLength;
|
||||||
|
__u8 NumberofInterfaces;
|
||||||
|
__u8 ConfigValue;
|
||||||
|
__u8 Configuration;
|
||||||
|
__u8 Attributes;
|
||||||
|
__u8 MaxPower;
|
||||||
|
} s_USB_Configurationdescriptor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
__u8 Length;
|
||||||
|
__u8 DescriptorType;
|
||||||
|
__u8 Interfacenumber;
|
||||||
|
__u8 AlternateSetting;
|
||||||
|
__u8 NumberofEndpoints;
|
||||||
|
__u8 InterfaceClass;
|
||||||
|
__u8 InterfaceSubClass;
|
||||||
|
__u8 InterfaceProtocol;
|
||||||
|
__u8 InterfaceIndex;
|
||||||
|
} s_USB_Interfacedescriptor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
__u8 Length;
|
||||||
|
__u8 DescriptorType;
|
||||||
|
__u8 EndpointAddress;
|
||||||
|
__u8 Attributes;
|
||||||
|
__u16 MaxPacketSize;
|
||||||
|
__u8 Interval;
|
||||||
|
} s_USB_Endpointdescriptor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
__u8 Length;
|
||||||
|
__u8 DescriptorType;
|
||||||
|
__u16 *LANGID;
|
||||||
|
} s_USB_Languagedescriptor;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
__u8 Length;
|
||||||
|
__u8 DescriptorType;
|
||||||
|
__u8 *String;
|
||||||
|
} s_USB_Stringdescriptor;
|
||||||
|
//#pragma block (pop)
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// Main Functions
|
||||||
|
int FindOHC(ohci_t * ohci, void *regbase);
|
||||||
|
int FindDev(ohci_t * ohci, int Port);
|
||||||
|
|
||||||
|
|
||||||
|
int ResetPort(ohci_t * ohci, int Port);
|
||||||
|
int SetAddres(ohci_t * ohci, int Port, __u8 AddrNew);
|
||||||
|
int SetConfigur(ohci_t * ohci, __u8 Addr, __u8 Config);
|
||||||
|
int GetDesc(ohci_t * ohci, __u8 Addr, __u8 DescrType, __u8 Index, __u8 Count, __u8 *DBuffer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Debug Functions
|
||||||
|
void DebugFile(ohci_t * ohci);
|
||||||
|
void DebugDescriptor( s_USB_Devicedescriptor * pDes );
|
||||||
|
void DebugConfigDescriptor( s_USB_Configurationdescriptor * pDes );
|
||||||
|
void DebugInterfaceDescriptor( s_USB_Interfacedescriptor * pDes );
|
||||||
|
void DebugEndPointDescriptor( s_USB_Endpointdescriptor * pDes );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __OHCI_X__
|
|
@ -0,0 +1,89 @@
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* File: pad.h */
|
||||||
|
/* bkenwright@xbdev.net - www.xbdev.net */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
What on earth! Whats this file for?
|
||||||
|
Well once we have our usb device address set...for the xbox gamepad :)
|
||||||
|
This file will do some simple commands...sending bulk test messages
|
||||||
|
...an example would be to send a rumble message?
|
||||||
|
Also probe for some button presses?
|
||||||
|
|
||||||
|
In Development though.
|
||||||
|
*/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __PAD__
|
||||||
|
#define __PAD__
|
||||||
|
|
||||||
|
|
||||||
|
#include "ohci.h"
|
||||||
|
#include "hub.h"
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* stXPAD - Gamepad Data Structure */
|
||||||
|
/* This structure will be filled in by our USB Gamepad - its the data that */
|
||||||
|
/* is returned to us when we request a gamepad in on the usb bus. */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(1) // We use this, so our data is packed nice and tight!..no space.
|
||||||
|
struct stXPAD // Packed to 1 byte alignment.
|
||||||
|
{
|
||||||
|
char reserved1;
|
||||||
|
unsigned char structsize;
|
||||||
|
|
||||||
|
char pad; /* 1 up 2 down 4 left 8 right */
|
||||||
|
char reserved2;
|
||||||
|
unsigned char keys[6]; /* A B X Y Black White */
|
||||||
|
|
||||||
|
unsigned char trig_left;
|
||||||
|
unsigned char trig_right;
|
||||||
|
short stick_left_x;
|
||||||
|
short stick_left_y;
|
||||||
|
short stick_right_x;
|
||||||
|
short stick_right_y;
|
||||||
|
|
||||||
|
char padding[0x40];
|
||||||
|
};
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* stRumbleXPAD */
|
||||||
|
/* We will fill this with data later on, that we will pass to the gamepad, */
|
||||||
|
/* it will specify the left or right rumble and speed for example */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
struct stRumbleXPAD
|
||||||
|
{
|
||||||
|
};
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Functions */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
void usb_bulk_msg( usbd_device * dev, int size, void * data ); // Send data to the USB
|
||||||
|
|
||||||
|
void usb_bulk_msg_in( usbd_device * dev, int size, void * data ); // Get data from the USB
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __PAD__
|
|
@ -0,0 +1,96 @@
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* File: xinput.h */
|
||||||
|
/* Auth: bkenwright@xbdev.net */
|
||||||
|
/* Desc: GamePad entry code for use on the xbox. */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
This is our xinput header file, this is where all our functions that we'll
|
||||||
|
use in our game or app for the xbox that 'require' gamepad support will
|
||||||
|
be put.
|
||||||
|
*/
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
How does this code work? What lib's does it need? How would I use it
|
||||||
|
in my code?
|
||||||
|
|
||||||
|
Well the aim of the gamepad code was to develop an independent set of
|
||||||
|
code for the openxdk - but because it's lib independent it also works on
|
||||||
|
the xdk.
|
||||||
|
|
||||||
|
<1> Include our header file, and the other files which do all the work..
|
||||||
|
later they'll be put into a library
|
||||||
|
e.g. #include "xinput/xinput.h" // Gamepad input
|
||||||
|
|
||||||
|
<2> Init our gamepad code
|
||||||
|
e.g.
|
||||||
|
stXINPUT xin;
|
||||||
|
xInitInput(&xin);
|
||||||
|
You do this ocne at the start of the program, I did it this way as I don't
|
||||||
|
like globals, so you need to pass it a stuct called stXINPUT which
|
||||||
|
keeps all our usb/gampad information in.
|
||||||
|
|
||||||
|
<3> Get our gamepad information in our main loop e.g:
|
||||||
|
stXPAD pad;
|
||||||
|
xGetPadInput(&pad, &xin);
|
||||||
|
|
||||||
|
<4> When we've all finished, call xReleaseInput(&xin);
|
||||||
|
|
||||||
|
<Misc> You can also set the rumble effect - still in development
|
||||||
|
e.g. xSetPadInput(&pad, &xin);
|
||||||
|
*/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __XINPUT__
|
||||||
|
#define __XINPUT__
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "ohci.h"
|
||||||
|
#include "pad.h" // for stXPAD definition
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// About this - at the moment it just contains the offset to the ohci memory
|
||||||
|
// location (e.g. 0xfed00000...but we will also use this to keep track of
|
||||||
|
// alocated memory - how many gamepads are plugged in...usb dev drivers etc.
|
||||||
|
|
||||||
|
struct stXINPUT
|
||||||
|
{
|
||||||
|
ohci_t my_ohci;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct stXPAD; // Defined in xpad.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Interface Functions */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
//<1> Creation
|
||||||
|
int xInitInput(stXINPUT* p);
|
||||||
|
|
||||||
|
//<2> Probing/ Getting or Setting Gamepad
|
||||||
|
int xGetPadInput(stXPAD * p, stXINPUT * xin, int iWhichPad = 0); // 0 is default pad
|
||||||
|
int xSetPadInput(stXPAD * p, stXINPUT * xin, int iWhichPad = 0);
|
||||||
|
|
||||||
|
//<3> Death End
|
||||||
|
int xReleaseInput(stXINPUT * p);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __XINPUT__
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
/******************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* It has arrived! */
|
||||||
|
/* */
|
||||||
|
/* Gamepad support for the OpenXDK */
|
||||||
|
/* */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
This is a lib build of the gamepad code - its more or less independent..it
|
||||||
|
doens't need any of the other openxdk header files, and will work in the ms xdk
|
||||||
|
as well.
|
||||||
|
|
||||||
|
Its been designed to be as flexible as possible - so many of the xinput.h
|
||||||
|
interface functions have been designed so we can tweek away at the workings
|
||||||
|
and get you a great feel in tim.
|
||||||
|
|
||||||
|
It works! But might need a bit of improvement for speed.
|
||||||
|
|
||||||
|
Externals:
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" __u32 __stdcall MmAllocateContiguousMemory(__u32 a);
|
||||||
|
extern "C" __u32 __stdcall MmLockUnlockBufferPages(__u32 MemoryAddress, __u32 NumberOfBytes, __u32 a);
|
||||||
|
extern "C" __u32 __stdcall MmGetPhysicalAddress(__u32 BaseAddress);
|
||||||
|
|
||||||
|
|
||||||
|
These are the only external links in our code! Everything else..even the
|
||||||
|
myGetTickCount() have all been implemented inside our code!
|
||||||
|
|
||||||
|
|
||||||
|
How to use it:
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/*
|
||||||
|
How does this code work? What lib's does it need? How would I use it
|
||||||
|
in my code?
|
||||||
|
|
||||||
|
Well the aim of the gamepad code was to develop an independent set of
|
||||||
|
code for the openxdk - but because it's lib independent it also works on
|
||||||
|
the xdk.
|
||||||
|
|
||||||
|
<1> Include our header file, and the other files which do all the work..
|
||||||
|
later they'll be put into a library
|
||||||
|
e.g. #include "xinput/xinput.h" // Gamepad input
|
||||||
|
|
||||||
|
<2> Init our gamepad code
|
||||||
|
e.g.
|
||||||
|
stXINPUT xin;
|
||||||
|
xInitInput(&xin);
|
||||||
|
You do this ocne at the start of the program, I did it this way as I don't
|
||||||
|
like globals, so you need to pass it a stuct called stXINPUT which
|
||||||
|
keeps all our usb/gampad information in.
|
||||||
|
|
||||||
|
<3> Get our gamepad information in our main loop e.g:
|
||||||
|
stXPAD pad;
|
||||||
|
xGetPadInput(&pad, &xin);
|
||||||
|
|
||||||
|
<4> When we've all finished, call xReleaseInput(&xin);
|
||||||
|
|
||||||
|
<Misc> You can also set the rumble effect - still in development
|
||||||
|
e.g. xSetPadInput(&pad, &xin);
|
||||||
|
*/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
Feedback welcome: bkenwright@xbdev.net
|
||||||
|
|
||||||
|
|
||||||
|
Edits to OpenXDK main code:
|
||||||
|
|
||||||
|
mm.h line:83
|
||||||
|
|
||||||
|
from:
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmLockUnlockBufferPages;
|
||||||
|
|
||||||
|
to:
|
||||||
|
|
||||||
|
XBSYSAPI EXPORTNUM(175) PHYSICAL_ADDRESS NTAPI MmLockUnlockBufferPages
|
||||||
|
(
|
||||||
|
IN PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN ULONG Protect
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
mm.c line:94
|
||||||
|
|
||||||
|
from:
|
||||||
|
|
||||||
|
XBSYSAPI VOID *MmLockUnlockBufferPages = 0;
|
||||||
|
|
||||||
|
to:
|
||||||
|
|
||||||
|
|
||||||
|
XBSYSAPI EXPORTNUM(175) PHYSICAL_ADDRESS NTAPI MmLockUnlockBufferPages
|
||||||
|
(
|
||||||
|
IN PHYSICAL_ADDRESS BaseAddress,
|
||||||
|
IN ULONG NumberOfBytes,
|
||||||
|
IN ULONG Protect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : ansidecl.h
|
||||||
|
// *
|
||||||
|
// * note : This LIBC is TOTALLY free - do what you like with it!!
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __OPENXDK_ANSIDECL__
|
||||||
|
#define __OPENXDK_ANSIDECL__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Bigboy types
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef _BIGBOY_TYPES_
|
||||||
|
#define _BIGBOY_TYPES_
|
||||||
|
typedef unsigned char byte;
|
||||||
|
typedef unsigned char u8;
|
||||||
|
typedef signed char s8;
|
||||||
|
typedef unsigned short u16;
|
||||||
|
typedef signed short s16;
|
||||||
|
typedef unsigned int u32;
|
||||||
|
typedef signed int s32;
|
||||||
|
#endif //_BIGBOY_TYPES_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL 0x00
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef true
|
||||||
|
#define true 1
|
||||||
|
#endif
|
||||||
|
#ifndef false
|
||||||
|
#define false 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SIZE_T_
|
||||||
|
#define __SIZE_T_
|
||||||
|
typedef unsigned int size_t;
|
||||||
|
#endif //__SIZE_T_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __OPENXDK_ANSIDECL__
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : ctype.h
|
||||||
|
// *
|
||||||
|
// * note : This LIBC is TOTALLY free - do what you like with it!!
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __OPENXDK_CTYPE__
|
||||||
|
#define __OPENXDK_CTYPE__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ansidecl.h>
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Structures
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Functions
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
|
||||||
|
#define tolower(c) (c>='A' && c<='Z')?c+('a'-'A'):c
|
||||||
|
#define toupper(c) (c>='a' && c<='z')?c+('A'-'a'):c
|
||||||
|
#define isdigit(c) (c>='0' && c<='9')?1:0
|
||||||
|
#define isxdigit(c) (c>='0' && c<='9' || c>='a' && c<='f' || c>='A' && c<='F')?1:0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __OPENXDK_CTYPE__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
#ifndef __OPENXDK_MALLOC__
|
||||||
|
#define __OPENXDK_MALLOC__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//dummy malloc to make bitmap lib compile :P
|
||||||
|
|
||||||
|
void *malloc(size_t);
|
||||||
|
void free(void *);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,77 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : math.h
|
||||||
|
// *
|
||||||
|
// * note : This LIBC is TOTALLY free - do what you like with it!!
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __OPENXDK_MATH__
|
||||||
|
#define __OPENXDK_MATH__
|
||||||
|
|
||||||
|
//here for now
|
||||||
|
#define OPENXDK_UNIMPLEMENTEDC(x) // x are not implemented in C!
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Double-precision functions
|
||||||
|
|
||||||
|
//trig
|
||||||
|
double sin(double);
|
||||||
|
double cos(double);
|
||||||
|
double tan(double);
|
||||||
|
double asin(double);
|
||||||
|
double acos(double);
|
||||||
|
double atan(double);
|
||||||
|
double atan2(double, double);
|
||||||
|
|
||||||
|
//power
|
||||||
|
double sqrt(double);
|
||||||
|
double pow(double, double); //approx.
|
||||||
|
double exp(double); //approx.
|
||||||
|
double log(double); //approx.
|
||||||
|
double log10(double); //approx
|
||||||
|
double hypot(double, double);
|
||||||
|
|
||||||
|
//rounding
|
||||||
|
double ceil(double);
|
||||||
|
double floor(double);
|
||||||
|
double fmod(double, double);
|
||||||
|
double fabs(double);
|
||||||
|
|
||||||
|
//Single-precision functions
|
||||||
|
|
||||||
|
//trig
|
||||||
|
float sinf(float);
|
||||||
|
float cosf(float);
|
||||||
|
float tanf(float);
|
||||||
|
float asinf(float);
|
||||||
|
float acosf(float);
|
||||||
|
float atanf(float);
|
||||||
|
float atan2f(float, float);
|
||||||
|
|
||||||
|
//power
|
||||||
|
float sqrtf(float);
|
||||||
|
float powf(float, float);//approx.
|
||||||
|
float expf(float);//approx.
|
||||||
|
float logf(float);//approx.
|
||||||
|
float log10f(float);//approx
|
||||||
|
float hypotf(float, float);
|
||||||
|
|
||||||
|
//rounding
|
||||||
|
float ceilf(float);
|
||||||
|
float floorf(float);
|
||||||
|
float fmodf(float, float);
|
||||||
|
float fabsf(float);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //__OPENXDK_MATH__
|
|
@ -0,0 +1,65 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : stdarg.h
|
||||||
|
// *
|
||||||
|
// * note : This LIBC is TOTALLY free - do what you like with it!!
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
// a
|
||||||
|
#ifndef __OPENXDK_STDARG__
|
||||||
|
#define __OPENXDK_STDARG__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(push,8)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _VA_LIST_DEFINED
|
||||||
|
#ifdef _M_ALPHA
|
||||||
|
typedef struct {
|
||||||
|
char *a0; // pointer to first argument
|
||||||
|
int offset; // byte offset of next arg
|
||||||
|
} va_list;
|
||||||
|
#else
|
||||||
|
typedef char * va_list;
|
||||||
|
#endif
|
||||||
|
#define _VA_LIST_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// GET rid of C4146 compiler warnings: unary minus operator applied to unsigned type, result still unsigned
|
||||||
|
#define NEGU32(a) ((u32) (-((s32)(a))) )
|
||||||
|
|
||||||
|
|
||||||
|
#define _INTSIZEOF(n) ( (sizeof(n) + (sizeof(int) - 1)) & NEGU32(sizeof(int)) )
|
||||||
|
#define va_start(ap,v) ( ap = (va_list)&v + _INTSIZEOF(v) )
|
||||||
|
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
|
||||||
|
#define va_end(ap) ( ap = (va_list)0 )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
#endif // __OPENXDK_STDARG__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : stdio.h
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __STDIO_H__
|
||||||
|
#define __STDIO_H__ 1
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#include <openxdk.h>
|
||||||
|
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// Low level input/output functions
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#define _O_RDONLY (0x00000001)
|
||||||
|
#define _O_WRONLY (0x00000002)
|
||||||
|
#define _O_RDWR (0x00000003)
|
||||||
|
#define _O_NBLOCK (0x00000010)
|
||||||
|
#define _O_APPEND (0x00000100)
|
||||||
|
#define _O_CREAT (0x00000200)
|
||||||
|
#define _O_TRUNC (0x00000400)
|
||||||
|
#define _O_EXCL (0x00000800)
|
||||||
|
#define _O_TEMPORARY (0x00001000)
|
||||||
|
#define _O_TEXT (0x00004000)
|
||||||
|
#define _O_BINARY (0x00008000)
|
||||||
|
|
||||||
|
#define O_RDONLY _O_RDONLY
|
||||||
|
#define O_WRONLY _O_WRONLY
|
||||||
|
#define O_RDWR _O_RDWR
|
||||||
|
#define O_NBLOCK _O_NBLOCK
|
||||||
|
#define O_APPEND _O_APPEND
|
||||||
|
#define O_CREAT _O_CREAT
|
||||||
|
#define O_EXCL _O_EXCL
|
||||||
|
#define O_TRUNC _O_TRUNC
|
||||||
|
#define O_TEMPORARY _O_TEMPORARY
|
||||||
|
#define O_TEXT _O_TEXT
|
||||||
|
#define O_BINARY _O_BINARY
|
||||||
|
|
||||||
|
|
||||||
|
#define SEEK_SET 0
|
||||||
|
#define SEEK_CUR 1
|
||||||
|
#define SEEK_END 2
|
||||||
|
|
||||||
|
extern u32 LastErrorCode;
|
||||||
|
|
||||||
|
typedef unsigned int size_t;
|
||||||
|
|
||||||
|
int _open( char *filename, int oflag, int permission );
|
||||||
|
int _read( int handle, void *buffer, unsigned int count );
|
||||||
|
int _write( int handle, void* buffer, unsigned int count );
|
||||||
|
int _close( int handle );
|
||||||
|
int _lseek( int handle, u32 offset, int base );
|
||||||
|
|
||||||
|
//int printf(const char *format, ...);
|
||||||
|
//int vsnprintf( char *buffer, unsigned int count, const char *format, va_list ap );
|
||||||
|
int sprintf(char*, const char *format, ...);
|
||||||
|
int snprintf (char *str, size_t size, const char *format, ...);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// Standard C file input/output functions
|
||||||
|
// (Which are just wrappers for the low level ones)
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#define EOF (-1)
|
||||||
|
|
||||||
|
struct __stdio_file {
|
||||||
|
int fd;
|
||||||
|
int flags;
|
||||||
|
unsigned int bs; /* read: bytes in buffer */
|
||||||
|
unsigned int bm; /* position in buffer */
|
||||||
|
unsigned int buflen; /* length of buf */
|
||||||
|
char *buf;
|
||||||
|
unsigned char ungetbuf;
|
||||||
|
char ungotten;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct __stdio_file FILE;
|
||||||
|
|
||||||
|
|
||||||
|
FILE *fopen(char *path, const char *mode);
|
||||||
|
size_t fread( void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
|
size_t fwrite( void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
|
int fclose(FILE *stream);
|
||||||
|
|
||||||
|
int fprintf(FILE *f,const char *format,...);
|
||||||
|
int fseek(FILE *stream, long offset, int whence);
|
||||||
|
long ftell(FILE *stream) ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ifdef __cplusplus
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif // __STDIO_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : stdlib.h
|
||||||
|
// *
|
||||||
|
// * note : This LIBC is TOTALLY free - do what you like with it!!
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __OPENXDK_STDLIB__
|
||||||
|
#define __OPENXDK_STDLIB__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ansidecl.h>
|
||||||
|
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Defines etc.
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
// we could just as well use any other randmax 2^x-1 but this seems to be the standard
|
||||||
|
#define RAND_MAX 32767
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Structures
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct Sdiv_t{ // div structure
|
||||||
|
int quot;
|
||||||
|
int rem;
|
||||||
|
} div_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct Sldiv_t{ // ldiv structure
|
||||||
|
long int quot;
|
||||||
|
long int rem;
|
||||||
|
} ldiv_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Functions
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
int abs( int i );
|
||||||
|
void abort( void );
|
||||||
|
div_t div( int number, int divisor );
|
||||||
|
ldiv_t ldiv( long int number, long int divisor );
|
||||||
|
char* itoa( int value, char *string, int radix );
|
||||||
|
char* ltoa( long value, char *string, int radix );
|
||||||
|
int rand( void );
|
||||||
|
void srand( unsigned int );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //__OPENXDK_STDLIB__
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : openLIBC
|
||||||
|
// *
|
||||||
|
// * desc : Totally Free LIC replacement
|
||||||
|
// *
|
||||||
|
// * file : string.h
|
||||||
|
// *
|
||||||
|
// * note : This LIBC is TOTALLY free - do what you like with it!!
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
|
||||||
|
#ifndef __OPENXDK_STRING__
|
||||||
|
#define __OPENXDK_STRING__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ansidecl.h>
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Structures
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
// *****************************************************************************
|
||||||
|
//
|
||||||
|
// Functions
|
||||||
|
//
|
||||||
|
// *****************************************************************************
|
||||||
|
char* strcat( char *dest, const char *src );
|
||||||
|
char* strncpy( char *dest, const char *src, unsigned int count );
|
||||||
|
char* strcpy( char *dest, const char *src );
|
||||||
|
size_t strlen( const char *string );
|
||||||
|
void* memcpy( void *dest, const void *src, int count );
|
||||||
|
void* memccpy( void *dest, const void *src, int c, unsigned int count );
|
||||||
|
int memcmp( const void *buff1, const void *buff2, size_t count );
|
||||||
|
void *memset( void *Dest, int fill, size_t length );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __OPENXDK_STRING__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,479 @@
|
||||||
|
#ifndef _I386_BITOPS_H
|
||||||
|
#define _I386_BITOPS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 1992, Linus Torvalds.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #include <linux/config.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These have to be done with inline assembly: that way the bit-setting
|
||||||
|
* is guaranteed to be atomic. All bit operations return 0 if the bit
|
||||||
|
* was cleared before the operation and != 0 if it was not.
|
||||||
|
*
|
||||||
|
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
#define LOCK_PREFIX "lock ; "
|
||||||
|
#else
|
||||||
|
#define LOCK_PREFIX ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ADDR (*(volatile long *) addr)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set_bit - Atomically set a bit in memory
|
||||||
|
* @nr: the bit to set
|
||||||
|
* @addr: the address to start counting from
|
||||||
|
*
|
||||||
|
* This function is atomic and may not be reordered. See __set_bit()
|
||||||
|
* if you do not require the atomic guarantees.
|
||||||
|
* Note that @nr may be almost arbitrarily large; this function is not
|
||||||
|
* restricted to acting on a single-word quantity.
|
||||||
|
*/
|
||||||
|
/*static __inline__ void set_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
__asm__ __volatile__( LOCK_PREFIX
|
||||||
|
"btsl %1,%0"
|
||||||
|
:"=m" (ADDR)
|
||||||
|
:"Ir" (nr));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static __inline void set_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock bts [ebx], eax
|
||||||
|
sbb eax, eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __set_bit - Set a bit in memory
|
||||||
|
* @nr: the bit to set
|
||||||
|
* @addr: the address to start counting from
|
||||||
|
*
|
||||||
|
* Unlike set_bit(), this function is non-atomic and may be reordered.
|
||||||
|
* If it's called on the same region of memory simultaneously, the effect
|
||||||
|
* may be that only one operation succeeds.
|
||||||
|
*/
|
||||||
|
static __inline void __set_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock bts [ebx], eax
|
||||||
|
sbb eax, eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clear_bit - Clears a bit in memory
|
||||||
|
* @nr: Bit to clear
|
||||||
|
* @addr: Address to start counting from
|
||||||
|
*
|
||||||
|
* clear_bit() is atomic and may not be reordered. However, it does
|
||||||
|
* not contain a memory barrier, so if it is used for locking purposes,
|
||||||
|
* you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
|
||||||
|
* in order to ensure changes are visible on other processors.
|
||||||
|
*/
|
||||||
|
static __inline void clear_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btr [ebx], eax
|
||||||
|
sbb eax, eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#define smp_mb__before_clear_bit() barrier()
|
||||||
|
#define smp_mb__after_clear_bit() barrier()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __change_bit - Toggle a bit in memory
|
||||||
|
* @nr: the bit to set
|
||||||
|
* @addr: the address to start counting from
|
||||||
|
*
|
||||||
|
* Unlike change_bit(), this function is non-atomic and may be reordered.
|
||||||
|
* If it's called on the same region of memory simultaneously, the effect
|
||||||
|
* may be that only one operation succeeds.
|
||||||
|
*/
|
||||||
|
static __inline void __change_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btc [ebx], eax
|
||||||
|
sbb eax, eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* change_bit - Toggle a bit in memory
|
||||||
|
* @nr: Bit to clear
|
||||||
|
* @addr: Address to start counting from
|
||||||
|
*
|
||||||
|
* change_bit() is atomic and may not be reordered.
|
||||||
|
* Note that @nr may be almost arbitrarily large; this function is not
|
||||||
|
* restricted to acting on a single-word quantity.
|
||||||
|
*/
|
||||||
|
static __inline void change_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btc [ebx], eax
|
||||||
|
sbb eax, eax
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test_and_set_bit - Set a bit and return its old value
|
||||||
|
* @nr: Bit to set
|
||||||
|
* @addr: Address to count from
|
||||||
|
*
|
||||||
|
* This operation is atomic and cannot be reordered.
|
||||||
|
* It also implies a memory barrier.
|
||||||
|
*/
|
||||||
|
static __inline int test_and_set_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock bts [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/* __asm__ __volatile__( LOCK_PREFIX
|
||||||
|
"btsl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit),"=m" (ADDR)
|
||||||
|
:"Ir" (nr) : "memory");
|
||||||
|
*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __test_and_set_bit - Set a bit and return its old value
|
||||||
|
* @nr: Bit to set
|
||||||
|
* @addr: Address to count from
|
||||||
|
*
|
||||||
|
* This operation is non-atomic and can be reordered.
|
||||||
|
* If two examples of this operation race, one can appear to succeed
|
||||||
|
* but actually fail. You must protect multiple accesses with a lock.
|
||||||
|
*/
|
||||||
|
static __inline int __test_and_set_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock bts [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/*__asm__(
|
||||||
|
"btsl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit),"=m" (ADDR)
|
||||||
|
:"Ir" (nr));*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test_and_clear_bit - Clear a bit and return its old value
|
||||||
|
* @nr: Bit to set
|
||||||
|
* @addr: Address to count from
|
||||||
|
*
|
||||||
|
* This operation is atomic and cannot be reordered.
|
||||||
|
* It also implies a memory barrier.
|
||||||
|
*/
|
||||||
|
static __inline int test_and_clear_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btr [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
__asm__ __volatile__( LOCK_PREFIX
|
||||||
|
"btrl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit),"=m" (ADDR)
|
||||||
|
:"Ir" (nr) : "memory");
|
||||||
|
*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __test_and_clear_bit - Clear a bit and return its old value
|
||||||
|
* @nr: Bit to set
|
||||||
|
* @addr: Address to count from
|
||||||
|
*
|
||||||
|
* This operation is non-atomic and can be reordered.
|
||||||
|
* If two examples of this operation race, one can appear to succeed
|
||||||
|
* but actually fail. You must protect multiple accesses with a lock.
|
||||||
|
*/
|
||||||
|
static __inline int __test_and_clear_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btr [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
__asm__(
|
||||||
|
"btrl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit),"=m" (ADDR)
|
||||||
|
:"Ir" (nr));
|
||||||
|
*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WARNING: non atomic and it can be reordered! */
|
||||||
|
static __inline int __test_and_change_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btc [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"btcl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit),"=m" (ADDR)
|
||||||
|
:"Ir" (nr) : "memory");*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test_and_change_bit - Change a bit and return its new value
|
||||||
|
* @nr: Bit to set
|
||||||
|
* @addr: Address to count from
|
||||||
|
*
|
||||||
|
* This operation is atomic and cannot be reordered.
|
||||||
|
* It also implies a memory barrier.
|
||||||
|
*/
|
||||||
|
static __inline int test_and_change_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock btc [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
__asm__ __volatile__( LOCK_PREFIX
|
||||||
|
"btcl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit),"=m" (ADDR)
|
||||||
|
:"Ir" (nr) : "memory");*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0 /* Fool kernel-doc since it doesn't do macros yet */
|
||||||
|
/**
|
||||||
|
* test_bit - Determine whether a bit is set
|
||||||
|
* @nr: bit number to test
|
||||||
|
* @addr: Address to start counting from
|
||||||
|
*/
|
||||||
|
static int test_bit(int nr, const volatile void * addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static __inline int constant_test_bit(int nr, const volatile void * addr)
|
||||||
|
{
|
||||||
|
return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline int variable_test_bit(int nr, volatile void * addr)
|
||||||
|
{
|
||||||
|
int oldbit;
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov eax, nr
|
||||||
|
mov ebx, addr
|
||||||
|
lock bt [ebx], eax
|
||||||
|
sbb eax, eax // result into eax
|
||||||
|
mov oldbit,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"btl %2,%1\n\tsbbl %0,%0"
|
||||||
|
:"=r" (oldbit)
|
||||||
|
:"m" (ADDR),"Ir" (nr));*/
|
||||||
|
return oldbit;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define test_bit(nr,addr) \
|
||||||
|
(__builtin_constant_p(nr) ? \
|
||||||
|
constant_test_bit((nr),(addr)) : \
|
||||||
|
variable_test_bit((nr),(addr)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find_first_zero_bit - find the first zero bit in a memory region
|
||||||
|
* @addr: The address to start the search at
|
||||||
|
* @size: The maximum size to search
|
||||||
|
*
|
||||||
|
* Returns the bit-number of the first zero bit, not the number of the byte
|
||||||
|
* containing a bit.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
static __inline int find_first_zero_bit(void * addr, unsigned size)
|
||||||
|
{
|
||||||
|
int d0, d1, d2;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (!size)
|
||||||
|
return 0;
|
||||||
|
/* This looks at memory. Mark it volatile to tell gcc not to move it around */
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"movl $-1,%%eax\n\t"
|
||||||
|
"xorl %%edx,%%edx\n\t"
|
||||||
|
"repe; scasl\n\t"
|
||||||
|
"je 1f\n\t"
|
||||||
|
"xorl -4(%%edi),%%eax\n\t"
|
||||||
|
"subl $4,%%edi\n\t"
|
||||||
|
"bsfl %%eax,%%edx\n"
|
||||||
|
"1:\tsubl %%ebx,%%edi\n\t"
|
||||||
|
"shll $3,%%edi\n\t"
|
||||||
|
"addl %%edi,%%edx"
|
||||||
|
:"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
|
||||||
|
:"1" ((size + 31) >> 5), "2" (addr), "b" (addr));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* find_next_zero_bit - find the first zero bit in a memory region
|
||||||
|
* @addr: The address to base the search on
|
||||||
|
* @offset: The bitnumber to start searching at
|
||||||
|
* @size: The maximum size to search
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
|
||||||
|
{
|
||||||
|
unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
|
||||||
|
int set = 0, bit = offset & 31, res;
|
||||||
|
|
||||||
|
if (bit) {
|
||||||
|
/*
|
||||||
|
* Look for zero in first byte
|
||||||
|
*/
|
||||||
|
__asm__("bsfl %1,%0\n\t"
|
||||||
|
"jne 1f\n\t"
|
||||||
|
"movl $32, %0\n"
|
||||||
|
"1:"
|
||||||
|
: "=r" (set)
|
||||||
|
: "r" (~(*p >> bit)));
|
||||||
|
if (set < (32 - bit))
|
||||||
|
return set + offset;
|
||||||
|
set = 32 - bit;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* No zero yet, search remaining full bytes for a zero
|
||||||
|
*/
|
||||||
|
res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
|
||||||
|
return (offset + set + res);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* ffz - find first zero in word.
|
||||||
|
* @word: The word to search
|
||||||
|
*
|
||||||
|
* Undefined if no zero exists, so code should check against ~0UL first.
|
||||||
|
*/
|
||||||
|
static __inline unsigned long ffz(unsigned long DWordValue )
|
||||||
|
{
|
||||||
|
unsigned long OutputData;
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
xor eax, eax
|
||||||
|
mov ebx, DWordValue
|
||||||
|
lock bsf eax, ebx
|
||||||
|
mov OutputData,eax // store in oldbit for returning (0 or 1)
|
||||||
|
}
|
||||||
|
/* __asm__("bsfl %1,%0"
|
||||||
|
:"=r" (word)
|
||||||
|
:"r" (~word));*/
|
||||||
|
return OutputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ffs - find first bit set
|
||||||
|
* @x: the word to search
|
||||||
|
*
|
||||||
|
* This is defined the same way as
|
||||||
|
* the libc and compiler builtin ffs routines, therefore
|
||||||
|
* differs in spirit from the above ffz (man ffs).
|
||||||
|
*/
|
||||||
|
static __inline__ int ffs(int x)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
__asm__("bsfl %1,%0\n\t"
|
||||||
|
"jnz 1f\n\t"
|
||||||
|
"movl $-1,%0\n"
|
||||||
|
"1:" : "=r" (r) : "rm" (x));
|
||||||
|
return r+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hweightN - returns the hamming weight of a N-bit word
|
||||||
|
* @x: the word to weigh
|
||||||
|
*
|
||||||
|
* The Hamming Weight of a number is the total number of bits set in it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define hweight32(x) generic_hweight32(x)
|
||||||
|
#define hweight16(x) generic_hweight16(x)
|
||||||
|
#define hweight8(x) generic_hweight8(x)
|
||||||
|
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
|
#define ext2_set_bit __test_and_set_bit
|
||||||
|
#define ext2_clear_bit __test_and_clear_bit
|
||||||
|
#define ext2_test_bit test_bit
|
||||||
|
#define ext2_find_first_zero_bit find_first_zero_bit
|
||||||
|
#define ext2_find_next_zero_bit find_next_zero_bit
|
||||||
|
|
||||||
|
/* Bitmap functions for the minix filesystem. */
|
||||||
|
#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr)
|
||||||
|
#define minix_set_bit(nr,addr) __set_bit(nr,addr)
|
||||||
|
#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr)
|
||||||
|
#define minix_test_bit(nr,addr) test_bit(nr,addr)
|
||||||
|
#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
|
||||||
|
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
|
#endif /* _I386_BITOPS_H */
|
|
@ -0,0 +1,132 @@
|
||||||
|
#ifndef _I386_ERRNO_H
|
||||||
|
#define _I386_ERRNO_H
|
||||||
|
|
||||||
|
#define EPERM 1 /* Operation not permitted */
|
||||||
|
#define ENOENT 2 /* No such file or directory */
|
||||||
|
#define ESRCH 3 /* No such process */
|
||||||
|
#define EINTR 4 /* Interrupted system call */
|
||||||
|
#define EIO 5 /* I/O error */
|
||||||
|
#define ENXIO 6 /* No such device or address */
|
||||||
|
#define E2BIG 7 /* Argument list too long */
|
||||||
|
#define ENOEXEC 8 /* Exec format error */
|
||||||
|
#define EBADF 9 /* Bad file number */
|
||||||
|
#define ECHILD 10 /* No child processes */
|
||||||
|
#define EAGAIN 11 /* Try again */
|
||||||
|
#define ENOMEM 12 /* Out of memory */
|
||||||
|
#define EACCES 13 /* Permission denied */
|
||||||
|
#define EFAULT 14 /* Bad address */
|
||||||
|
#define ENOTBLK 15 /* Block device required */
|
||||||
|
#define EBUSY 16 /* Device or resource busy */
|
||||||
|
#define EEXIST 17 /* File exists */
|
||||||
|
#define EXDEV 18 /* Cross-device link */
|
||||||
|
#define ENODEV 19 /* No such device */
|
||||||
|
#define ENOTDIR 20 /* Not a directory */
|
||||||
|
#define EISDIR 21 /* Is a directory */
|
||||||
|
#define EINVAL 22 /* Invalid argument */
|
||||||
|
#define ENFILE 23 /* File table overflow */
|
||||||
|
#define EMFILE 24 /* Too many open files */
|
||||||
|
#define ENOTTY 25 /* Not a typewriter */
|
||||||
|
#define ETXTBSY 26 /* Text file busy */
|
||||||
|
#define EFBIG 27 /* File too large */
|
||||||
|
#define ENOSPC 28 /* No space left on device */
|
||||||
|
#define ESPIPE 29 /* Illegal seek */
|
||||||
|
#define EROFS 30 /* Read-only file system */
|
||||||
|
#define EMLINK 31 /* Too many links */
|
||||||
|
#define EPIPE 32 /* Broken pipe */
|
||||||
|
#define EDOM 33 /* Math argument out of domain of func */
|
||||||
|
#define ERANGE 34 /* Math result not representable */
|
||||||
|
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||||
|
#define ENAMETOOLONG 36 /* File name too long */
|
||||||
|
#define ENOLCK 37 /* No record locks available */
|
||||||
|
#define ENOSYS 38 /* Function not implemented */
|
||||||
|
#define ENOTEMPTY 39 /* Directory not empty */
|
||||||
|
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||||
|
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||||
|
#define ENOMSG 42 /* No message of desired type */
|
||||||
|
#define EIDRM 43 /* Identifier removed */
|
||||||
|
#define ECHRNG 44 /* Channel number out of range */
|
||||||
|
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||||
|
#define EL3HLT 46 /* Level 3 halted */
|
||||||
|
#define EL3RST 47 /* Level 3 reset */
|
||||||
|
#define ELNRNG 48 /* Link number out of range */
|
||||||
|
#define EUNATCH 49 /* Protocol driver not attached */
|
||||||
|
#define ENOCSI 50 /* No CSI structure available */
|
||||||
|
#define EL2HLT 51 /* Level 2 halted */
|
||||||
|
#define EBADE 52 /* Invalid exchange */
|
||||||
|
#define EBADR 53 /* Invalid request descriptor */
|
||||||
|
#define EXFULL 54 /* Exchange full */
|
||||||
|
#define ENOANO 55 /* No anode */
|
||||||
|
#define EBADRQC 56 /* Invalid request code */
|
||||||
|
#define EBADSLT 57 /* Invalid slot */
|
||||||
|
|
||||||
|
#define EDEADLOCK EDEADLK
|
||||||
|
|
||||||
|
#define EBFONT 59 /* Bad font file format */
|
||||||
|
#define ENOSTR 60 /* Device not a stream */
|
||||||
|
#define ENODATA 61 /* No data available */
|
||||||
|
#define ETIME 62 /* Timer expired */
|
||||||
|
#define ENOSR 63 /* Out of streams resources */
|
||||||
|
#define ENONET 64 /* Machine is not on the network */
|
||||||
|
#define ENOPKG 65 /* Package not installed */
|
||||||
|
#define EREMOTE 66 /* Object is remote */
|
||||||
|
#define ENOLINK 67 /* Link has been severed */
|
||||||
|
#define EADV 68 /* Advertise error */
|
||||||
|
#define ESRMNT 69 /* Srmount error */
|
||||||
|
#define ECOMM 70 /* Communication error on send */
|
||||||
|
#define EPROTO 71 /* Protocol error */
|
||||||
|
#define EMULTIHOP 72 /* Multihop attempted */
|
||||||
|
#define EDOTDOT 73 /* RFS specific error */
|
||||||
|
#define EBADMSG 74 /* Not a data message */
|
||||||
|
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||||
|
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||||
|
#define EBADFD 77 /* File descriptor in bad state */
|
||||||
|
#define EREMCHG 78 /* Remote address changed */
|
||||||
|
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||||
|
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||||
|
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||||
|
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||||
|
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||||
|
#define EILSEQ 84 /* Illegal byte sequence */
|
||||||
|
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||||
|
#define ESTRPIPE 86 /* Streams pipe error */
|
||||||
|
#define EUSERS 87 /* Too many users */
|
||||||
|
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||||
|
#define EDESTADDRREQ 89 /* Destination address required */
|
||||||
|
#define EMSGSIZE 90 /* Message too long */
|
||||||
|
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||||
|
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||||
|
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||||
|
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||||
|
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||||
|
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||||
|
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||||
|
#define EADDRINUSE 98 /* Address already in use */
|
||||||
|
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||||
|
#define ENETDOWN 100 /* Network is down */
|
||||||
|
#define ENETUNREACH 101 /* Network is unreachable */
|
||||||
|
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||||
|
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||||
|
#define ECONNRESET 104 /* Connection reset by peer */
|
||||||
|
#define ENOBUFS 105 /* No buffer space available */
|
||||||
|
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||||
|
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||||
|
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||||
|
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||||
|
#define ETIMEDOUT 110 /* Connection timed out */
|
||||||
|
#define ECONNREFUSED 111 /* Connection refused */
|
||||||
|
#define EHOSTDOWN 112 /* Host is down */
|
||||||
|
#define EHOSTUNREACH 113 /* No route to host */
|
||||||
|
#define EALREADY 114 /* Operation already in progress */
|
||||||
|
#define EINPROGRESS 115 /* Operation now in progress */
|
||||||
|
#define ESTALE 116 /* Stale NFS file handle */
|
||||||
|
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||||
|
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||||
|
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||||
|
#define EISNAM 120 /* Is a named type file */
|
||||||
|
#define EREMOTEIO 121 /* Remote I/O error */
|
||||||
|
#define EDQUOT 122 /* Quota exceeded */
|
||||||
|
|
||||||
|
#define ENOMEDIUM 123 /* No medium found */
|
||||||
|
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,624 @@
|
||||||
|
#ifndef _Boot_H_
|
||||||
|
#define _Boot_H_
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
Includes used by XBox boot code
|
||||||
|
***************************************************************************/
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// configuration
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "consts.h"
|
||||||
|
// BB
|
||||||
|
#if 0
|
||||||
|
#include "jpeglib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
unsigned int cromwell_config;
|
||||||
|
unsigned int cromwell_retryload;
|
||||||
|
unsigned int cromwell_loadbank;
|
||||||
|
unsigned int cromwell_Biostype;
|
||||||
|
unsigned int xbox_ram;
|
||||||
|
|
||||||
|
|
||||||
|
#define XROMWELL 0
|
||||||
|
#define CROMWELL 1
|
||||||
|
|
||||||
|
#define ICON_WIDTH 64
|
||||||
|
#define ICON_HEIGH 64
|
||||||
|
|
||||||
|
static _inline double min (double a, double b)
|
||||||
|
{
|
||||||
|
if (a < b) return a; else return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _inline double max (double a, double b)
|
||||||
|
{
|
||||||
|
if (a > b) return a; else return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// filtror is a debugging device designed to make code available over LPC and allow a debug shell
|
||||||
|
// details are at http://warmcat.com/milksop
|
||||||
|
// if you don't have one, or are building a final ROM image, keep this at zero
|
||||||
|
|
||||||
|
#define INCLUDE_FILTROR 0
|
||||||
|
|
||||||
|
// enable logging to serial port. You probably don't have this.
|
||||||
|
|
||||||
|
#define INCLUDE_SERIAL 0
|
||||||
|
|
||||||
|
// enable trace message printing for debugging - with filtror or serial only
|
||||||
|
#define PRINT_TRACE 0
|
||||||
|
#if PRINT_TRACE
|
||||||
|
#define TRACE bprintf(__FILE__ " :%d\n\r",__LINE__);
|
||||||
|
#else
|
||||||
|
#define TRACE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INITRD_POS 0x02000000
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// some typedefs to make for easy sizing
|
||||||
|
|
||||||
|
typedef unsigned long ULONG;
|
||||||
|
typedef unsigned int DWORD;
|
||||||
|
typedef unsigned short WORD;
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
#ifndef bool_already_defined_
|
||||||
|
typedef int bool;
|
||||||
|
#endif
|
||||||
|
typedef unsigned long RGBA; // LSB=R -> MSB = A
|
||||||
|
//typedef long long __int64;
|
||||||
|
|
||||||
|
#define guint int
|
||||||
|
#define guint8 unsigned char
|
||||||
|
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL ((void *)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ASSERT(exp) { if(!(exp)) { bprintf("Assert failed file " __FILE__ " line %d\n", __LINE__); } }
|
||||||
|
|
||||||
|
// BB
|
||||||
|
#if 0
|
||||||
|
#include "BootFilesystemIso9660.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void WATCHDOG(void);
|
||||||
|
|
||||||
|
#include "BootVideo.h"
|
||||||
|
|
||||||
|
extern volatile CURRENT_VIDEO_MODE_DETAILS currentvideomodedetails;
|
||||||
|
|
||||||
|
volatile DWORD VIDEO_CURSOR_POSX;
|
||||||
|
volatile DWORD VIDEO_CURSOR_POSY;
|
||||||
|
volatile DWORD VIDEO_ATTR;
|
||||||
|
volatile DWORD VIDEO_LUMASCALING;
|
||||||
|
volatile DWORD VIDEO_RSCALING;
|
||||||
|
volatile DWORD VIDEO_BSCALING;
|
||||||
|
volatile DWORD VIDEO_VSYNC_COUNT;
|
||||||
|
volatile DWORD BIOS_TICK_COUNT;
|
||||||
|
volatile DWORD VIDEO_VSYNC_POSITION;
|
||||||
|
volatile DWORD VIDEO_VSYNC_DIR;
|
||||||
|
volatile DWORD DVD_TRAY_STATE;
|
||||||
|
|
||||||
|
#define DVD_CLOSED 0
|
||||||
|
#define DVD_CLOSING 1
|
||||||
|
#define DVD_OPEN 2
|
||||||
|
#define DVD_OPENING 3
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Superfunky i386 internal structures
|
||||||
|
|
||||||
|
typedef struct gdt_t {
|
||||||
|
unsigned short m_wSize __attribute__ ((packed));
|
||||||
|
unsigned long m_dwBase32 __attribute__ ((packed));
|
||||||
|
unsigned short m_wDummy __attribute__ ((packed));
|
||||||
|
} ts_descriptor_pointer;
|
||||||
|
|
||||||
|
typedef struct { // inside an 8-byte protected mode interrupt vector
|
||||||
|
WORD m_wHandlerHighAddressLow16;
|
||||||
|
WORD m_wSelector;
|
||||||
|
WORD m_wType;
|
||||||
|
WORD m_wHandlerLinearAddressHigh16;
|
||||||
|
} ts_pm_interrupt;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
EDT_UNKNOWN= 0,
|
||||||
|
EDT_XBOXFS
|
||||||
|
} enumDriveType;
|
||||||
|
|
||||||
|
typedef struct tsHarddiskInfo { // this is the retained knowledge about an IDE device after init
|
||||||
|
unsigned short m_fwPortBase;
|
||||||
|
unsigned short m_wCountHeads;
|
||||||
|
unsigned short m_wCountCylinders;
|
||||||
|
unsigned short m_wCountSectorsPerTrack;
|
||||||
|
unsigned long m_dwCountSectorsTotal; /* total */
|
||||||
|
unsigned char m_bLbaMode; /* am i lba (0x40) or chs (0x00) */
|
||||||
|
unsigned char m_szIdentityModelNumber[40];
|
||||||
|
unsigned char term_space_1[2];
|
||||||
|
unsigned char m_szSerial[20];
|
||||||
|
unsigned char term_space_2[2];
|
||||||
|
char m_szFirmware[8];
|
||||||
|
unsigned char term_space_3[2];
|
||||||
|
unsigned char m_fDriveExists;
|
||||||
|
unsigned char m_fAtapi; // true if a CDROM, etc
|
||||||
|
enumDriveType m_enumDriveType;
|
||||||
|
unsigned char m_bCableConductors; // valid for device 0 if present
|
||||||
|
unsigned short m_wAtaRevisionSupported;
|
||||||
|
unsigned char s_length;
|
||||||
|
unsigned char m_length;
|
||||||
|
unsigned char m_fHasMbr;
|
||||||
|
} tsHarddiskInfo;
|
||||||
|
|
||||||
|
|
||||||
|
/* a retail Xbox has 64 MB of RAM */
|
||||||
|
#define RAMSIZE (64 * 1024*1024)
|
||||||
|
/* the size of the framebuffer (defaults to 4 MB) */
|
||||||
|
#define FRAMEBUFFER_SIZE 0x00400000
|
||||||
|
/* the start of the framebuffer */
|
||||||
|
#define FRAMEBUFFER_START (0xf0000000 | (RAMSIZE - FRAMEBUFFER_SIZE))
|
||||||
|
/* the protected mode part of the kernel has to reside at 1 MB in RAM */
|
||||||
|
#define PM_KERNEL_DEST 0x100000
|
||||||
|
/* parameters for the kernel have to be here */
|
||||||
|
#define KERNEL_SETUP 0x90000
|
||||||
|
/* the GDT must not be overwritten, so we place it into an unused
|
||||||
|
area within KERNEL_SETUP */
|
||||||
|
#define GDT_LOC (KERNEL_SETUP+0x800)
|
||||||
|
/* same with the command line */
|
||||||
|
#define CMD_LINE_LOC (KERNEL_SETUP+0x1000)
|
||||||
|
|
||||||
|
/* let's reserve 4 MB at the top for the framebuffer */
|
||||||
|
#define RAMSIZE_USE (RAMSIZE - FRAMEBUFFER_SIZE)
|
||||||
|
/* the initrd resides at 1 MB from the top of RAM */
|
||||||
|
#define INITRD_DEST (RAMSIZE_USE - 1024*1024)
|
||||||
|
|
||||||
|
//#define LPCFlashadress 0xFFF00000
|
||||||
|
#define LPCFlashadress 0xFF000000
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// LED-flashing codes
|
||||||
|
// or these together as argument to I2cSetFrontpanelLed
|
||||||
|
|
||||||
|
enum {
|
||||||
|
I2C_LED_RED0 = 0x80,
|
||||||
|
I2C_LED_RED1 = 0x40,
|
||||||
|
I2C_LED_RED2 = 0x20,
|
||||||
|
I2C_LED_RED3 = 0x10,
|
||||||
|
I2C_LED_GREEN0 = 0x08,
|
||||||
|
I2C_LED_GREEN1 = 0x04,
|
||||||
|
I2C_LED_GREEN2 = 0x02,
|
||||||
|
I2C_LED_GREEN3 = 0x01
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////
|
||||||
|
/* BIOS-wide error codes all have b31 set */
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ERR_SUCCESS = 0, // completed without error
|
||||||
|
|
||||||
|
ERR_I2C_ERROR_TIMEOUT = 0x80000001, // I2C action failed because it did not complete in a reasonable time
|
||||||
|
ERR_I2C_ERROR_BUS = 0x80000002, // I2C action failed due to non retryable bus error
|
||||||
|
|
||||||
|
ERR_BOOT_PIC_ALG_BROKEN = 0x80000101 // PIC algorithm did not pass its self-test
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// some Boot API prototypes
|
||||||
|
|
||||||
|
//////// BootPerformPicChallengeResponseAction.c
|
||||||
|
|
||||||
|
/* ---------------------------- IO primitives -----------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static __inline void IoOutputByte(WORD wAds, BYTE bValue) {
|
||||||
|
// __asm__ (" out %%al,%%dx" : : "edx" (dwAds), "al" (bValue) );
|
||||||
|
__asm__ __volatile__ ("outb %b0,%w1": :"a" (bValue), "Nd" (wAds));
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline void IoOutputWord(WORD wAds, WORD wValue) {
|
||||||
|
// __asm__ (" out %%ax,%%dx " : : "edx" (dwAds), "ax" (wValue) );
|
||||||
|
__asm__ __volatile__ ("outw %0,%w1": :"a" (wValue), "Nd" (wAds));
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline void IoOutputDword(WORD wAds, DWORD dwValue) {
|
||||||
|
// __asm__ (" out %%eax,%%dx " : : "edx" (dwAds), "ax" (wValue) );
|
||||||
|
__asm__ __volatile__ ("outl %0,%w1": :"a" (dwValue), "Nd" (wAds));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static __inline BYTE IoInputByte(WORD wAds) {
|
||||||
|
unsigned char _v;
|
||||||
|
|
||||||
|
__asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (wAds));
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline WORD IoInputWord(WORD wAds) {
|
||||||
|
WORD _v;
|
||||||
|
|
||||||
|
__asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (wAds));
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline DWORD IoInputDword(WORD wAds) {
|
||||||
|
DWORD _v;
|
||||||
|
|
||||||
|
__asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (wAds));
|
||||||
|
return _v;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define rdmsr(msr,val1,val2) \
|
||||||
|
__asm__ __volatile__("rdmsr" \
|
||||||
|
: "=a" (val1), "=d" (val2) \
|
||||||
|
: "c" (msr))
|
||||||
|
|
||||||
|
#define wrmsr(msr,val1,val2) \
|
||||||
|
__asm__ __volatile__("wrmsr" \
|
||||||
|
: /* no outputs */ \
|
||||||
|
: "c" (msr), "a" (val1), "d" (val2))
|
||||||
|
|
||||||
|
|
||||||
|
void BootPciInterruptEnable(void);
|
||||||
|
|
||||||
|
// boot process
|
||||||
|
int BootPerformPicChallengeResponseAction(void);
|
||||||
|
// LED control (see associated enum above)
|
||||||
|
int I2cSetFrontpanelLed(BYTE b);
|
||||||
|
|
||||||
|
//////// filtror.c
|
||||||
|
|
||||||
|
#if INCLUDE_FILTROR
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD m_dwBlocksFromPc;
|
||||||
|
DWORD m_dwCountChecksumErrorsSeenFromPc;
|
||||||
|
DWORD m_dwBlocksToPc;
|
||||||
|
DWORD m_dwCountTimeoutErrorsSeenToPc; // this member should be incremented by the higher-level protocol when expected response does not happen
|
||||||
|
} BOOTFILTROR_CHANNEL_QUALITY_STATS;
|
||||||
|
|
||||||
|
extern BOOTFILTROR_CHANNEL_QUALITY_STATS bfcqs;
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
int BootFiltrorGetIncomingMessageLength(void);
|
||||||
|
void BootFiltrorMarkIncomingMessageAsHavingBeenRead(void) ;
|
||||||
|
bool BootFiltrorDoesPcHaveAMessageWaitingForItToRead(void);
|
||||||
|
void BootFiltrorSetMessageLengthForPcToRead(WORD wChecksum, WORD wLength) ;
|
||||||
|
int DumpAddressAndData(DWORD dwAds, const BYTE * baData, DWORD dwCountBytesUsable);
|
||||||
|
// main functions
|
||||||
|
int BootFiltrorSendArrayToPc(const BYTE * pba, WORD wLength);
|
||||||
|
int BootFiltrorGetArrayFromPc( BYTE * pba, WORD wLengthMax);
|
||||||
|
int BootFiltrorSendArrayToPcModal(const BYTE * pba, WORD wLength);
|
||||||
|
int BootFiltrorSendStringToPcModal(const char *szFormat, ...);
|
||||||
|
// alias
|
||||||
|
#define bprintf BootFiltrorSendStringToPcModal
|
||||||
|
#else
|
||||||
|
#if INCLUDE_SERIAL
|
||||||
|
#define bprintf serialprint
|
||||||
|
#else
|
||||||
|
#define bprintf(...)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INCLUDE_SERIAL
|
||||||
|
int serialprint(const char *szFormat, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SPAMI2C() __asm__ __volatile__ (\
|
||||||
|
"retry: ; "\
|
||||||
|
"movb $0x55, %al ;"\
|
||||||
|
"movl $0xc004, %edx ;"\
|
||||||
|
"shl $1, %al ;"\
|
||||||
|
"out %al, %dx ;"\
|
||||||
|
\
|
||||||
|
"movb $0xaa, %al ;"\
|
||||||
|
"add $4, %edx ;"\
|
||||||
|
"out %al, %dx ;"\
|
||||||
|
\
|
||||||
|
"movb $0xbb, %al ;"\
|
||||||
|
"sub $0x2, %edx ;"\
|
||||||
|
"out %al, %dx ;"\
|
||||||
|
\
|
||||||
|
"sub $6, %edx ;"\
|
||||||
|
"in %dx, %ax ;"\
|
||||||
|
"out %ax, %dx ;"\
|
||||||
|
"add $2, %edx ;"\
|
||||||
|
"movb $0xa, %al ;"\
|
||||||
|
"out %al, %dx ;"\
|
||||||
|
"sub $0x2, %dx ;"\
|
||||||
|
"spin: ;"\
|
||||||
|
"in %dx, %al ;"\
|
||||||
|
"test $8, %al ;"\
|
||||||
|
"jnz spin ;"\
|
||||||
|
"test $8, %al ;"\
|
||||||
|
"jnz retry ;"\
|
||||||
|
"test $0x24, %al ;"\
|
||||||
|
\
|
||||||
|
"jmp retry"\
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _LIST_ENTRY {
|
||||||
|
struct _LIST_ENTRY *m_plistentryNext;
|
||||||
|
struct _LIST_ENTRY *m_plistentryPrevious;
|
||||||
|
} LIST_ENTRY;
|
||||||
|
|
||||||
|
void ListEntryInsertAfterCurrent(LIST_ENTRY *plistentryCurrent, LIST_ENTRY *plistentryNew);
|
||||||
|
void ListEntryRemove(LIST_ENTRY *plistentryCurrent);
|
||||||
|
|
||||||
|
////////// BootPerformXCodeActions.c
|
||||||
|
|
||||||
|
int BootPerformXCodeActions(void);
|
||||||
|
|
||||||
|
#include "BootEEPROM.h"
|
||||||
|
|
||||||
|
///////// BootParser.c
|
||||||
|
#define MAX_LINE 1024
|
||||||
|
typedef struct _CONFIGENTRY {
|
||||||
|
int nValid;
|
||||||
|
char szPath[MAX_LINE];
|
||||||
|
char szKernel[MAX_LINE];
|
||||||
|
char szInitrd[MAX_LINE];
|
||||||
|
char szAppend[MAX_LINE];
|
||||||
|
int nRivaFB;
|
||||||
|
int nVesaFB;
|
||||||
|
} CONFIGENTRY, *LPCONFIGENTRY;
|
||||||
|
|
||||||
|
int ParseConfig(char *szBuffer, CONFIGENTRY *entry, EEPROMDATA *eeprom);
|
||||||
|
|
||||||
|
////////// BootStartBios.c
|
||||||
|
|
||||||
|
void StartBios(CONFIGENTRY *config,int nActivePartition, int nFATXPresent,int bootfrom);
|
||||||
|
int BootMenue(CONFIGENTRY *config,int nDrive,int nActivePartition, int nFATXPresent);
|
||||||
|
|
||||||
|
////////// BootResetActions.c
|
||||||
|
void ClearIDT (void);
|
||||||
|
void BootResetAction(void);
|
||||||
|
void BootCpuCache(bool fEnable) ;
|
||||||
|
int printk(const char *szFormat, ...);
|
||||||
|
void BiosCmosWrite(BYTE bAds, BYTE bData);
|
||||||
|
BYTE BiosCmosRead(BYTE bAds);
|
||||||
|
|
||||||
|
|
||||||
|
///////// BootPciPeripheralInitialization.c
|
||||||
|
void BootPciPeripheralInitialization(void);
|
||||||
|
extern void ReadPCIByte(unsigned int bus, unsigned int dev, unsigned intfunc, unsigned int reg_off, unsigned char *pbyteval);
|
||||||
|
extern void WritePCIByte(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off, unsigned char byteval);
|
||||||
|
extern void ReadPCIDword(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off, unsigned int *pdwordval);
|
||||||
|
extern void WritePCIDword(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off, unsigned int dwordval);
|
||||||
|
extern void ReadPCIBlock(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off, unsigned char *buf, unsigned int nbytes);
|
||||||
|
extern void WritePCIBlock(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off, unsigned char *buf, unsigned int nbytes);
|
||||||
|
|
||||||
|
void PciWriteByte (unsigned int bus, unsigned int dev, unsigned int func,
|
||||||
|
unsigned int reg_off, unsigned char byteval);
|
||||||
|
BYTE PciReadByte(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off);
|
||||||
|
DWORD PciWriteDword(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off, DWORD dw);
|
||||||
|
DWORD PciReadDword(unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg_off);
|
||||||
|
|
||||||
|
///////// BootPerformPicChallengeResponseAction.c
|
||||||
|
|
||||||
|
int I2CTransmitWord(BYTE bPicAddressI2cFormat, WORD wDataToWrite);
|
||||||
|
int I2CTransmitByteGetReturn(BYTE bPicAddressI2cFormat, BYTE bDataToWrite);
|
||||||
|
bool I2CGetTemperature(int *, int *);
|
||||||
|
void I2CModifyBits(BYTE bAds, BYTE bReg, BYTE bData, BYTE bMask);
|
||||||
|
|
||||||
|
///////// BootIde.c
|
||||||
|
|
||||||
|
extern tsHarddiskInfo tsaHarddiskInfo[]; // static struct stores data about attached drives
|
||||||
|
int BootIdeInit(void);
|
||||||
|
int BootIdeReadSector(int nDriveIndex, void * pbBuffer, unsigned int block, int byte_offset, int n_bytes);
|
||||||
|
int BootIdeBootSectorHddOrElTorito(int nDriveIndex, BYTE * pbaResult);
|
||||||
|
int BootIdeAtapiAdditionalSenseCode(int nDrive, BYTE * pba, int nLengthMaxReturn);
|
||||||
|
BYTE BootIdeGetTrayState(void);
|
||||||
|
int BootIdeSetTransferMode(int nIndexDrive, int nMode);
|
||||||
|
int BootIdeWaitNotBusy(unsigned uIoBase);
|
||||||
|
bool BootIdeAtapiReportFriendlyError(int nDriveIndex, char * szErrorReturn, int nMaxLengthError);
|
||||||
|
void BootIdeAtapiPrintkFriendlyError(int nDriveIndex);
|
||||||
|
|
||||||
|
///////// BootUSB.c
|
||||||
|
|
||||||
|
void BootStopUSB(void);
|
||||||
|
void BootStartUSB(void);
|
||||||
|
void USBGetEvents(void);
|
||||||
|
|
||||||
|
#include "xpad.h"
|
||||||
|
|
||||||
|
extern struct xpad_data XPAD_current[4];
|
||||||
|
extern struct xpad_data XPAD_last[4];
|
||||||
|
|
||||||
|
///////// BootEthernet.c
|
||||||
|
|
||||||
|
int BootStartUpEthernet(void);
|
||||||
|
|
||||||
|
///////// BootAudio.c
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
WORD m_wTimeStartmS;
|
||||||
|
WORD m_wTimeDurationmS;
|
||||||
|
DWORD m_dwFrequency;
|
||||||
|
} SONG_NOTE;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AET_SINE=0,
|
||||||
|
AET_NOISE
|
||||||
|
} AUDIO_ELEMENT_TYPES;
|
||||||
|
|
||||||
|
typedef void (*CALLBACK_AFTER_BLOCK)(void * pvoidAc97Device, void * pvoidaudioelement);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _AUDIO_ELEMENT { // represents a kind of generated sound, needs a derived object to be usable
|
||||||
|
struct _AUDIO_ELEMENT * m_paudioelementNext;
|
||||||
|
short m_sPanZeroIsAllLeft7FFFIsAllRight;
|
||||||
|
AUDIO_ELEMENT_TYPES m_aetType;
|
||||||
|
DWORD m_dwVolumeElementMaster7fff0000Max;
|
||||||
|
DWORD m_dwVolumeAttackRate;
|
||||||
|
DWORD m_dwVolumeAttackLimit;
|
||||||
|
DWORD m_dwVolumeSustainRate;
|
||||||
|
DWORD m_dwVolumeSustainLimit;
|
||||||
|
DWORD m_dwVolumeDecayRate;
|
||||||
|
BYTE m_bStageZeroIsAttack;
|
||||||
|
void * m_pvPayload;
|
||||||
|
DWORD m_dwPayload2;
|
||||||
|
CALLBACK_AFTER_BLOCK m_callbackEveryBufferFill;
|
||||||
|
DWORD m_dwCount48kHzSamplesRendered;
|
||||||
|
} AUDIO_ELEMENT;
|
||||||
|
|
||||||
|
typedef struct _AUDIO_ELEMENT_SINE { // derived object composed from base object AUDIO_ELEMENT represents a sine wave with harmonics
|
||||||
|
AUDIO_ELEMENT m_paudioelement;
|
||||||
|
DWORD m_dwComputedFundamentalPhaseIncrementFor48kHzSamples;
|
||||||
|
short m_saVolumePerHarmonicZeroIsNone7FFFIsFull[5]; // first entry is fundamental, then 2nd harmonic, etc
|
||||||
|
DWORD m_dwPhaseAccumilator[5];
|
||||||
|
} AUDIO_ELEMENT_SINE;
|
||||||
|
|
||||||
|
typedef struct _AUDIO_ELEMENT_NOISE { // derived object composed from base object AUDIO_ELEMENT represents a whitish noise source
|
||||||
|
AUDIO_ELEMENT m_paudioelement;
|
||||||
|
short m_sVolumeZeroIsNone7FFFIsFull;
|
||||||
|
union {
|
||||||
|
DWORD m_dwShifter;
|
||||||
|
short m_saSamples[2];
|
||||||
|
} shifter;
|
||||||
|
short m_sLastSample;
|
||||||
|
} AUDIO_ELEMENT_NOISE;
|
||||||
|
|
||||||
|
typedef struct { // descriptor from AC97 specification
|
||||||
|
DWORD m_dwBufferStartAddress;
|
||||||
|
WORD m_wBufferLengthInSamples; // 0=no smaples
|
||||||
|
WORD m_wBufferControl; // b15=1=issue IRQ on completion, b14=1=last in stream
|
||||||
|
} AC97_DESCRIPTOR __attribute__ ((aligned (8)));
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
AC97_DESCRIPTOR m_aac97descriptorPcmSpdif[32];
|
||||||
|
AC97_DESCRIPTOR m_aac97descriptorPcmOut[32];
|
||||||
|
volatile DWORD * m_pdwMMIO;
|
||||||
|
volatile DWORD m_dwCount48kHzSamplesRendered;
|
||||||
|
volatile DWORD m_dwNextDescriptorMod31;
|
||||||
|
AUDIO_ELEMENT * m_paudioelementFirst;
|
||||||
|
} AC97_DEVICE __attribute__ ((aligned (8))) ;
|
||||||
|
|
||||||
|
void wait_ms(DWORD ticks);
|
||||||
|
void wait_smalldelay(void);
|
||||||
|
void BootAudioInit(volatile AC97_DEVICE * pac97device);
|
||||||
|
void BootAudioInterrupt(volatile AC97_DEVICE * pac97device);
|
||||||
|
void BootAudioSilence(volatile AC97_DEVICE * pac97device);
|
||||||
|
void BootAudioOutBufferToDescriptor(volatile AC97_DEVICE * pac97device, DWORD * pdwBuffer, WORD wLengthInSamples, bool fFinal);
|
||||||
|
short BootAudioInterpolatedSine(DWORD dwPhase4GIs2PiRadians);
|
||||||
|
void BootAudioPlayDescriptors(volatile AC97_DEVICE * pac97device);
|
||||||
|
void BootAudioAttachAudioElement(volatile AC97_DEVICE * pac97device, AUDIO_ELEMENT * paudioelement);
|
||||||
|
void BootAudioDetachAudioElement(volatile AC97_DEVICE * pac97device, AUDIO_ELEMENT * paudioelement);
|
||||||
|
void ConstructAUDIO_ELEMENT_SINE(volatile AUDIO_ELEMENT_SINE *, int nFrequencyFundamental);
|
||||||
|
void DestructAUDIO_ELEMENT_SINE(volatile AC97_DEVICE * pac97device, AUDIO_ELEMENT_SINE * paes);
|
||||||
|
void ConstructAUDIO_ELEMENT_NOISE(volatile AUDIO_ELEMENT_NOISE *);
|
||||||
|
void DestructAUDIO_ELEMENT_NOISE(volatile AC97_DEVICE * pac97device, AUDIO_ELEMENT_NOISE * paen);
|
||||||
|
WORD BootAudioGetMixerSetting(volatile AC97_DEVICE * pac97device, int nSettingIndex);
|
||||||
|
void BootAudioSetMixerSetting(volatile AC97_DEVICE * pac97device, int nSettingIndex, WORD wValue);
|
||||||
|
|
||||||
|
|
||||||
|
// video helpers
|
||||||
|
|
||||||
|
void BootVideoBlit(
|
||||||
|
DWORD * pdwTopLeftDestination,
|
||||||
|
DWORD dwCountBytesPerLineDestination,
|
||||||
|
DWORD * pdwTopLeftSource,
|
||||||
|
DWORD dwCountBytesPerLineSource,
|
||||||
|
DWORD dwCountLines
|
||||||
|
);
|
||||||
|
|
||||||
|
void BootVideoVignette(
|
||||||
|
DWORD * pdwaTopLeftDestination,
|
||||||
|
DWORD m_dwCountBytesPerLineDestination,
|
||||||
|
DWORD m_dwCountLines,
|
||||||
|
RGBA rgbaColour1,
|
||||||
|
RGBA rgbaColour2,
|
||||||
|
DWORD dwStartLine,
|
||||||
|
DWORD dwEndLine
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BYTE * m_pBitmapData;
|
||||||
|
int m_nWidth;
|
||||||
|
int m_nHeight;
|
||||||
|
int m_nBytesPerPixel;
|
||||||
|
} JPEG;
|
||||||
|
|
||||||
|
int BootVideoOverlayString(DWORD * pdwaTopLeftDestination, DWORD m_dwCountBytesPerLineDestination, RGBA rgbaOpaqueness, const char * szString);
|
||||||
|
void BootVideoChunkedPrint(char * szBuffer, WORD wLength);
|
||||||
|
int VideoDumpAddressAndData(DWORD dwAds, const BYTE * baData, DWORD dwCountBytesUsable);
|
||||||
|
unsigned int BootVideoGetStringTotalWidth(const char * szc);
|
||||||
|
void BootVideoClearScreen(JPEG * pJpeg, int nStartLine, int nEndLine);
|
||||||
|
void BootVideoJpegBlitBlend(
|
||||||
|
DWORD * pdwTopLeftDestination,
|
||||||
|
DWORD dwCountBytesPerLineDestination,
|
||||||
|
JPEG * pJpeg,
|
||||||
|
DWORD * pdwTopLeftInJpegBitmap,
|
||||||
|
RGBA m_rgbaTransparent,
|
||||||
|
DWORD * pdwTopLeftBackground,
|
||||||
|
DWORD dwCountBytesPerLineBackground,
|
||||||
|
DWORD dwCountBytesPerPixelBackground,
|
||||||
|
int x,
|
||||||
|
int y
|
||||||
|
);
|
||||||
|
|
||||||
|
bool BootVideoJpegUnpackAsRgb(
|
||||||
|
BYTE *pbaJpegFileImage,
|
||||||
|
int nFileLength,
|
||||||
|
JPEG * pJpeg
|
||||||
|
);
|
||||||
|
|
||||||
|
void BootVideoEnableOutput(BYTE bAvPack);
|
||||||
|
BYTE * BootVideoGetPointerToEffectiveJpegTopLeft(JPEG * pJpeg);
|
||||||
|
|
||||||
|
void * memcpy(void *dest, const void *src, size_t size);
|
||||||
|
void * memset(void *dest, int data, size_t size);
|
||||||
|
int _memcmp(const BYTE *pb, const BYTE *pb1, int n);
|
||||||
|
int _strncmp(const char *sz1, const char *sz2, int nMax);
|
||||||
|
char * strcpy(char *sz, const char *szc);
|
||||||
|
char * _strncpy(char *sz, const char *szc, int nLenMax);
|
||||||
|
|
||||||
|
void MemoryManagementInitialization(void * pvStartAddress, DWORD dwTotalMemoryAllocLength);
|
||||||
|
void * malloc(size_t size);
|
||||||
|
void free(void *);
|
||||||
|
|
||||||
|
void Sleep(int nMicroseconds);
|
||||||
|
|
||||||
|
extern volatile int nCountI2cinterrupts, nCountUnusedInterrupts, nCountUnusedInterruptsPic2, nCountInterruptsSmc, nCountInterruptsIde;
|
||||||
|
extern volatile bool fSeenPowerdown;
|
||||||
|
extern BYTE baBackdrop[60*72*4];
|
||||||
|
extern JPEG jpegBackdrop;
|
||||||
|
typedef enum {
|
||||||
|
ETS_OPEN_OR_OPENING=0,
|
||||||
|
ETS_CLOSING,
|
||||||
|
ETS_CLOSED
|
||||||
|
} TRAY_STATE;
|
||||||
|
extern volatile TRAY_STATE traystate;
|
||||||
|
|
||||||
|
|
||||||
|
extern void BootInterruptsWriteIdt(void);
|
||||||
|
|
||||||
|
int copy_swap_trim(unsigned char *dst, unsigned char *src, int len);
|
||||||
|
void HMAC_SHA1( unsigned char *result,
|
||||||
|
unsigned char *key, int key_length,
|
||||||
|
unsigned char *text1, int text1_length,
|
||||||
|
unsigned char *text2, int text2_length );
|
||||||
|
|
||||||
|
char *HelpGetToken(char *ptr,char token);
|
||||||
|
void HelpGetParm(char *szBuffer, char *szOrig);
|
||||||
|
char *strrchr0(char *string, char ch);
|
||||||
|
|
||||||
|
#endif // _Boot_H_
|
|
@ -0,0 +1,46 @@
|
||||||
|
////////////////////// compile-time options ////////////////////////////////
|
||||||
|
|
||||||
|
// selects between the supported video modes, see boot.h for enum listing those available
|
||||||
|
#define VIDEO_PREFERRED_MODE VIDEO_MODE_800x600
|
||||||
|
|
||||||
|
#define FLASH
|
||||||
|
|
||||||
|
//
|
||||||
|
// uncomment to force CD boot mode even if MBR present
|
||||||
|
// default is to boot from HDD if MBR present, else CD
|
||||||
|
//#define FORCE_CD_BOOT
|
||||||
|
//#define IS_XBE_CDLOADER
|
||||||
|
#define MENU
|
||||||
|
|
||||||
|
// uncomment to default to FATX boot if you
|
||||||
|
// run xromwell as bootloader for FATX
|
||||||
|
|
||||||
|
//#define DEFAULT_FATX
|
||||||
|
|
||||||
|
// Usefull combinations
|
||||||
|
//
|
||||||
|
// Booting from CD
|
||||||
|
//
|
||||||
|
// #define FORCE_CD_BOOT
|
||||||
|
// #define IS_XBE_CDLOADER
|
||||||
|
// #undef MENU
|
||||||
|
//
|
||||||
|
// Use xromwell as a normal bootselector from
|
||||||
|
// HDD
|
||||||
|
//
|
||||||
|
// #undef FORCE_CD_BOOT
|
||||||
|
// #undef IS_XBE_CDLOADER
|
||||||
|
// #define MENU
|
||||||
|
|
||||||
|
// display a line like Composite 480 detected if uncommented
|
||||||
|
#undef REPORT_VIDEO_MODE
|
||||||
|
|
||||||
|
// show the MBR table if the MBR is valid
|
||||||
|
#undef DISPLAY_MBR_INFO
|
||||||
|
|
||||||
|
// uncomment to do Ethernet init
|
||||||
|
//#define DO_ETHERNET 1
|
||||||
|
|
||||||
|
|
||||||
|
#undef DEBUG_MODE
|
||||||
|
#undef XPAD_VIBRA_STARTUP
|
|
@ -0,0 +1,86 @@
|
||||||
|
#ifndef _Consts_H_
|
||||||
|
#define _Consts_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* includes for startup code in a form usable by the .S files
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#define VERSION "BASE:2.20"
|
||||||
|
|
||||||
|
#define PCI_CFG_ADDR 0x0CF8
|
||||||
|
#define PCI_CFG_DATA 0x0CFC
|
||||||
|
|
||||||
|
|
||||||
|
#define I2C_IO_BASE 0xc000
|
||||||
|
|
||||||
|
#define BUS_0 0
|
||||||
|
#define BUS_1 1
|
||||||
|
|
||||||
|
#define DEV_0 0
|
||||||
|
#define DEV_1 1
|
||||||
|
#define DEV_2 2
|
||||||
|
#define DEV_3 3
|
||||||
|
#define DEV_4 4
|
||||||
|
#define DEV_5 5
|
||||||
|
#define DEV_6 6
|
||||||
|
#define DEV_7 7
|
||||||
|
#define DEV_8 8
|
||||||
|
#define DEV_9 9
|
||||||
|
#define DEV_a 0xa
|
||||||
|
#define DEV_b 0xb
|
||||||
|
#define DEV_c 0xc
|
||||||
|
#define DEV_d 0xd
|
||||||
|
#define DEV_e 0xe
|
||||||
|
#define DEV_f 0xf
|
||||||
|
#define DEV_10 0x10
|
||||||
|
#define DEV_11 0x11
|
||||||
|
#define DEV_12 0x12
|
||||||
|
#define DEV_13 0x13
|
||||||
|
#define DEV_14 0x14
|
||||||
|
#define DEV_15 0x15
|
||||||
|
#define DEV_16 0x16
|
||||||
|
#define DEV_17 0x17
|
||||||
|
#define DEV_18 0x18
|
||||||
|
#define DEV_19 0x19
|
||||||
|
#define DEV_1a 0x1a
|
||||||
|
#define DEV_1b 0x1b
|
||||||
|
#define DEV_1c 0x1c
|
||||||
|
#define DEV_1d 0x1d
|
||||||
|
#define DEV_1e 0x1e
|
||||||
|
#define DEV_1f 0x1f
|
||||||
|
|
||||||
|
#define FUNC_0 0
|
||||||
|
/*
|
||||||
|
#define boot_post_macro(value) \
|
||||||
|
movb $(value), %al ;\
|
||||||
|
outb %al, $0x80
|
||||||
|
*/
|
||||||
|
/* Filtror debug stuff 4K block used for communications */
|
||||||
|
#define FILT_DEBUG_BASE 0xff0fe000
|
||||||
|
#define FILT_DEBUG_FOOTPRINT 0x1000
|
||||||
|
#define FILT_DEBUG_MAX_DATA ((FILT_DEBUG_FOOTPRINT/2)-4)
|
||||||
|
#define FILT_DEBUG_TOPC_START (FILT_DEBUG_BASE+0)
|
||||||
|
#define FILT_DEBUG_FROMPC_START (FILT_DEBUG_BASE+(FILT_DEBUG_FOOTPRINT/2))
|
||||||
|
#define FILT_DEBUG_TOPC_LEN (FILT_DEBUG_BASE+(FILT_DEBUG_FOOTPRINT/2)-2)
|
||||||
|
#define FILT_DEBUG_FROMPC_LEN (FILT_DEBUG_BASE+FILT_DEBUG_FOOTPRINT-2)
|
||||||
|
#define FILT_DEBUG_TOPC_CHECKSUM (FILT_DEBUG_BASE+(FILT_DEBUG_FOOTPRINT/2)-4)
|
||||||
|
#define FILT_DEBUG_FROMPC_CHECKSUM (FILT_DEBUG_BASE+FILT_DEBUG_FOOTPRINT-4)
|
||||||
|
|
||||||
|
#define MEMORYMANAGERSTART 0x01000000
|
||||||
|
#define MEMORYMANAGERSIZE 0x1000000 // 16 MB
|
||||||
|
#define MEMORYMANAGEREND 0x01FFFFFF
|
||||||
|
|
||||||
|
#endif // _Consts_H_
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,430 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001-2002 by David Brownell
|
||||||
|
*
|
||||||
|
* 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; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
|
/* This file contains declarations of usbcore internals that are mostly
|
||||||
|
* used or exposed by Host Controller Drivers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB Packet IDs (PIDs)
|
||||||
|
*/
|
||||||
|
#define USB_PID_UNDEF_0 0xf0
|
||||||
|
#define USB_PID_OUT 0xe1
|
||||||
|
#define USB_PID_ACK 0xd2
|
||||||
|
#define USB_PID_DATA0 0xc3
|
||||||
|
#define USB_PID_PING 0xb4 /* USB 2.0 */
|
||||||
|
#define USB_PID_SOF 0xa5
|
||||||
|
#define USB_PID_NYET 0x96 /* USB 2.0 */
|
||||||
|
#define USB_PID_DATA2 0x87 /* USB 2.0 */
|
||||||
|
#define USB_PID_SPLIT 0x78 /* USB 2.0 */
|
||||||
|
#define USB_PID_IN 0x69
|
||||||
|
#define USB_PID_NAK 0x5a
|
||||||
|
#define USB_PID_DATA1 0x4b
|
||||||
|
#define USB_PID_PREAMBLE 0x3c /* Token mode */
|
||||||
|
#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */
|
||||||
|
#define USB_PID_SETUP 0x2d
|
||||||
|
#define USB_PID_STALL 0x1e
|
||||||
|
#define USB_PID_MDATA 0x0f /* USB 2.0 */
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB Host Controller Driver (usb_hcd) framework
|
||||||
|
*
|
||||||
|
* Since "struct usb_bus" is so thin, you can't share much code in it.
|
||||||
|
* This framework is a layer over that, and should be more sharable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
struct usb_hcd { /* usb_bus.hcpriv points to this */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* housekeeping
|
||||||
|
*/
|
||||||
|
struct usb_bus self; /* hcd is-a bus */
|
||||||
|
|
||||||
|
const char *product_desc; /* product/vendor string */
|
||||||
|
const char *description; /* "ehci-hcd" etc */
|
||||||
|
|
||||||
|
struct timer_list rh_timer; /* drives root hub */
|
||||||
|
struct list_head dev_list; /* devices on this bus */
|
||||||
|
struct work_struct work;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* hardware info/state
|
||||||
|
*/
|
||||||
|
struct hc_driver *driver; /* hw-specific hooks */
|
||||||
|
int irq; /* irq allocated */
|
||||||
|
void *regs; /* device memory/io */
|
||||||
|
struct device *controller; /* handle to hardware */
|
||||||
|
|
||||||
|
/* a few non-PCI controllers exist, mostly for OHCI */
|
||||||
|
struct pci_dev *pdev; /* pci is typical */
|
||||||
|
#ifdef CONFIG_PCI
|
||||||
|
int region; /* pci region for regs */
|
||||||
|
u32 pci_state [16]; /* for PM state save */
|
||||||
|
atomic_t resume_count; /* multiple resumes issue */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HCD_BUFFER_POOLS 4
|
||||||
|
struct pci_pool *pool [HCD_BUFFER_POOLS];
|
||||||
|
|
||||||
|
int state;
|
||||||
|
# define __ACTIVE 0x01
|
||||||
|
# define __SLEEPY 0x02
|
||||||
|
# define __SUSPEND 0x04
|
||||||
|
# define __TRANSIENT 0x80
|
||||||
|
|
||||||
|
# define USB_STATE_HALT 0
|
||||||
|
# define USB_STATE_RUNNING (__ACTIVE)
|
||||||
|
# define USB_STATE_READY (__ACTIVE|__SLEEPY)
|
||||||
|
# define USB_STATE_QUIESCING (__SUSPEND|__TRANSIENT|__ACTIVE)
|
||||||
|
# define USB_STATE_RESUMING (__SUSPEND|__TRANSIENT)
|
||||||
|
# define USB_STATE_SUSPENDED (__SUSPEND)
|
||||||
|
|
||||||
|
#define HCD_IS_RUNNING(state) ((state) & __ACTIVE)
|
||||||
|
#define HCD_IS_SUSPENDED(state) ((state) & __SUSPEND)
|
||||||
|
|
||||||
|
/* more shared queuing code would be good; it should support
|
||||||
|
* smarter scheduling, handle transaction translators, etc;
|
||||||
|
* input size of periodic table to an interrupt scheduler.
|
||||||
|
* (ohci 32, uhci 1024, ehci 256/512/1024).
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 2.4 does this a bit differently ... */
|
||||||
|
static _inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd)
|
||||||
|
{
|
||||||
|
return &hcd->self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct hcd_dev { /* usb_device.hcpriv points to this */
|
||||||
|
struct list_head dev_list; /* on this hcd */
|
||||||
|
struct list_head urb_list; /* pending on this dev */
|
||||||
|
|
||||||
|
/* per-configuration HC/HCD state, such as QH or ED */
|
||||||
|
void *ep[32];
|
||||||
|
};
|
||||||
|
|
||||||
|
// urb.hcpriv is really hardware-specific
|
||||||
|
|
||||||
|
struct hcd_timeout { /* timeouts we allocate */
|
||||||
|
struct list_head timeout_list;
|
||||||
|
struct timer_list timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME usb_operations should vanish or become hc_driver,
|
||||||
|
* when usb_bus and usb_hcd become the same thing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct usb_operations {
|
||||||
|
int (*allocate)(struct usb_device *);
|
||||||
|
int (*deallocate)(struct usb_device *);
|
||||||
|
int (*get_frame_number) (struct usb_device *usb_dev);
|
||||||
|
int (*submit_urb) (struct urb *urb, int mem_flags);
|
||||||
|
int (*unlink_urb) (struct urb *urb);
|
||||||
|
|
||||||
|
/* allocate dma-consistent buffer for URB_DMA_NOMAPPING */
|
||||||
|
void *(*buffer_alloc)(struct usb_bus *bus, size_t size,
|
||||||
|
int mem_flags,
|
||||||
|
dma_addr_t *dma);
|
||||||
|
void (*buffer_free)(struct usb_bus *bus, size_t size,
|
||||||
|
void *addr, dma_addr_t dma);
|
||||||
|
|
||||||
|
void (*disable)(struct usb_device *udev, int bEndpointAddress);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* each driver provides one of these, and hardware init support */
|
||||||
|
|
||||||
|
struct pt_regs;
|
||||||
|
|
||||||
|
struct hc_driver {
|
||||||
|
const char *description; /* "ehci-hcd" etc */
|
||||||
|
|
||||||
|
/* irq handler */
|
||||||
|
void (*irq) (struct usb_hcd *hcd, struct pt_regs *regs);
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
|
||||||
|
#define HCD_USB11 0x0010 /* USB 1.1 */
|
||||||
|
#define HCD_USB2 0x0020 /* USB 2.0 */
|
||||||
|
|
||||||
|
/* called to init HCD and root hub */
|
||||||
|
int (*start) (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
/* called after all devices were suspended */
|
||||||
|
int (*suspend) (struct usb_hcd *hcd, u32 state);
|
||||||
|
|
||||||
|
/* called before any devices get resumed */
|
||||||
|
int (*resume) (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
/* cleanly make HCD stop writing memory and doing I/O */
|
||||||
|
void (*stop) (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
/* return current frame number */
|
||||||
|
int (*get_frame_number) (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
/* memory lifecycle */
|
||||||
|
struct usb_hcd *(*hcd_alloc) (void);
|
||||||
|
void (*hcd_free) (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
/* manage i/o requests, device state */
|
||||||
|
int (*urb_enqueue) (struct usb_hcd *hcd, struct urb *urb,
|
||||||
|
int mem_flags);
|
||||||
|
int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb);
|
||||||
|
|
||||||
|
/* hw synch, freeing endpoint resources that urb_dequeue can't */
|
||||||
|
void (*endpoint_disable)(struct usb_hcd *hcd,
|
||||||
|
struct hcd_dev *dev, int bEndpointAddress);
|
||||||
|
|
||||||
|
/* root hub support */
|
||||||
|
int (*hub_status_data) (struct usb_hcd *hcd, char *buf);
|
||||||
|
int (*hub_control) (struct usb_hcd *hcd,
|
||||||
|
u16 typeReq, u16 wValue, u16 wIndex,
|
||||||
|
char *buf, u16 wLength);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs);
|
||||||
|
extern void usb_bus_init (struct usb_bus *bus);
|
||||||
|
extern void usb_rh_status_dequeue (struct usb_hcd *hcd, struct urb *urb);
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCI
|
||||||
|
struct pci_dev;
|
||||||
|
struct pci_device_id;
|
||||||
|
extern int usb_hcd_pci_probe (struct pci_dev *dev,
|
||||||
|
const struct pci_device_id *id);
|
||||||
|
extern void usb_hcd_pci_remove (struct pci_dev *dev);
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
// FIXME: see Documentation/power/pci.txt (2.4.6 and later?)
|
||||||
|
// extern int usb_hcd_pci_save_state (struct pci_dev *dev, u32 state);
|
||||||
|
extern int usb_hcd_pci_suspend (struct pci_dev *dev, u32 state);
|
||||||
|
extern int usb_hcd_pci_resume (struct pci_dev *dev);
|
||||||
|
// extern int usb_hcd_pci_enable_wake (struct pci_dev *dev, u32 state, int flg);
|
||||||
|
#endif /* CONFIG_PM */
|
||||||
|
|
||||||
|
#endif /* CONFIG_PCI */
|
||||||
|
|
||||||
|
/* pci-ish (pdev null is ok) buffer alloc/mapping support */
|
||||||
|
int hcd_buffer_create (struct usb_hcd *hcd);
|
||||||
|
void hcd_buffer_destroy (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
void *hcd_buffer_alloc (struct usb_bus *bus, size_t size,
|
||||||
|
int mem_flags, dma_addr_t *dma);
|
||||||
|
void hcd_buffer_free (struct usb_bus *bus, size_t size,
|
||||||
|
void *addr, dma_addr_t dma);
|
||||||
|
|
||||||
|
/* generic bus glue, needed for host controllers that don't use PCI */
|
||||||
|
extern struct usb_operations usb_hcd_operations;
|
||||||
|
extern irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r);
|
||||||
|
extern void usb_hc_died (struct usb_hcd *hcd);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Enumeration is only for the hub driver, or HCD virtual root hubs */
|
||||||
|
extern int usb_new_device(struct usb_device *dev, struct device *parent);
|
||||||
|
extern void usb_connect(struct usb_device *dev);
|
||||||
|
extern void usb_disconnect(struct usb_device **);
|
||||||
|
|
||||||
|
/* exported to hub driver ONLY to support usb_reset_device () */
|
||||||
|
extern int usb_get_configuration(struct usb_device *dev);
|
||||||
|
extern void usb_set_maxpacket(struct usb_device *dev);
|
||||||
|
extern void usb_destroy_configuration(struct usb_device *dev);
|
||||||
|
extern int usb_set_address(struct usb_device *dev);
|
||||||
|
|
||||||
|
/* use these only before the device's address has been set */
|
||||||
|
#define usb_snddefctrl(dev) ((PIPE_CONTROL << 30))
|
||||||
|
#define usb_rcvdefctrl(dev) ((PIPE_CONTROL << 30) | USB_DIR_IN)
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HCD Root Hub support
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hub.h"
|
||||||
|
|
||||||
|
/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
|
||||||
|
#define DeviceRequest \
|
||||||
|
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
|
||||||
|
#define DeviceOutRequest \
|
||||||
|
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
|
||||||
|
|
||||||
|
#define InterfaceRequest \
|
||||||
|
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||||
|
|
||||||
|
#define EndpointRequest \
|
||||||
|
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||||
|
#define EndpointOutRequest \
|
||||||
|
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||||
|
|
||||||
|
/* table 9.6 standard features */
|
||||||
|
#define DEVICE_REMOTE_WAKEUP 1
|
||||||
|
#define ENDPOINT_HALT 0
|
||||||
|
|
||||||
|
/* class requests from the USB 2.0 hub spec, table 11-15 */
|
||||||
|
/* GetBusState and SetHubDescriptor are optional, omitted */
|
||||||
|
#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
|
||||||
|
#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
|
||||||
|
#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)
|
||||||
|
#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS)
|
||||||
|
#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS)
|
||||||
|
#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE)
|
||||||
|
#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic bandwidth allocation constants/support
|
||||||
|
*/
|
||||||
|
#define FRAME_TIME_USECS 1000L
|
||||||
|
#define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */
|
||||||
|
/* Trying not to use worst-case bit-stuffing
|
||||||
|
of (7/6 * 8 * bytecount) = 9.33 * bytecount */
|
||||||
|
/* bytecount = data payload byte count */
|
||||||
|
|
||||||
|
#define NS_TO_US(ns) ((ns + 500L) / 1000L)
|
||||||
|
/* convert & round nanoseconds to microseconds */
|
||||||
|
|
||||||
|
extern void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb,
|
||||||
|
int bustime, int isoc);
|
||||||
|
extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb,
|
||||||
|
int isoc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Full/low speed bandwidth allocation constants/support.
|
||||||
|
*/
|
||||||
|
#define BW_HOST_DELAY 1000L /* nanoseconds */
|
||||||
|
#define BW_HUB_LS_SETUP 333L /* nanoseconds */
|
||||||
|
/* 4 full-speed bit times (est.) */
|
||||||
|
|
||||||
|
#define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */
|
||||||
|
#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L)
|
||||||
|
#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L)
|
||||||
|
|
||||||
|
extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ceiling microseconds (typical) for that many bytes at high speed
|
||||||
|
* ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed
|
||||||
|
* to preallocate bandwidth)
|
||||||
|
*/
|
||||||
|
#define USB2_HOST_DELAY 5 /* nsec, guess */
|
||||||
|
#define HS_USECS(bytes) NS_TO_US ( ((55 * 8 * 2083)/1000) \
|
||||||
|
+ ((2083UL * (3167 + BitTime (bytes)))/1000) \
|
||||||
|
+ USB2_HOST_DELAY)
|
||||||
|
#define HS_USECS_ISO(bytes) NS_TO_US ( ((long)(38 * 8 * 2.083)) \
|
||||||
|
+ ((2083UL * (3167 + BitTime (bytes)))/1000) \
|
||||||
|
+ USB2_HOST_DELAY)
|
||||||
|
|
||||||
|
extern long usb_calc_bus_time (int speed, int is_input,
|
||||||
|
int isoc, int bytecount);
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
extern struct usb_bus *usb_alloc_bus (struct usb_operations *);
|
||||||
|
extern void usb_free_bus (struct usb_bus *);
|
||||||
|
|
||||||
|
extern void usb_register_bus (struct usb_bus *);
|
||||||
|
extern void usb_deregister_bus (struct usb_bus *);
|
||||||
|
|
||||||
|
extern int usb_register_root_hub (struct usb_device *usb_dev,
|
||||||
|
struct device *parent_dev);
|
||||||
|
|
||||||
|
/* for portability to 2.4, hcds should call this */
|
||||||
|
static _inline int hcd_register_root (struct usb_hcd *hcd)
|
||||||
|
{
|
||||||
|
return usb_register_root_hub (
|
||||||
|
hcd_to_bus (hcd)->root_hub, hcd->controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* exported only within usbcore */
|
||||||
|
|
||||||
|
extern struct list_head usb_bus_list;
|
||||||
|
extern struct semaphore usb_bus_list_lock;
|
||||||
|
|
||||||
|
extern void usb_bus_get (struct usb_bus *bus);
|
||||||
|
extern void usb_bus_put (struct usb_bus *bus);
|
||||||
|
|
||||||
|
extern int usb_find_interface_driver (struct usb_device *dev,
|
||||||
|
struct usb_interface *interface);
|
||||||
|
|
||||||
|
#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
|
||||||
|
|
||||||
|
#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB device fs stuff
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USB_DEVICEFS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* these are expected to be called from the USB core/hub thread
|
||||||
|
* with the kernel lock held
|
||||||
|
*/
|
||||||
|
extern void usbfs_add_bus(struct usb_bus *bus);
|
||||||
|
extern void usbfs_remove_bus(struct usb_bus *bus);
|
||||||
|
extern void usbfs_add_device(struct usb_device *dev);
|
||||||
|
extern void usbfs_remove_device(struct usb_device *dev);
|
||||||
|
extern void usbfs_update_special (void);
|
||||||
|
|
||||||
|
extern int usbfs_init(void);
|
||||||
|
extern void usbfs_cleanup(void);
|
||||||
|
|
||||||
|
#else /* CONFIG_USB_DEVICEFS */
|
||||||
|
|
||||||
|
static _inline void usbfs_add_bus(struct usb_bus *bus) {}
|
||||||
|
static _inline void usbfs_remove_bus(struct usb_bus *bus) {}
|
||||||
|
static _inline void usbfs_add_device(struct usb_device *dev) {}
|
||||||
|
static _inline void usbfs_remove_device(struct usb_device *dev) {}
|
||||||
|
static _inline void usbfs_update_special (void) {}
|
||||||
|
|
||||||
|
static _inline int usbfs_init(void) { return 0; }
|
||||||
|
static _inline void usbfs_cleanup(void) { }
|
||||||
|
|
||||||
|
#endif /* CONFIG_USB_DEVICEFS */
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */
|
||||||
|
// bleech -- resurfaced in 2.4.11 or 2.4.12
|
||||||
|
#define bitmap DeviceRemovable
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* random stuff */
|
||||||
|
|
||||||
|
#define RUN_CONTEXT (in_irq () ? "in_irq" \
|
||||||
|
: (in_interrupt () ? "in_interrupt" : "can sleep"))
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
|
|
@ -0,0 +1,201 @@
|
||||||
|
#ifndef __LINUX_HUB_H
|
||||||
|
#define __LINUX_HUB_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub protocol and driver data structures.
|
||||||
|
*
|
||||||
|
* Some of these are known to the "virtual root hub" code
|
||||||
|
* in host controller drivers.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#include <linux/list.h>
|
||||||
|
#include <linux/workqueue.h>
|
||||||
|
#include <linux/compiler.h> /* likely()/unlikely() */
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Hub request types
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
|
||||||
|
#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub class requests
|
||||||
|
* See USB 2.0 spec Table 11-16
|
||||||
|
*/
|
||||||
|
#define HUB_CLEAR_TT_BUFFER 8
|
||||||
|
#define HUB_RESET_TT 9
|
||||||
|
#define HUB_GET_TT_STATE 10
|
||||||
|
#define HUB_STOP_TT 11
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub Class feature numbers
|
||||||
|
* See USB 2.0 spec Table 11-17
|
||||||
|
*/
|
||||||
|
#define C_HUB_LOCAL_POWER 0
|
||||||
|
#define C_HUB_OVER_CURRENT 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Port feature numbers
|
||||||
|
* See USB 2.0 spec Table 11-17
|
||||||
|
*/
|
||||||
|
#define USB_PORT_FEAT_CONNECTION 0
|
||||||
|
#define USB_PORT_FEAT_ENABLE 1
|
||||||
|
#define USB_PORT_FEAT_SUSPEND 2
|
||||||
|
#define USB_PORT_FEAT_OVER_CURRENT 3
|
||||||
|
#define USB_PORT_FEAT_RESET 4
|
||||||
|
#define USB_PORT_FEAT_POWER 8
|
||||||
|
#define USB_PORT_FEAT_LOWSPEED 9
|
||||||
|
#define USB_PORT_FEAT_HIGHSPEED 10
|
||||||
|
#define USB_PORT_FEAT_C_CONNECTION 16
|
||||||
|
#define USB_PORT_FEAT_C_ENABLE 17
|
||||||
|
#define USB_PORT_FEAT_C_SUSPEND 18
|
||||||
|
#define USB_PORT_FEAT_C_OVER_CURRENT 19
|
||||||
|
#define USB_PORT_FEAT_C_RESET 20
|
||||||
|
#define USB_PORT_FEAT_TEST 21
|
||||||
|
#define USB_PORT_FEAT_INDICATOR 22
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub Status and Hub Change results
|
||||||
|
* See USB 2.0 spec Table 11-19 and Table 11-20
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_port_status {
|
||||||
|
__u16 wPortStatus;
|
||||||
|
__u16 wPortChange;
|
||||||
|
}; // __attribute__ ((packed));
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wPortStatus bit field
|
||||||
|
* See USB 2.0 spec Table 11-21
|
||||||
|
*/
|
||||||
|
#define USB_PORT_STAT_CONNECTION 0x0001
|
||||||
|
#define USB_PORT_STAT_ENABLE 0x0002
|
||||||
|
#define USB_PORT_STAT_SUSPEND 0x0004
|
||||||
|
#define USB_PORT_STAT_OVERCURRENT 0x0008
|
||||||
|
#define USB_PORT_STAT_RESET 0x0010
|
||||||
|
/* bits 5 to 7 are reserved */
|
||||||
|
#define USB_PORT_STAT_POWER 0x0100
|
||||||
|
#define USB_PORT_STAT_LOW_SPEED 0x0200
|
||||||
|
#define USB_PORT_STAT_HIGH_SPEED 0x0400
|
||||||
|
#define USB_PORT_STAT_TEST 0x0800
|
||||||
|
#define USB_PORT_STAT_INDICATOR 0x1000
|
||||||
|
/* bits 13 to 15 are reserved */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wPortChange bit field
|
||||||
|
* See USB 2.0 spec Table 11-22
|
||||||
|
* Bits 0 to 4 shown, bits 5 to 15 are reserved
|
||||||
|
*/
|
||||||
|
#define USB_PORT_STAT_C_CONNECTION 0x0001
|
||||||
|
#define USB_PORT_STAT_C_ENABLE 0x0002
|
||||||
|
#define USB_PORT_STAT_C_SUSPEND 0x0004
|
||||||
|
#define USB_PORT_STAT_C_OVERCURRENT 0x0008
|
||||||
|
#define USB_PORT_STAT_C_RESET 0x0010
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wHubCharacteristics (masks)
|
||||||
|
* See USB 2.0 spec Table 11-13, offset 3
|
||||||
|
*/
|
||||||
|
#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
|
||||||
|
#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
|
||||||
|
#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
|
||||||
|
#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
|
||||||
|
#define HUB_CHAR_PORTIND 0x0080 /* D7 */
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_hub_status {
|
||||||
|
__u16 wHubStatus;
|
||||||
|
__u16 wHubChange;
|
||||||
|
};// __attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub Status & Hub Change bit masks
|
||||||
|
* See USB 2.0 spec Table 11-19 and Table 11-20
|
||||||
|
* Bits 0 and 1 for wHubStatus and wHubChange
|
||||||
|
* Bits 2 to 15 are reserved for both
|
||||||
|
*/
|
||||||
|
#define HUB_STATUS_LOCAL_POWER 0x0001
|
||||||
|
#define HUB_STATUS_OVERCURRENT 0x0002
|
||||||
|
#define HUB_CHANGE_LOCAL_POWER 0x0001
|
||||||
|
#define HUB_CHANGE_OVERCURRENT 0x0002
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hub descriptor
|
||||||
|
* See USB 2.0 spec Table 11-13
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
|
||||||
|
#define USB_DT_HUB_NONVAR_SIZE 7
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_hub_descriptor {
|
||||||
|
__u8 bDescLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
__u8 bNbrPorts;
|
||||||
|
__u16 wHubCharacteristics;
|
||||||
|
__u8 bPwrOn2PwrGood;
|
||||||
|
__u8 bHubContrCurrent;
|
||||||
|
/* add 1 bit for hub status change; round to bytes */
|
||||||
|
__u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
|
||||||
|
__u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
struct usb_device;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As of USB 2.0, full/low speed devices are segregated into trees.
|
||||||
|
* One type grows from USB 1.1 host controllers (OHCI, UHCI etc).
|
||||||
|
* The other type grows from high speed hubs when they connect to
|
||||||
|
* full/low speed devices using "Transaction Translators" (TTs).
|
||||||
|
*
|
||||||
|
* TTs should only be known to the hub driver, and high speed bus
|
||||||
|
* drivers (only EHCI for now). They affect periodic scheduling and
|
||||||
|
* sometimes control/bulk error recovery.
|
||||||
|
*/
|
||||||
|
struct usb_tt {
|
||||||
|
struct usb_device *hub; /* upstream highspeed hub */
|
||||||
|
int multi; /* true means one TT per port */
|
||||||
|
|
||||||
|
/* for control/bulk error recovery (CLEAR_TT_BUFFER) */
|
||||||
|
spinlock_t lock;
|
||||||
|
struct list_head clear_list; /* of usb_tt_clear */
|
||||||
|
struct work_struct kevent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct usb_tt_clear {
|
||||||
|
struct list_head clear_list;
|
||||||
|
unsigned tt;
|
||||||
|
u16 devinfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe);
|
||||||
|
|
||||||
|
struct usb_hub {
|
||||||
|
struct usb_interface *intf; /* the "real" device */
|
||||||
|
struct urb *urb; /* for interrupt polling pipe */
|
||||||
|
|
||||||
|
/* buffer for urb ... 1 bit each for hub and children, rounded up */
|
||||||
|
char (*buffer)[(USB_MAXCHILDREN + 1 + 7) / 8];
|
||||||
|
dma_addr_t buffer_dma; /* DMA address for buffer */
|
||||||
|
union {
|
||||||
|
struct usb_hub_status hub;
|
||||||
|
struct usb_port_status port;
|
||||||
|
} *status; /* buffer for status reports */
|
||||||
|
|
||||||
|
int error; /* last reported error */
|
||||||
|
int nerrors; /* track consecutive errors */
|
||||||
|
|
||||||
|
struct list_head hub_list; /* all hubs */
|
||||||
|
struct list_head event_list; /* hubs w/data or errs ready */
|
||||||
|
|
||||||
|
struct usb_hub_descriptor *descriptor; /* class descriptor */
|
||||||
|
struct semaphore khubd_sem;
|
||||||
|
struct usb_tt tt; /* Transaction Translator */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __LINUX_HUB_H */
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* Functions local to drivers/usb/core/ */
|
||||||
|
|
||||||
|
extern void usb_create_driverfs_dev_files (struct usb_device *dev);
|
||||||
|
extern void usb_create_driverfs_intf_files (struct usb_interface *intf);
|
||||||
|
|
|
@ -0,0 +1,417 @@
|
||||||
|
/*
|
||||||
|
* OHCI HCD (Host Controller Driver) for USB.
|
||||||
|
*
|
||||||
|
* (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
|
||||||
|
* (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
|
||||||
|
*
|
||||||
|
* This file is licenced under the GPL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OHCI Endpoint Descriptor (ED) ... holds TD queue
|
||||||
|
* See OHCI spec, section 4.2
|
||||||
|
*
|
||||||
|
* This is a "Queue Head" for those transfers, which is why
|
||||||
|
* both EHCI and UHCI call similar structures a "QH".
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct ed {
|
||||||
|
/* first fields are hardware-specified, le32 */
|
||||||
|
__u32 hwINFO; /* endpoint config bitmap */
|
||||||
|
/* info bits defined by hcd */
|
||||||
|
#define ED_DEQUEUE __constant_cpu_to_le32(1 << 27)
|
||||||
|
/* info bits defined by the hardware */
|
||||||
|
#define ED_ISO __constant_cpu_to_le32(1 << 15)
|
||||||
|
#define ED_SKIP __constant_cpu_to_le32(1 << 14)
|
||||||
|
#define ED_LOWSPEED __constant_cpu_to_le32(1 << 13)
|
||||||
|
#define ED_OUT __constant_cpu_to_le32(0x01 << 11)
|
||||||
|
#define ED_IN __constant_cpu_to_le32(0x02 << 11)
|
||||||
|
__u32 hwTailP; /* tail of TD list */
|
||||||
|
__u32 hwHeadP; /* head of TD list (hc r/w) */
|
||||||
|
#define ED_C __constant_cpu_to_le32(0x02) /* toggle carry */
|
||||||
|
#define ED_H __constant_cpu_to_le32(0x01) /* halted */
|
||||||
|
__u32 hwNextED; /* next ED in list */
|
||||||
|
|
||||||
|
/* rest are purely for the driver's use */
|
||||||
|
dma_addr_t dma; /* addr of ED */
|
||||||
|
struct td *dummy; /* next TD to activate */
|
||||||
|
|
||||||
|
/* host's view of schedule */
|
||||||
|
struct ed *ed_next; /* on schedule or rm_list */
|
||||||
|
struct ed *ed_prev; /* for non-interrupt EDs */
|
||||||
|
struct list_head td_list; /* "shadow list" of our TDs */
|
||||||
|
|
||||||
|
/* create --> IDLE --> OPER --> ... --> IDLE --> destroy
|
||||||
|
* usually: OPER --> UNLINK --> (IDLE | OPER) --> ...
|
||||||
|
* some special cases : OPER --> IDLE ...
|
||||||
|
*/
|
||||||
|
u8 state; /* ED_{IDLE,UNLINK,OPER} */
|
||||||
|
#define ED_IDLE 0x00 /* NOT linked to HC */
|
||||||
|
#define ED_UNLINK 0x01 /* being unlinked from hc */
|
||||||
|
#define ED_OPER 0x02 /* IS linked to hc */
|
||||||
|
|
||||||
|
u8 type; /* PIPE_{BULK,...} */
|
||||||
|
|
||||||
|
/* periodic scheduling params (for intr and iso) */
|
||||||
|
u8 branch;
|
||||||
|
u16 interval;
|
||||||
|
u16 load;
|
||||||
|
u16 last_iso; /* iso only */
|
||||||
|
|
||||||
|
/* HC may see EDs on rm_list until next frame (frame_no == tick) */
|
||||||
|
u16 tick;
|
||||||
|
}; // __attribute__ ((aligned(16)));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define ED_MASK ((u32)~0x0f) /* strip hw status in low addr bits */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OHCI Transfer Descriptor (TD) ... one per transfer segment
|
||||||
|
* See OHCI spec, sections 4.3.1 (general = control/bulk/interrupt)
|
||||||
|
* and 4.3.2 (iso)
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct td {
|
||||||
|
/* first fields are hardware-specified, le32 */
|
||||||
|
__u32 hwINFO; /* transfer info bitmask */
|
||||||
|
|
||||||
|
/* hwINFO bits for both general and iso tds: */
|
||||||
|
#define TD_CC 0xf0000000 /* condition code */
|
||||||
|
#define TD_CC_GET(td_p) ((td_p >>28) & 0x0f)
|
||||||
|
//#define TD_CC_SET(td_p, cc) (td_p) = ((td_p) & 0x0fffffff) | (((cc) & 0x0f) << 28)
|
||||||
|
#define TD_DI 0x00E00000 /* frames before interrupt */
|
||||||
|
#define TD_DI_SET(X) (((X) & 0x07)<< 21)
|
||||||
|
/* these two bits are available for definition/use by HCDs in both
|
||||||
|
* general and iso tds ... others are available for only one type
|
||||||
|
*/
|
||||||
|
#define TD_DONE 0x00020000 /* retired to donelist */
|
||||||
|
#define TD_ISO 0x00010000 /* copy of ED_ISO */
|
||||||
|
|
||||||
|
/* hwINFO bits for general tds: */
|
||||||
|
#define TD_EC 0x0C000000 /* error count */
|
||||||
|
#define TD_T 0x03000000 /* data toggle state */
|
||||||
|
#define TD_T_DATA0 0x02000000 /* DATA0 */
|
||||||
|
#define TD_T_DATA1 0x03000000 /* DATA1 */
|
||||||
|
#define TD_T_TOGGLE 0x00000000 /* uses ED_C */
|
||||||
|
#define TD_DP 0x00180000 /* direction/pid */
|
||||||
|
#define TD_DP_SETUP 0x00000000 /* SETUP pid */
|
||||||
|
#define TD_DP_IN 0x00100000 /* IN pid */
|
||||||
|
#define TD_DP_OUT 0x00080000 /* OUT pid */
|
||||||
|
/* 0x00180000 rsvd */
|
||||||
|
#define TD_R 0x00040000 /* round: short packets OK? */
|
||||||
|
|
||||||
|
/* (no hwINFO #defines yet for iso tds) */
|
||||||
|
|
||||||
|
__u32 hwCBP; /* Current Buffer Pointer (or 0) */
|
||||||
|
__u32 hwNextTD; /* Next TD Pointer */
|
||||||
|
__u32 hwBE; /* Memory Buffer End Pointer */
|
||||||
|
|
||||||
|
/* PSW is only for ISO */
|
||||||
|
#define MAXPSW 1 /* hardware allows 8 */
|
||||||
|
__u16 hwPSW [MAXPSW];
|
||||||
|
|
||||||
|
/* rest are purely for the driver's use */
|
||||||
|
__u8 index;
|
||||||
|
struct ed *ed;
|
||||||
|
struct td *td_hash; /* dma-->td hashtable */
|
||||||
|
struct td *next_dl_td;
|
||||||
|
struct urb *urb;
|
||||||
|
|
||||||
|
dma_addr_t td_dma; /* addr of this TD */
|
||||||
|
dma_addr_t data_dma; /* addr of data it points to */
|
||||||
|
|
||||||
|
struct list_head td_list; /* "shadow list", TDs on same ED */
|
||||||
|
}; // __attribute__ ((aligned(32))); /* c/b/i need 16; only iso needs 32 */
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define TD_MASK ((u32)~0x1f) /* strip hw status in low addr bits */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hardware transfer status codes -- CC from td->hwINFO or td->hwPSW
|
||||||
|
*/
|
||||||
|
#define TD_CC_NOERROR 0x00
|
||||||
|
#define TD_CC_CRC 0x01
|
||||||
|
#define TD_CC_BITSTUFFING 0x02
|
||||||
|
#define TD_CC_DATATOGGLEM 0x03
|
||||||
|
#define TD_CC_STALL 0x04
|
||||||
|
#define TD_DEVNOTRESP 0x05
|
||||||
|
#define TD_PIDCHECKFAIL 0x06
|
||||||
|
#define TD_UNEXPECTEDPID 0x07
|
||||||
|
#define TD_DATAOVERRUN 0x08
|
||||||
|
#define TD_DATAUNDERRUN 0x09
|
||||||
|
/* 0x0A, 0x0B reserved for hardware */
|
||||||
|
#define TD_BUFFEROVERRUN 0x0C
|
||||||
|
#define TD_BUFFERUNDERRUN 0x0D
|
||||||
|
/* 0x0E, 0x0F reserved for HCD */
|
||||||
|
#define TD_NOTACCESSED 0x0F
|
||||||
|
|
||||||
|
|
||||||
|
/* map OHCI TD status codes (CC) to errno values */
|
||||||
|
static const int cc_to_error [16] = {
|
||||||
|
/* No Error */ 0,
|
||||||
|
/* CRC Error */ -EILSEQ,
|
||||||
|
/* Bit Stuff */ -EPROTO,
|
||||||
|
/* Data Togg */ -EILSEQ,
|
||||||
|
/* Stall */ -EPIPE,
|
||||||
|
/* DevNotResp */ -ETIMEDOUT,
|
||||||
|
/* PIDCheck */ -EPROTO,
|
||||||
|
/* UnExpPID */ -EPROTO,
|
||||||
|
/* DataOver */ -EOVERFLOW,
|
||||||
|
/* DataUnder */ -EREMOTEIO,
|
||||||
|
/* (for hw) */ -EIO,
|
||||||
|
/* (for hw) */ -EIO,
|
||||||
|
/* BufferOver */ -ECOMM,
|
||||||
|
/* BuffUnder */ -ENOSR,
|
||||||
|
/* (for HCD) */ -EALREADY,
|
||||||
|
/* (for HCD) */ -EALREADY
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The HCCA (Host Controller Communications Area) is a 256 byte
|
||||||
|
* structure defined section 4.4.1 of the OHCI spec. The HC is
|
||||||
|
* told the base address of it. It must be 256-byte aligned.
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct ohci_hcca {
|
||||||
|
#define NUM_INTS 32
|
||||||
|
__u32 int_table [NUM_INTS]; /* periodic schedule */
|
||||||
|
__u16 frame_no; /* current frame number */
|
||||||
|
__u16 pad1; /* set to 0 on each frame_no change */
|
||||||
|
__u32 done_head; /* info returned for an interrupt */
|
||||||
|
u8 reserved_for_hc [116];
|
||||||
|
u8 what [4]; /* spec only identifies 252 bytes :) */
|
||||||
|
}; // __attribute__ ((aligned(256)));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the structure of the OHCI controller's memory mapped I/O region.
|
||||||
|
* You must use readl() and writel() (in <asm/io.h>) to access these fields!!
|
||||||
|
* Layout is in section 7 (and appendix B) of the spec.
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct ohci_regs {
|
||||||
|
/* control and status registers (section 7.1) */
|
||||||
|
__u32 revision;
|
||||||
|
__u32 control;
|
||||||
|
__u32 cmdstatus;
|
||||||
|
__u32 intrstatus;
|
||||||
|
__u32 intrenable;
|
||||||
|
__u32 intrdisable;
|
||||||
|
|
||||||
|
/* memory pointers (section 7.2) */
|
||||||
|
__u32 hcca;
|
||||||
|
__u32 ed_periodcurrent;
|
||||||
|
__u32 ed_controlhead;
|
||||||
|
__u32 ed_controlcurrent;
|
||||||
|
__u32 ed_bulkhead;
|
||||||
|
__u32 ed_bulkcurrent;
|
||||||
|
__u32 donehead;
|
||||||
|
|
||||||
|
/* frame counters (section 7.3) */
|
||||||
|
__u32 fminterval;
|
||||||
|
__u32 fmremaining;
|
||||||
|
__u32 fmnumber;
|
||||||
|
__u32 periodicstart;
|
||||||
|
__u32 lsthresh;
|
||||||
|
|
||||||
|
/* Root hub ports (section 7.4) */
|
||||||
|
struct ohci_roothub_regs {
|
||||||
|
__u32 a;
|
||||||
|
__u32 b;
|
||||||
|
__u32 status;
|
||||||
|
#define MAX_ROOT_PORTS 15 /* maximum OHCI root hub ports (RH_A_NDP) */
|
||||||
|
__u32 portstatus [MAX_ROOT_PORTS];
|
||||||
|
} roothub;
|
||||||
|
|
||||||
|
/* and optional "legacy support" registers (appendix B) at 0x0100 */
|
||||||
|
|
||||||
|
}; // __attribute__ ((aligned(32)));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/* OHCI CONTROL AND STATUS REGISTER MASKS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HcControl (control) register masks
|
||||||
|
*/
|
||||||
|
#define OHCI_CTRL_CBSR (3 << 0) /* control/bulk service ratio */
|
||||||
|
#define OHCI_CTRL_PLE (1 << 2) /* periodic list enable */
|
||||||
|
#define OHCI_CTRL_IE (1 << 3) /* isochronous enable */
|
||||||
|
#define OHCI_CTRL_CLE (1 << 4) /* control list enable */
|
||||||
|
#define OHCI_CTRL_BLE (1 << 5) /* bulk list enable */
|
||||||
|
#define OHCI_CTRL_HCFS (3 << 6) /* host controller functional state */
|
||||||
|
#define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
|
||||||
|
#define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
|
||||||
|
#define OHCI_CTRL_RWE (1 << 10) /* remote wakeup enable */
|
||||||
|
|
||||||
|
/* pre-shifted values for HCFS */
|
||||||
|
# define OHCI_USB_RESET (0 << 6)
|
||||||
|
# define OHCI_USB_RESUME (1 << 6)
|
||||||
|
# define OHCI_USB_OPER (2 << 6)
|
||||||
|
# define OHCI_USB_SUSPEND (3 << 6)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HcCommandStatus (cmdstatus) register masks
|
||||||
|
*/
|
||||||
|
#define OHCI_HCR (1 << 0) /* host controller reset */
|
||||||
|
#define OHCI_CLF (1 << 1) /* control list filled */
|
||||||
|
#define OHCI_BLF (1 << 2) /* bulk list filled */
|
||||||
|
#define OHCI_OCR (1 << 3) /* ownership change request */
|
||||||
|
#define OHCI_SOC (3 << 16) /* scheduling overrun count */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* masks used with interrupt registers:
|
||||||
|
* HcInterruptStatus (intrstatus)
|
||||||
|
* HcInterruptEnable (intrenable)
|
||||||
|
* HcInterruptDisable (intrdisable)
|
||||||
|
*/
|
||||||
|
#define OHCI_INTR_SO (1 << 0) /* scheduling overrun */
|
||||||
|
#define OHCI_INTR_WDH (1 << 1) /* writeback of done_head */
|
||||||
|
#define OHCI_INTR_SF (1 << 2) /* start frame */
|
||||||
|
#define OHCI_INTR_RD (1 << 3) /* resume detect */
|
||||||
|
#define OHCI_INTR_UE (1 << 4) /* unrecoverable error */
|
||||||
|
#define OHCI_INTR_FNO (1 << 5) /* frame number overflow */
|
||||||
|
#define OHCI_INTR_RHSC (1 << 6) /* root hub status change */
|
||||||
|
#define OHCI_INTR_OC (1 << 30) /* ownership change */
|
||||||
|
#define OHCI_INTR_MIE (1 << 31) /* master interrupt enable */
|
||||||
|
|
||||||
|
|
||||||
|
/* OHCI ROOT HUB REGISTER MASKS */
|
||||||
|
|
||||||
|
/* roothub.portstatus [i] bits */
|
||||||
|
#define RH_PS_CCS 0x00000001 /* current connect status */
|
||||||
|
#define RH_PS_PES 0x00000002 /* port enable status*/
|
||||||
|
#define RH_PS_PSS 0x00000004 /* port suspend status */
|
||||||
|
#define RH_PS_POCI 0x00000008 /* port over current indicator */
|
||||||
|
#define RH_PS_PRS 0x00000010 /* port reset status */
|
||||||
|
#define RH_PS_PPS 0x00000100 /* port power status */
|
||||||
|
#define RH_PS_LSDA 0x00000200 /* low speed device attached */
|
||||||
|
#define RH_PS_CSC 0x00010000 /* connect status change */
|
||||||
|
#define RH_PS_PESC 0x00020000 /* port enable status change */
|
||||||
|
#define RH_PS_PSSC 0x00040000 /* port suspend status change */
|
||||||
|
#define RH_PS_OCIC 0x00080000 /* over current indicator change */
|
||||||
|
#define RH_PS_PRSC 0x00100000 /* port reset status change */
|
||||||
|
|
||||||
|
/* roothub.status bits */
|
||||||
|
#define RH_HS_LPS 0x00000001 /* local power status */
|
||||||
|
#define RH_HS_OCI 0x00000002 /* over current indicator */
|
||||||
|
#define RH_HS_DRWE 0x00008000 /* device remote wakeup enable */
|
||||||
|
#define RH_HS_LPSC 0x00010000 /* local power status change */
|
||||||
|
#define RH_HS_OCIC 0x00020000 /* over current indicator change */
|
||||||
|
#define RH_HS_CRWE 0x80000000 /* clear remote wakeup enable */
|
||||||
|
|
||||||
|
/* roothub.b masks */
|
||||||
|
#define RH_B_DR 0x0000ffff /* device removable flags */
|
||||||
|
#define RH_B_PPCM 0xffff0000 /* port power control mask */
|
||||||
|
|
||||||
|
/* roothub.a masks */
|
||||||
|
#define RH_A_NDP (0xff << 0) /* number of downstream ports */
|
||||||
|
#define RH_A_PSM (1 << 8) /* power switching mode */
|
||||||
|
#define RH_A_NPS (1 << 9) /* no power switching */
|
||||||
|
#define RH_A_DT (1 << 10) /* device type (mbz) */
|
||||||
|
#define RH_A_OCPM (1 << 11) /* over current protection mode */
|
||||||
|
#define RH_A_NOCP (1 << 12) /* no over current protection */
|
||||||
|
#define RH_A_POTPGT (0xff << 24) /* power on to power good time */
|
||||||
|
|
||||||
|
|
||||||
|
/* hcd-private per-urb state */
|
||||||
|
typedef struct urb_priv {
|
||||||
|
struct ed *ed;
|
||||||
|
__u16 length; // # tds in this request
|
||||||
|
__u16 td_cnt; // tds already serviced
|
||||||
|
int state;
|
||||||
|
struct td *td [0]; // all TDs in this request
|
||||||
|
|
||||||
|
} urb_priv_t;
|
||||||
|
|
||||||
|
#define URB_DEL 1
|
||||||
|
|
||||||
|
#define TD_HASH_SIZE 64 /* power'o'two */
|
||||||
|
// sizeof (struct td) ~= 64 == 2^6 ...
|
||||||
|
#define TD_HASH_FUNC(td_dma) ((td_dma ^ (td_dma >> 6)) % TD_HASH_SIZE)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the full ohci controller description
|
||||||
|
*
|
||||||
|
* Note how the "proper" USB information is just
|
||||||
|
* a subset of what the full implementation needs. (Linus)
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct ohci_hcd {
|
||||||
|
spinlock_t lock;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I/O memory used to communicate with the HC (dma-consistent)
|
||||||
|
*/
|
||||||
|
struct ohci_regs *regs;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* main memory used to communicate with the HC (dma-consistent).
|
||||||
|
* hcd adds to schedule for a live hc any time, but removals finish
|
||||||
|
* only at the start of the next frame.
|
||||||
|
*/
|
||||||
|
struct ohci_hcca *hcca;
|
||||||
|
dma_addr_t hcca_dma;
|
||||||
|
|
||||||
|
struct ed *ed_rm_list; /* to be removed */
|
||||||
|
|
||||||
|
struct ed *ed_bulktail; /* last in bulk list */
|
||||||
|
struct ed *ed_controltail; /* last in ctrl list */
|
||||||
|
struct ed *periodic [NUM_INTS]; /* shadow int_table */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* memory management for queue data structures
|
||||||
|
*/
|
||||||
|
struct pci_pool *td_cache;
|
||||||
|
struct pci_pool *ed_cache;
|
||||||
|
struct td *td_hash [TD_HASH_SIZE];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* driver state
|
||||||
|
*/
|
||||||
|
int disabled; /* e.g. got a UE, we're hung */
|
||||||
|
int sleeping;
|
||||||
|
int load [NUM_INTS];
|
||||||
|
u32 hc_control; /* copy of hc control reg */
|
||||||
|
|
||||||
|
unsigned long flags; /* for HC bugs */
|
||||||
|
#define OHCI_QUIRK_AMD756 0x01 /* erratum #4 */
|
||||||
|
#define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */
|
||||||
|
// there are also chip quirks/bugs in init logic
|
||||||
|
|
||||||
|
/*
|
||||||
|
* framework state
|
||||||
|
*/
|
||||||
|
struct usb_hcd hcd;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define hcd_to_ohci(hcd_ptr) container_of(hcd_ptr, struct ohci_hcd, hcd)
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define STUB_DEBUG_FILES
|
||||||
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
//#define ohci_dbg(ohci, fmt, args...) dev_dbg ((ohci)->hcd.controller , fmt , ## args )
|
||||||
|
//#define ohci_err(ohci, fmt, args...) dev_err ((ohci)->hcd.controller , fmt , ## args )
|
||||||
|
//#define ohci_info(ohci, fmt, args...) dev_info ((ohci)->hcd.controller , fmt , ## args )
|
||||||
|
//#define ohci_warn(ohci, fmt, args...) dev_warn ((ohci)->hcd.controller , fmt , ## args )
|
||||||
|
|
||||||
|
int ohci_dbg(struct ohci_hcd* ohci, char *str, const char *format, ...);
|
||||||
|
int ohci_err(struct ohci_hcd* ohci, char *str, const char *format, ...);
|
||||||
|
int ohci_info(struct ohci_hcd* ohci, char *str, const char *format, ...);
|
||||||
|
int ohci_warn(struct ohci_hcd* ohci, char *str, const char *format, ...);
|
||||||
|
int ohci_vdbg(struct ohci_hcd* ohci, char *str, const char *format, ...);
|
||||||
|
|
||||||
|
|
||||||
|
//#ifdef OHCI_VERBOSE_DEBUG
|
||||||
|
//# define ohci_vdbg ohci_dbg
|
||||||
|
//#else
|
||||||
|
//# define ohci_vdbg(ohci, fmt, args...) do { } while (0)
|
||||||
|
//#endif
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
/*
|
||||||
|
* Configs for OHCI
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define CONFIG_PCI
|
|
@ -0,0 +1,72 @@
|
||||||
|
#ifndef _LINUX_BITOPS_H
|
||||||
|
#define _LINUX_BITOPS_H
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ffs: find first bit set. This is defined the same way as
|
||||||
|
* the libc and compiler builtin ffs routines, therefore
|
||||||
|
* differs in spirit from the above ffz (man ffs).
|
||||||
|
*/
|
||||||
|
|
||||||
|
static __inline int generic_ffs(int x)
|
||||||
|
{
|
||||||
|
int r = 1;
|
||||||
|
|
||||||
|
if (!x)
|
||||||
|
return 0;
|
||||||
|
if (!(x & 0xffff)) {
|
||||||
|
x >>= 16;
|
||||||
|
r += 16;
|
||||||
|
}
|
||||||
|
if (!(x & 0xff)) {
|
||||||
|
x >>= 8;
|
||||||
|
r += 8;
|
||||||
|
}
|
||||||
|
if (!(x & 0xf)) {
|
||||||
|
x >>= 4;
|
||||||
|
r += 4;
|
||||||
|
}
|
||||||
|
if (!(x & 3)) {
|
||||||
|
x >>= 2;
|
||||||
|
r += 2;
|
||||||
|
}
|
||||||
|
if (!(x & 1)) {
|
||||||
|
x >>= 1;
|
||||||
|
r += 1;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* hweightN: returns the hamming weight (i.e. the number
|
||||||
|
* of bits set) of a N-bit word
|
||||||
|
*/
|
||||||
|
|
||||||
|
static __inline unsigned int generic_hweight32(unsigned int w)
|
||||||
|
{
|
||||||
|
unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
|
||||||
|
res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
|
||||||
|
res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
|
||||||
|
res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
|
||||||
|
return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline unsigned int generic_hweight16(unsigned int w)
|
||||||
|
{
|
||||||
|
unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
|
||||||
|
res = (res & 0x3333) + ((res >> 2) & 0x3333);
|
||||||
|
res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
|
||||||
|
return (res & 0x00FF) + ((res >> 8) & 0x00FF);
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline unsigned int generic_hweight8(unsigned int w)
|
||||||
|
{
|
||||||
|
unsigned int res = (w & 0x55) + ((w >> 1) & 0x55);
|
||||||
|
res = (res & 0x33) + ((res >> 2) & 0x33);
|
||||||
|
return (res & 0x0F) + ((res >> 4) & 0x0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "asm/bitops.h"
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,332 @@
|
||||||
|
/*
|
||||||
|
* This file holds USB constants and structures that are needed for USB
|
||||||
|
* device APIs. These are used by the USB device model, which is defined
|
||||||
|
* in chapter 9 of the USB 2.0 specification. Linux has several APIs in C
|
||||||
|
* that need these:
|
||||||
|
*
|
||||||
|
* - the master/host side Linux-USB kernel driver API;
|
||||||
|
* - the "usbfs" user space API; and
|
||||||
|
* - (eventually) a Linux "gadget" slave/device side driver API.
|
||||||
|
*
|
||||||
|
* USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
|
||||||
|
* act either as a USB master/host or as a USB slave/device. That means
|
||||||
|
* the master and slave side APIs will benefit from working well together.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LINUX_USB_CH9_H
|
||||||
|
#define __LINUX_USB_CH9_H
|
||||||
|
#if 0
|
||||||
|
#include <asm/types.h> /* __u8 etc */
|
||||||
|
#endif
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* CONTROL REQUEST SUPPORT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB directions
|
||||||
|
*
|
||||||
|
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
|
||||||
|
* It's also one of three fields in control requests bRequestType.
|
||||||
|
*/
|
||||||
|
#define USB_DIR_OUT 0 /* to device */
|
||||||
|
#define USB_DIR_IN 0x80 /* to host */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB types, the second of three bRequestType fields
|
||||||
|
*/
|
||||||
|
#define USB_TYPE_MASK (0x03 << 5)
|
||||||
|
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||||
|
#define USB_TYPE_CLASS (0x01 << 5)
|
||||||
|
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||||
|
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB recipients, the third of three bRequestType fields
|
||||||
|
*/
|
||||||
|
#define USB_RECIP_MASK 0x1f
|
||||||
|
#define USB_RECIP_DEVICE 0x00
|
||||||
|
#define USB_RECIP_INTERFACE 0x01
|
||||||
|
#define USB_RECIP_ENDPOINT 0x02
|
||||||
|
#define USB_RECIP_OTHER 0x03
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard requests, for the bRequest field of a SETUP packet.
|
||||||
|
*
|
||||||
|
* These are qualified by the bRequestType field, so that for example
|
||||||
|
* TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
|
||||||
|
* by a GET_STATUS request.
|
||||||
|
*/
|
||||||
|
#define USB_REQ_GET_STATUS 0x00
|
||||||
|
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||||
|
#define USB_REQ_SET_FEATURE 0x03
|
||||||
|
#define USB_REQ_SET_ADDRESS 0x05
|
||||||
|
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||||
|
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||||
|
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||||
|
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||||
|
#define USB_REQ_GET_INTERFACE 0x0A
|
||||||
|
#define USB_REQ_SET_INTERFACE 0x0B
|
||||||
|
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct usb_ctrlrequest - SETUP data for a USB device control request
|
||||||
|
* @bRequestType: matches the USB bmRequestType field
|
||||||
|
* @bRequest: matches the USB bRequest field
|
||||||
|
* @wValue: matches the USB wValue field (le16 byte order)
|
||||||
|
* @wIndex: matches the USB wIndex field (le16 byte order)
|
||||||
|
* @wLength: matches the USB wLength field (le16 byte order)
|
||||||
|
*
|
||||||
|
* This structure is used to send control requests to a USB device. It matches
|
||||||
|
* the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
|
||||||
|
* USB spec for a fuller description of the different fields, and what they are
|
||||||
|
* used for.
|
||||||
|
*
|
||||||
|
* Note that the driver for any interface can issue control requests.
|
||||||
|
* For most devices, interfaces don't coordinate with each other, so
|
||||||
|
* such requests may be made at any time.
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_ctrlrequest {
|
||||||
|
__u8 bRequestType;
|
||||||
|
__u8 bRequest;
|
||||||
|
__u16 wValue;
|
||||||
|
__u16 wIndex;
|
||||||
|
__u16 wLength;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
|
||||||
|
* (rarely) accepted by SET_DESCRIPTOR.
|
||||||
|
*
|
||||||
|
* Note that all multi-byte values here are encoded in little endian
|
||||||
|
* byte order "on the wire". But when exposed through Linux-USB APIs,
|
||||||
|
* they've been converted to cpu byte order.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Descriptor types ... USB 2.0 spec table 9.5
|
||||||
|
*/
|
||||||
|
#define USB_DT_DEVICE 0x01
|
||||||
|
#define USB_DT_CONFIG 0x02
|
||||||
|
#define USB_DT_STRING 0x03
|
||||||
|
#define USB_DT_INTERFACE 0x04
|
||||||
|
#define USB_DT_ENDPOINT 0x05
|
||||||
|
#define USB_DT_DEVICE_QUALIFIER 0x06
|
||||||
|
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
||||||
|
#define USB_DT_INTERFACE_POWER 0x08
|
||||||
|
|
||||||
|
/* All standard descriptors have these 2 fields at the beginning */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_descriptor_header {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB_DT_DEVICE: Device descriptor */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_device_descriptor {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
|
||||||
|
__u16 bcdUSB;
|
||||||
|
__u8 bDeviceClass;
|
||||||
|
__u8 bDeviceSubClass;
|
||||||
|
__u8 bDeviceProtocol;
|
||||||
|
__u8 bMaxPacketSize0;
|
||||||
|
__u16 idVendor;
|
||||||
|
__u16 idProduct;
|
||||||
|
__u16 bcdDevice;
|
||||||
|
__u8 iManufacturer;
|
||||||
|
__u8 iProduct;
|
||||||
|
__u8 iSerialNumber;
|
||||||
|
__u8 bNumConfigurations;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define USB_DT_DEVICE_SIZE 18
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Device and/or Interface Class codes
|
||||||
|
* as found in bDeviceClass or bInterfaceClass
|
||||||
|
* and defined by www.usb.org documents
|
||||||
|
*/
|
||||||
|
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||||
|
#define USB_CLASS_AUDIO 1
|
||||||
|
#define USB_CLASS_COMM 2
|
||||||
|
#define USB_CLASS_HID 3
|
||||||
|
#define USB_CLASS_PHYSICAL 5
|
||||||
|
#define USB_CLASS_STILL_IMAGE 6
|
||||||
|
#define USB_CLASS_PRINTER 7
|
||||||
|
#define USB_CLASS_MASS_STORAGE 8
|
||||||
|
#define USB_CLASS_HUB 9
|
||||||
|
#define USB_CLASS_CDC_DATA 0x0a
|
||||||
|
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
|
||||||
|
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
|
||||||
|
#define USB_CLASS_APP_SPEC 0xfe
|
||||||
|
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB_DT_CONFIG: Configuration descriptor information.
|
||||||
|
*
|
||||||
|
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
|
||||||
|
* descriptor type is different. Highspeed-capable devices can look
|
||||||
|
* different depending on what speed they're currently running. Only
|
||||||
|
* devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
|
||||||
|
* descriptors.
|
||||||
|
*/
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_config_descriptor {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
|
||||||
|
__u16 wTotalLength;
|
||||||
|
__u8 bNumInterfaces;
|
||||||
|
__u8 bConfigurationValue;
|
||||||
|
__u8 iConfiguration;
|
||||||
|
__u8 bmAttributes;
|
||||||
|
__u8 bMaxPower;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define USB_DT_CONFIG_SIZE 9
|
||||||
|
|
||||||
|
/* from config descriptor bmAttributes */
|
||||||
|
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
|
||||||
|
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
|
||||||
|
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB_DT_STRING: String descriptor */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_string_descriptor {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
|
||||||
|
__u16 wData[1]; /* UTF-16LE encoded */
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/* note that "string" zero is special, it holds language codes that
|
||||||
|
* the device supports, not Unicode characters.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB_DT_INTERFACE: Interface descriptor */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_interface_descriptor {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
|
||||||
|
__u8 bInterfaceNumber;
|
||||||
|
__u8 bAlternateSetting;
|
||||||
|
__u8 bNumEndpoints;
|
||||||
|
__u8 bInterfaceClass;
|
||||||
|
__u8 bInterfaceSubClass;
|
||||||
|
__u8 bInterfaceProtocol;
|
||||||
|
__u8 iInterface;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define USB_DT_INTERFACE_SIZE 9
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB_DT_ENDPOINT: Endpoint descriptor */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_endpoint_descriptor {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
|
||||||
|
__u8 bEndpointAddress;
|
||||||
|
__u8 bmAttributes;
|
||||||
|
__u16 wMaxPacketSize;
|
||||||
|
__u8 bInterval;
|
||||||
|
|
||||||
|
// NOTE: these two are _only_ in audio endpoints.
|
||||||
|
// use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof.
|
||||||
|
__u8 bRefresh;
|
||||||
|
__u8 bSynchAddress;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define USB_DT_ENDPOINT_SIZE 7
|
||||||
|
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Endpoints
|
||||||
|
*/
|
||||||
|
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
||||||
|
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||||
|
|
||||||
|
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
||||||
|
#define USB_ENDPOINT_XFER_CONTROL 0
|
||||||
|
#define USB_ENDPOINT_XFER_ISOC 1
|
||||||
|
#define USB_ENDPOINT_XFER_BULK 2
|
||||||
|
#define USB_ENDPOINT_XFER_INT 3
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
||||||
|
#pragma pack(1)
|
||||||
|
struct usb_qualifier_descriptor {
|
||||||
|
__u8 bLength;
|
||||||
|
__u8 bDescriptorType;
|
||||||
|
|
||||||
|
__u16 bcdUSB;
|
||||||
|
__u8 bDeviceClass;
|
||||||
|
__u8 bDeviceSubClass;
|
||||||
|
__u8 bDeviceProtocol;
|
||||||
|
__u8 bMaxPacketSize0;
|
||||||
|
__u8 bNumConfigurations;
|
||||||
|
__u8 bRESERVED;
|
||||||
|
}; //__attribute__ ((packed));
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USB 2.0 defines three speeds, here's how Linux identifies them */
|
||||||
|
|
||||||
|
enum usb_device_speed {
|
||||||
|
USB_SPEED_UNKNOWN = 0, /* enumerating */
|
||||||
|
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
|
||||||
|
USB_SPEED_HIGH /* usb 2.0 */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum usb_device_state {
|
||||||
|
/* NOTATTACHED isn't in the USB spec, and this state acts
|
||||||
|
* the same as ATTACHED ... but it's clearer this way.
|
||||||
|
*/
|
||||||
|
USB_STATE_NOTATTACHED = 0,
|
||||||
|
|
||||||
|
/* the chapter 9 device states */
|
||||||
|
USB_STATE_ATTACHED,
|
||||||
|
USB_STATE_POWERED,
|
||||||
|
USB_STATE_DEFAULT, /* limited function */
|
||||||
|
USB_STATE_ADDRESS,
|
||||||
|
USB_STATE_CONFIGURED, /* most functions */
|
||||||
|
|
||||||
|
USB_STATE_SUSPENDED
|
||||||
|
|
||||||
|
/* NOTE: there are actually four different SUSPENDED
|
||||||
|
* states, returning to POWERED, DEFAULT, ADDRESS, or
|
||||||
|
* CONFIGURED respectively when SOF tokens flow again.
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __LINUX_USB_CH9_H */
|
|
@ -0,0 +1,782 @@
|
||||||
|
/*
|
||||||
|
* linux-wrapper.h
|
||||||
|
*
|
||||||
|
* Hard coded Linux kernel replacements for x86
|
||||||
|
*
|
||||||
|
* (c) 2003 Georg Acher (georg@acher.org)
|
||||||
|
*
|
||||||
|
* Emulation of:
|
||||||
|
* typedefs
|
||||||
|
* structs
|
||||||
|
* macros
|
||||||
|
*
|
||||||
|
* All structs and prototypes are based on kernel source 2.5.72
|
||||||
|
*
|
||||||
|
* #include <standard-GPL-header.h>
|
||||||
|
*/
|
||||||
|
#ifndef __LINUX_WRAPPER_H__
|
||||||
|
#define __LINUX_WRAPPER_H__
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Typedefs */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
#define __inline__ __inline
|
||||||
|
#include <xlibc/ansidecl.h>
|
||||||
|
|
||||||
|
typedef unsigned int __u32;
|
||||||
|
typedef __u32 u32;
|
||||||
|
typedef unsigned short __u16;
|
||||||
|
typedef __u16 u16;
|
||||||
|
typedef unsigned char __u8;
|
||||||
|
typedef __u8 u8;
|
||||||
|
|
||||||
|
typedef short s16;
|
||||||
|
|
||||||
|
typedef u32 dma_addr_t;
|
||||||
|
|
||||||
|
typedef int spinlock_t;
|
||||||
|
typedef int atomic_t;
|
||||||
|
#ifndef STANDALONE
|
||||||
|
typedef int mode_t;
|
||||||
|
typedef int pid_t;
|
||||||
|
typedef int ssize_t;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
typedef int irqreturn_t;
|
||||||
|
typedef unsigned long kernel_ulong_t;
|
||||||
|
|
||||||
|
typedef int wait_queue_head_t;
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Stuff from xbox/linux environment */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "list.h"
|
||||||
|
|
||||||
|
#ifndef STANDALONE
|
||||||
|
#ifdef MODULE
|
||||||
|
typedef int size_t;
|
||||||
|
#define NULL ((void*)0)
|
||||||
|
extern void * memset(void *,int,unsigned int);
|
||||||
|
extern void * memcpy(void *,const void *,unsigned int);
|
||||||
|
#if 0
|
||||||
|
extern char * strcpy(char *,const char *);
|
||||||
|
#else
|
||||||
|
static inline char * strcpy(char * dest,const char *src)
|
||||||
|
{
|
||||||
|
int d0, d1, d2;
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"1:\tlodsb\n\t"
|
||||||
|
"stosb\n\t"
|
||||||
|
"testb %%al,%%al\n\t"
|
||||||
|
"jne 1b"
|
||||||
|
: "=&S" (d0), "=&D" (d1), "=&a" (d2)
|
||||||
|
:"0" (src),"1" (dest) : "memory");
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
extern size_t strlen(const char *);
|
||||||
|
|
||||||
|
extern int memcmp(const void *,const void *,unsigned int);
|
||||||
|
|
||||||
|
#else
|
||||||
|
//#include "boot.h"
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "consts.h"
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* General structs */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
struct timer_list {
|
||||||
|
void (*function)(unsigned long);
|
||||||
|
unsigned long data;
|
||||||
|
int expires;
|
||||||
|
struct list_head timer_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct work_struct {
|
||||||
|
void (*func)(void *);
|
||||||
|
};
|
||||||
|
struct device {
|
||||||
|
char name[128];
|
||||||
|
struct bus_type *bus;
|
||||||
|
int dma_mask;
|
||||||
|
char bus_id[16];
|
||||||
|
struct device_driver* driver;
|
||||||
|
void *driver_data;
|
||||||
|
struct device *parent;
|
||||||
|
struct list_head driver_list;
|
||||||
|
void (*release)(struct device * dev);
|
||||||
|
};
|
||||||
|
struct class_device{int a;};
|
||||||
|
struct semaphore{int a;};
|
||||||
|
|
||||||
|
struct device_driver{
|
||||||
|
char *name;
|
||||||
|
struct bus_type *bus;
|
||||||
|
int (*probe) (struct device * dev);
|
||||||
|
int (*remove) (struct device * dev);
|
||||||
|
struct list_head devices;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bus_type {
|
||||||
|
char * name;
|
||||||
|
int (*match)(struct device * dev, struct device_driver * drv);
|
||||||
|
struct device * (*add) (struct device * parent, char * bus_id);
|
||||||
|
int (*hotplug) (struct device *dev, char **envp,
|
||||||
|
int num_envp, char *buffer, int buffer_size);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dummy_process
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pt_regs
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
};
|
||||||
|
struct completion {
|
||||||
|
unsigned int done;
|
||||||
|
wait_queue_head_t wait;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* from mod_devicetable.h */
|
||||||
|
|
||||||
|
struct usb_device_id {
|
||||||
|
/* which fields to match against? */
|
||||||
|
__u16 match_flags;
|
||||||
|
|
||||||
|
/* Used for product specific matches; range is inclusive */
|
||||||
|
__u16 idVendor;
|
||||||
|
__u16 idProduct;
|
||||||
|
__u16 bcdDevice_lo;
|
||||||
|
__u16 bcdDevice_hi;
|
||||||
|
|
||||||
|
/* Used for device class matches */
|
||||||
|
__u8 bDeviceClass;
|
||||||
|
__u8 bDeviceSubClass;
|
||||||
|
__u8 bDeviceProtocol;
|
||||||
|
|
||||||
|
/* Used for interface class matches */
|
||||||
|
__u8 bInterfaceClass;
|
||||||
|
__u8 bInterfaceSubClass;
|
||||||
|
__u8 bInterfaceProtocol;
|
||||||
|
|
||||||
|
/* not matched against */
|
||||||
|
kernel_ulong_t driver_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Some useful macros to use to create struct usb_device_id */
|
||||||
|
#define USB_DEVICE_ID_MATCH_VENDOR 0x0001
|
||||||
|
#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
|
||||||
|
#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
|
||||||
|
#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
|
||||||
|
#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
|
||||||
|
#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
|
||||||
|
#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
|
||||||
|
#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
|
||||||
|
#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
|
||||||
|
#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* imported functions from top-level */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void* zxmalloc(size_t);
|
||||||
|
void zxfree(void*);
|
||||||
|
void zxprintf(char* fmt, ...);
|
||||||
|
int zxsprintf(char *buffer, char* fmt, ...);
|
||||||
|
//void zxsprintf(char *buffer, char* fmt, ...);
|
||||||
|
int zxsnprintf(char *buffer, size_t s, char* fmt, ...);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* PCI structs (taken from linux/pci.h et al., but slightly modified) */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
struct pci_dev {
|
||||||
|
int vendor;
|
||||||
|
int device;
|
||||||
|
struct pci_bus *bus;
|
||||||
|
int irq;
|
||||||
|
char *slot_name;
|
||||||
|
struct device dev;
|
||||||
|
int base[4];
|
||||||
|
int flags[4];
|
||||||
|
void * data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pci_bus {
|
||||||
|
unsigned char number;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pci_device_id {
|
||||||
|
__u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
|
||||||
|
__u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
|
||||||
|
__u32 class, class_mask; /* (class,subclass,prog-if) triplet */
|
||||||
|
kernel_ulong_t driver_data; /* Data private to the driver */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pci_driver {
|
||||||
|
struct list_head node;
|
||||||
|
char *name;
|
||||||
|
const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
|
||||||
|
int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
|
||||||
|
void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
|
||||||
|
int (*save_state) (struct pci_dev *dev, u32 state); /* Save Device Context */
|
||||||
|
int (*suspend) (struct pci_dev *dev, u32 state); /* Device suspended */
|
||||||
|
int (*resume) (struct pci_dev *dev); /* Device woken up */
|
||||||
|
int (*enable_wake) (struct pci_dev *dev, u32 state, int enable); /* Enable wake event */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct scatterlist
|
||||||
|
{
|
||||||
|
int page;
|
||||||
|
int offset;
|
||||||
|
int length;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct usbdevfs_hub_portinfo
|
||||||
|
{
|
||||||
|
int nports;
|
||||||
|
int port[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* constant defines */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define TASK_UNINTERRUPTIBLE 0
|
||||||
|
#define HZ 100 /* Don't rely on that... */
|
||||||
|
#define KERN_DEBUG "DBG: "
|
||||||
|
#define KERN_ERR "ERR: "
|
||||||
|
#define KERN_WARNING "WRN: "
|
||||||
|
#define KERN_INFO "INF: "
|
||||||
|
#define GFP_KERNEL 0
|
||||||
|
#define GFP_ATOMIC 0
|
||||||
|
#define GFP_NOIO 0
|
||||||
|
#define SLAB_ATOMIC 0
|
||||||
|
#define PCI_ANY_ID (~0)
|
||||||
|
#define SIGKILL 9
|
||||||
|
#define THIS_MODULE 0
|
||||||
|
#define PAGE_SIZE 4096
|
||||||
|
|
||||||
|
|
||||||
|
#define CLONE_FS 0
|
||||||
|
#define CLONE_FILES 0
|
||||||
|
#define CLONE_SIGHAND 0
|
||||||
|
#define PF_FREEZE 0
|
||||||
|
#define PF_IOTHREAD 0
|
||||||
|
|
||||||
|
|
||||||
|
#define USBDEVFS_HUB_PORTINFO 1234
|
||||||
|
#define SA_SHIRQ 0
|
||||||
|
|
||||||
|
#undef PCI_COMMAND
|
||||||
|
#define PCI_COMMAND 0
|
||||||
|
#undef PCI_COMMAND_MASTER
|
||||||
|
#define PCI_COMMAND_MASTER 0
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Module/export macros */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define MODULE_AUTHOR(a)
|
||||||
|
#define MODULE_DESCRIPTION(a)
|
||||||
|
#define MODULE_LICENSE(a)
|
||||||
|
#define MODULE_DEVICE_TABLE(type,name) void* module_table_##name=&name
|
||||||
|
|
||||||
|
#define __devinit
|
||||||
|
#define __exit
|
||||||
|
#define __init
|
||||||
|
#define __devinitdata
|
||||||
|
#define module_init(x) static void module_init_##x(void){ x();}
|
||||||
|
#define module_exit(x) static void module_exit_##x(void){ x();}
|
||||||
|
#define EXPORT_SYMBOL_GPL(x)
|
||||||
|
#define EXPORT_SYMBOL(x)
|
||||||
|
|
||||||
|
#define __setup(x,y) int setup_##y=(int)y
|
||||||
|
#define subsys_initcall(x) void subsys_##x(void){x();}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Access macros */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define dev_get_drvdata(a) (a)->driver_data
|
||||||
|
#define dev_set_drvdata(a,b) (a)->driver_data=(b)
|
||||||
|
|
||||||
|
#define __io_virt(x) ((void *)(x))
|
||||||
|
#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
|
||||||
|
#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
|
||||||
|
#define likely(x) (x)
|
||||||
|
#define unlikely(x) (x)
|
||||||
|
#define prefetch(x) 1
|
||||||
|
|
||||||
|
/* The kernel macro for list_for_each_entry makes nonsense (have no clue
|
||||||
|
* why, this is just the same definition...) */
|
||||||
|
|
||||||
|
#undef list_for_each_entry
|
||||||
|
/*
|
||||||
|
#define list_for_each_entry(pos, head, member) \
|
||||||
|
for (pos = list_entry((head)->next, pos, member), \
|
||||||
|
1; \
|
||||||
|
&pos->member != (head); \
|
||||||
|
pos = list_entry(pos->member.next, pos, member), \
|
||||||
|
1)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define list_for_each_entry(pos, head, member) \
|
||||||
|
for (pos = list_entry((head)->next, typeof(*pos), member), \
|
||||||
|
prefetch(pos->member.next); \
|
||||||
|
&pos->member != (head); \
|
||||||
|
pos = list_entry(pos->member.next, typeof(*pos), member), \
|
||||||
|
prefetch(pos->member.next))
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* function wrapper macros */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
#define kmalloc(x,y) zxmalloc(x)
|
||||||
|
#define kfree(x) zxfree(x)
|
||||||
|
|
||||||
|
// #define sprintf(a,b,format, arg...) zxsprintf((a),(b),format, ## arg)
|
||||||
|
// #define snprintf(a,b,format, arg...) zxsnprintf((a),(b),format, ##arg)
|
||||||
|
// #define printk(format, arg...) zxprintf(format, ## arg)
|
||||||
|
// #define BUG(...) do {} while(0)
|
||||||
|
|
||||||
|
/* Locks & friends */
|
||||||
|
|
||||||
|
#define DECLARE_MUTEX(x) struct semaphore x
|
||||||
|
#define init_MUTEX(x)
|
||||||
|
|
||||||
|
#define SPIN_LOCK_UNLOCKED 0
|
||||||
|
#define spin_lock_init(a) do {} while(0)
|
||||||
|
#define spin_lock(a) *(int*)a=1
|
||||||
|
#define spin_unlock(a) do {} while(0)
|
||||||
|
|
||||||
|
#define spin_lock_irqsave(a,b) b=0
|
||||||
|
#define spin_unlock_irqrestore(a,b)
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
|
||||||
|
#define local_irq_restore(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
|
||||||
|
#else
|
||||||
|
#define local_irq_save(x) do {} while(0)
|
||||||
|
#define local_irq_restore(x) do {} while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define atomic_inc(x) *(x)+=1
|
||||||
|
#define atomic_dec(x) *(x)-=1
|
||||||
|
#define atomic_dec_and_test(x) (*(x)-=1,(*(x))==0)
|
||||||
|
#define atomic_set(x,a) *(x)=a
|
||||||
|
#define atomic_read(x) *(x)
|
||||||
|
#define ATOMIC_INIT(x) (x)
|
||||||
|
|
||||||
|
#define down(x) do {} while(0)
|
||||||
|
#define up(x) do {} while(0)
|
||||||
|
#define down_trylock(a) 0
|
||||||
|
|
||||||
|
#define down_read(a) do {} while(0)
|
||||||
|
#define up_read(a) do {} while(0)
|
||||||
|
|
||||||
|
#define DECLARE_WAIT_QUEUE_HEAD(x) int x
|
||||||
|
|
||||||
|
#define DECLARE_COMPLETION(x) struct completion x
|
||||||
|
|
||||||
|
/* driver */
|
||||||
|
|
||||||
|
#define driver_unregister(a) do {} while(0)
|
||||||
|
#define put_device(a) do {} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
/* PCI */
|
||||||
|
#define pci_pool_create(a,b,c,d,e) (void*)1
|
||||||
|
|
||||||
|
#define pci_pool_alloc(a,b,c) my_pci_pool_alloc(a,b,c)
|
||||||
|
|
||||||
|
static void __inline *my_pci_pool_alloc(void* pool, size_t size,
|
||||||
|
dma_addr_t *dma_handle)
|
||||||
|
{
|
||||||
|
void* a;
|
||||||
|
a=kmalloc(size,0); //FIXME
|
||||||
|
#ifdef MODULE
|
||||||
|
*dma_handle=((u32)a)&0xfffffff;
|
||||||
|
#else
|
||||||
|
*dma_handle=(u32)a;
|
||||||
|
#endif
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define pci_pool_free(a,b,c) kfree(b)
|
||||||
|
#define pci_alloc_consistent(a,b,c) my_pci_alloc_consistent(a,b,c)
|
||||||
|
|
||||||
|
static void __inline *my_pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
|
||||||
|
dma_addr_t *dma_handle)
|
||||||
|
{
|
||||||
|
void* a;
|
||||||
|
|
||||||
|
a=kmalloc(size+256,0); //FIXME
|
||||||
|
a=(void*)(((int)a+255)&~255); // 256 alignment
|
||||||
|
*dma_handle=((u32)a)&0xfffffff;
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define pci_free_consistent(a,b,c,d) kfree(c)
|
||||||
|
#define pci_pool_destroy(a) do {} while(0)
|
||||||
|
|
||||||
|
#define pci_module_init(x) my_pci_module_init(x)
|
||||||
|
int my_pci_module_init(struct pci_driver *x);
|
||||||
|
|
||||||
|
#define pci_unregister_driver(a) do {} while(0)
|
||||||
|
|
||||||
|
#define bus_register(a) do {} while(0)
|
||||||
|
#define bus_unregister(a) do {} while(0)
|
||||||
|
|
||||||
|
#define dma_map_single(a,b,c,d) ((u32)(b)&0xfffffff)
|
||||||
|
#define dma_unmap_single(a,b,c,d) do {} while(0)
|
||||||
|
#define pci_unmap_single(a,b,c,d) do {} while(0)
|
||||||
|
#define dma_sync_single(a,b,c,d) do {} while(0)
|
||||||
|
#define dma_sync_sg(a,b,c,d) do {} while(0)
|
||||||
|
#define dma_map_sg(a,b,c,d) 0
|
||||||
|
#define dma_unmap_sg(a,b,c,d) do {} while(0)
|
||||||
|
|
||||||
|
#define usb_create_driverfs_dev_files(a) do {} while(0)
|
||||||
|
#define usb_create_driverfs_intf_files(a) do {} while(0)
|
||||||
|
#define sg_dma_address(x) ((u32)((x)->page*4096 + (x)->offset))
|
||||||
|
#define sg_dma_len(x) ((x)->length)
|
||||||
|
|
||||||
|
#define page_address(x) ((void*)(x/4096))
|
||||||
|
|
||||||
|
#define DMA_TO_DEVICE 0
|
||||||
|
#define DMA_FROM_DEVICE 0
|
||||||
|
#define PCI_DMA_TODEVICE
|
||||||
|
#define PCI_DMA_FROMDEVICE
|
||||||
|
#define PCI_DMA_TODEVICE
|
||||||
|
|
||||||
|
#define PCI_ROM_RESOURCE 0
|
||||||
|
#define IORESOURCE_IO 1
|
||||||
|
|
||||||
|
#define DECLARE_WAITQUEUE(a,b) wait_queue_head_t a=0
|
||||||
|
#define init_waitqueue_head(a) do {} while(0)
|
||||||
|
#define add_wait_queue(a,b) do {} while(0)
|
||||||
|
#define remove_wait_queue(a,b) do {} while(0)
|
||||||
|
|
||||||
|
// BB - Not sure FIXME
|
||||||
|
#define wmb() //__asm__ __volatile__ ("": : :"memory")
|
||||||
|
#define rmb() //__asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
|
||||||
|
|
||||||
|
#define in_interrupt() 0
|
||||||
|
|
||||||
|
#define init_completion(x) (x)->done=0
|
||||||
|
#define wait_for_completion(x) my_wait_for_completion(x)
|
||||||
|
void my_wait_for_completion(struct completion*);
|
||||||
|
|
||||||
|
#define IRQ_NONE 0
|
||||||
|
#define IRQ_HANDLED 1
|
||||||
|
|
||||||
|
#define INIT_WORK(a,b,c) (a)->func=b
|
||||||
|
|
||||||
|
#define set_current_state(a) do {} while(0)
|
||||||
|
|
||||||
|
#define might_sleep() do {} while(0)
|
||||||
|
#define daemonize(a) do {} while(0)
|
||||||
|
#define allow_signal(a) do {} while(0)
|
||||||
|
#define wait_event_interruptible(x,y) do {} while(0)
|
||||||
|
#define flush_scheduled_work() do {} while(0)
|
||||||
|
#define refrigerator(x) do {} while(0)
|
||||||
|
#define signal_pending(x) 1 // fall through threads
|
||||||
|
#define complete_and_exit(a,b) return 0
|
||||||
|
|
||||||
|
#define kill_proc(a,b,c) 0
|
||||||
|
#define yield() do {} while(0)
|
||||||
|
#define cpu_relax() do {} while(0)
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Kernel macros */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define LINUX_VERSION_CODE 0x020572
|
||||||
|
#define UTS_SYSNAME "XBOX"
|
||||||
|
#define UTS_RELEASE "----"
|
||||||
|
|
||||||
|
/* from linux/kernel.h */
|
||||||
|
#define max_t(type,x,y) \
|
||||||
|
({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
|
||||||
|
|
||||||
|
#define min_t(type,x,y) \
|
||||||
|
({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
|
||||||
|
|
||||||
|
#define container_of(ptr1, type1, member) ({ \
|
||||||
|
const typeof( ((type1 *)0)->member ) *__mptr = (ptr1); \
|
||||||
|
(type1 *)( (char *)__mptr - offsetof(type1,member) );})
|
||||||
|
|
||||||
|
|
||||||
|
/* from linux/stddef.h */
|
||||||
|
|
||||||
|
#undef offsetof
|
||||||
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Conversion macros */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define __constant_cpu_to_le32(x) (x)
|
||||||
|
#define cpu_to_le16(x) (x)
|
||||||
|
#define le16_to_cpu(x) (x)
|
||||||
|
#define cpu_to_le32(x) (x)
|
||||||
|
#define cpu_to_le32p(x) (*(__u32*)(x))
|
||||||
|
#define le32_to_cpup(x) (*(__u32*)(x))
|
||||||
|
#define le32_to_cpu(x) ((u32)x)
|
||||||
|
#define le16_to_cpus(x) do {} while (0)
|
||||||
|
#define le16_to_cpup(x) (*(__u16*)(x))
|
||||||
|
#define cpu_to_le16p(x) (*(__u16*)(x))
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Debug output */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
#ifdef DEBUG_MODE
|
||||||
|
#define dev_printk(lvl,x,f,arg...) printk(f, ## arg)
|
||||||
|
#define dev_dbg(x,f,arg...) do {} while (0) //printk(f, ## arg)
|
||||||
|
#define dev_info(x,f,arg...) printk(f,## arg)
|
||||||
|
#define dev_warn(x,f,arg...) printk(f,## arg)
|
||||||
|
#define dev_err(x,f,arg...) printk(f,## arg)
|
||||||
|
#define pr_debug(x,f,arg...) printk(f,## arg)
|
||||||
|
#define usbprintk printk
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifndef DEBUG_MODE
|
||||||
|
#define dev_printk(lvl,x,f,arg...) do {} while (0)
|
||||||
|
#define dev_dbg(x,f,arg...) do {} while (0) //printk(f, ## arg)
|
||||||
|
#define dev_info(x,f,arg...) do {} while (0)
|
||||||
|
#define dev_warn(x,f,arg...) do {} while (0)
|
||||||
|
#define dev_err(x,f,arg...) do {} while (0)
|
||||||
|
#define pr_debug(x,f,arg...) do {} while (0)
|
||||||
|
#define usbprintk
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define PCI_DEVFN(a,b) 0
|
||||||
|
#define PCI_SLOT(a) 0
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Stuff from kernel */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "asm/errno.h"
|
||||||
|
#include "linux/bitops.h"
|
||||||
|
#include "asm/pci_ids.h"
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* global variables */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define jiffies my_jiffies
|
||||||
|
extern int my_jiffies;
|
||||||
|
#define current my_current
|
||||||
|
extern struct dummy_process *my_current;
|
||||||
|
|
||||||
|
extern struct list_head interrupt_list;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Function prototypes */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
void usb_hcd_pci_remove (struct pci_dev *dev);
|
||||||
|
|
||||||
|
#define wait_ms(x) my_wait_ms(x)
|
||||||
|
void my_wait_ms(unsigned int ms);
|
||||||
|
|
||||||
|
#define udelay(x) my_udelay(x)
|
||||||
|
void my_udelay(unsigned int a);
|
||||||
|
|
||||||
|
#define mdelay(x) my_mdelay(x);
|
||||||
|
void my_mdelay(unsigned int a);
|
||||||
|
|
||||||
|
#define pci_find_slot(a,b) my_pci_find_slot(a,b)
|
||||||
|
struct pci_dev *my_pci_find_slot(int a,int b);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Timer management */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define MAX_TIMERS 20
|
||||||
|
extern struct timer_list *main_timer_list[MAX_TIMERS];
|
||||||
|
|
||||||
|
static void __inline__ init_timer(struct timer_list* t)
|
||||||
|
{
|
||||||
|
INIT_LIST_HEAD(&t->timer_list);
|
||||||
|
t->function=NULL;
|
||||||
|
t->expires=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __inline__ add_timer(struct timer_list* t)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
for(n=0;n<MAX_TIMERS;n++)
|
||||||
|
if (main_timer_list[n]==0)
|
||||||
|
{
|
||||||
|
main_timer_list[n]=t;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __inline__ del_timer(struct timer_list* t)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
for(n=0;n<MAX_TIMERS;n++)
|
||||||
|
if (main_timer_list[n]==t)
|
||||||
|
{
|
||||||
|
main_timer_list[n]=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void __inline__ del_timer_sync(struct timer_list* t)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
for(n=0;n<MAX_TIMERS;n++)
|
||||||
|
if (main_timer_list[n]==t)
|
||||||
|
{
|
||||||
|
main_timer_list[n]=0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
static void __inline__ mod_timer(struct timer_list* t, int ex)
|
||||||
|
{
|
||||||
|
del_timer(t);
|
||||||
|
t->expires=ex;
|
||||||
|
add_timer(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* Device driver and process related stuff */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static int __inline__ usb_major_init(void){return 0;}
|
||||||
|
static void __inline__ usb_major_cleanup(void){}
|
||||||
|
static void __inline__ schedule_work(void* p){}
|
||||||
|
|
||||||
|
#define device_initialize(x) my_device_initialize(x)
|
||||||
|
void my_device_initialize(struct device *dev);
|
||||||
|
|
||||||
|
#define get_device(x) my_get_device(x)
|
||||||
|
struct device *my_get_device(struct device *dev);
|
||||||
|
|
||||||
|
#define device_add(x) my_device_add(x)
|
||||||
|
int my_device_add(struct device *dev);
|
||||||
|
|
||||||
|
#define driver_register(x) my_driver_register(x)
|
||||||
|
int my_driver_register(struct device_driver *driver);
|
||||||
|
|
||||||
|
#define device_unregister(a) my_device_unregister(a)
|
||||||
|
int my_device_unregister(struct device *dev);
|
||||||
|
|
||||||
|
#define DEVICE_ATTR(a,b,c,d) int xxx_##a
|
||||||
|
#define device_create_file(a,b) do {} while(0)
|
||||||
|
#define device_remove_file(a,b) do {} while(0)
|
||||||
|
|
||||||
|
#define schedule_timeout(x) my_schedule_timeout(x)
|
||||||
|
int my_schedule_timeout(int x);
|
||||||
|
|
||||||
|
#define wake_up(x) my_wake_up(x)
|
||||||
|
void my_wake_up(void*);
|
||||||
|
|
||||||
|
// cannot be mapped via macro due to collision with urb->complete
|
||||||
|
static void __inline__ complete(struct completion *p)
|
||||||
|
{
|
||||||
|
/* Wake up x->wait */
|
||||||
|
p->done++;
|
||||||
|
wake_up(&p->wait);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define kernel_thread(a,b,c) my_kernel_thread(a,b,c)
|
||||||
|
int my_kernel_thread(int (*handler)(void*), void* parm, int flags);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* PCI, simple and inlined... */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
static int __inline__ pci_enable_device(struct pci_dev *dev) {return 0;}
|
||||||
|
|
||||||
|
static unsigned long __inline__ pci_resource_start (struct pci_dev *dev, int x)
|
||||||
|
{
|
||||||
|
return dev->base[x];
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long __inline__ pci_resource_len (struct pci_dev *dev, int x){return 0;}
|
||||||
|
|
||||||
|
static int __inline__ request_mem_region(unsigned long addr, unsigned long len, const char * d){return 1;}
|
||||||
|
|
||||||
|
static void __inline__ *ioremap_nocache(unsigned long addr, unsigned long len)
|
||||||
|
{
|
||||||
|
return (void*)addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __inline__ release_mem_region(unsigned long addr, unsigned long len){return 0;}
|
||||||
|
|
||||||
|
static int __inline__ pci_resource_flags(struct pci_dev *dev, int x)
|
||||||
|
{
|
||||||
|
return dev->flags[x];
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __inline__ request_region(unsigned long addr, unsigned long len, const char * d){return 0;}
|
||||||
|
|
||||||
|
static int __inline__ pci_set_master(struct pci_dev *dev){return 0;}
|
||||||
|
|
||||||
|
static int __inline__ iounmap(void* p){return 0;}
|
||||||
|
|
||||||
|
static int __inline__ release_region(unsigned long addr, unsigned long len){return 0;}
|
||||||
|
|
||||||
|
static int __inline__ pci_set_drvdata(struct pci_dev *dev, void* d)
|
||||||
|
{
|
||||||
|
dev->data=(void*)d;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __inline__ *pci_get_drvdata(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
return dev->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
/* IRQ handling */
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define request_irq(a,b,c,d,e) my_request_irq(a,b,c,d,e)
|
||||||
|
int my_request_irq(unsigned int irq,
|
||||||
|
int (*handler)(int, void *, struct pt_regs *),
|
||||||
|
unsigned long mode, const char *desc, void *data);
|
||||||
|
|
||||||
|
#define free_irq(a,b) my_free_irq(a,b)
|
||||||
|
int free_irq(int irq, void* p);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct my_irqs {
|
||||||
|
int (*handler)(int, void *, struct pt_regs *);
|
||||||
|
int irq;
|
||||||
|
void* data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAX_IRQS 8
|
||||||
|
|
||||||
|
// Exported to top level
|
||||||
|
|
||||||
|
void handle_irqs(int irq);
|
||||||
|
void inc_jiffies(int);
|
||||||
|
void init_wrapper(void);
|
||||||
|
void do_all_timers(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__LINUX_WRAPPER_H__
|
|
@ -0,0 +1,224 @@
|
||||||
|
#ifndef _BOOT_LIST_H
|
||||||
|
#define _BOOT_LIST_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Simple doubly linked list implementation.
|
||||||
|
*
|
||||||
|
* Some of the internal functions ("__xxx") are useful when
|
||||||
|
* manipulating whole lists rather than single entries, as
|
||||||
|
* sometimes we already know the next/prev entries and we can
|
||||||
|
* generate better code by using them directly rather than
|
||||||
|
* using the generic single-entry routines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct list_head {
|
||||||
|
struct list_head *next, *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||||
|
|
||||||
|
#define LIST_HEAD(name) \
|
||||||
|
struct list_head name = LIST_HEAD_INIT(name)
|
||||||
|
|
||||||
|
#define INIT_LIST_HEAD(ptr) do { \
|
||||||
|
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insert a new entry between two known consecutive entries.
|
||||||
|
*
|
||||||
|
* This is only for internal list manipulation where we know
|
||||||
|
* the prev/next entries already!
|
||||||
|
*/
|
||||||
|
static __inline void __list_add(struct list_head *new,
|
||||||
|
struct list_head *prev,
|
||||||
|
struct list_head *next)
|
||||||
|
{
|
||||||
|
next->prev = new;
|
||||||
|
new->next = next;
|
||||||
|
new->prev = prev;
|
||||||
|
prev->next = new;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_add - add a new entry
|
||||||
|
* @new: new entry to be added
|
||||||
|
* @head: list head to add it after
|
||||||
|
*
|
||||||
|
* Insert a new entry after the specified head.
|
||||||
|
* This is good for implementing stacks.
|
||||||
|
*/
|
||||||
|
static __inline void list_add(struct list_head *new, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_add(new, head, head->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_add_tail - add a new entry
|
||||||
|
* @new: new entry to be added
|
||||||
|
* @head: list head to add it before
|
||||||
|
*
|
||||||
|
* Insert a new entry before the specified head.
|
||||||
|
* This is useful for implementing queues.
|
||||||
|
*/
|
||||||
|
static __inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_add(new, head->prev, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete a list entry by making the prev/next entries
|
||||||
|
* point to each other.
|
||||||
|
*
|
||||||
|
* This is only for internal list manipulation where we know
|
||||||
|
* the prev/next entries already!
|
||||||
|
*/
|
||||||
|
static __inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||||
|
{
|
||||||
|
next->prev = prev;
|
||||||
|
prev->next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_del - deletes entry from list.
|
||||||
|
* @entry: the element to delete from the list.
|
||||||
|
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
|
||||||
|
*/
|
||||||
|
static __inline void list_del(struct list_head *entry)
|
||||||
|
{
|
||||||
|
__list_del(entry->prev, entry->next);
|
||||||
|
entry->next = (void *) 0;
|
||||||
|
entry->prev = (void *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_del_init - deletes entry from list and reinitialize it.
|
||||||
|
* @entry: the element to delete from the list.
|
||||||
|
*/
|
||||||
|
static __inline void list_del_init(struct list_head *entry)
|
||||||
|
{
|
||||||
|
__list_del(entry->prev, entry->next);
|
||||||
|
INIT_LIST_HEAD(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_move - delete from one list and add as another's head
|
||||||
|
* @list: the entry to move
|
||||||
|
* @head: the head that will precede our entry
|
||||||
|
*/
|
||||||
|
static __inline void list_move(struct list_head *list, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_del(list->prev, list->next);
|
||||||
|
list_add(list, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_move_tail - delete from one list and add as another's tail
|
||||||
|
* @list: the entry to move
|
||||||
|
* @head: the head that will follow our entry
|
||||||
|
*/
|
||||||
|
static __inline void list_move_tail(struct list_head *list,
|
||||||
|
struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_del(list->prev, list->next);
|
||||||
|
list_add_tail(list, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_empty - tests whether a list is empty
|
||||||
|
* @head: the list to test.
|
||||||
|
*/
|
||||||
|
static __inline int list_empty(struct list_head *head)
|
||||||
|
{
|
||||||
|
return head->next == head;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline void __list_splice(struct list_head *list,
|
||||||
|
struct list_head *head)
|
||||||
|
{
|
||||||
|
struct list_head *first = list->next;
|
||||||
|
struct list_head *last = list->prev;
|
||||||
|
struct list_head *at = head->next;
|
||||||
|
|
||||||
|
first->prev = head;
|
||||||
|
head->next = first;
|
||||||
|
|
||||||
|
last->next = at;
|
||||||
|
at->prev = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_splice - join two lists
|
||||||
|
* @list: the new list to add.
|
||||||
|
* @head: the place to add it in the first list.
|
||||||
|
*/
|
||||||
|
static __inline void list_splice(struct list_head *list, struct list_head *head)
|
||||||
|
{
|
||||||
|
if (!list_empty(list))
|
||||||
|
__list_splice(list, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||||
|
* @list: the new list to add.
|
||||||
|
* @head: the place to add it in the first list.
|
||||||
|
*
|
||||||
|
* The list at @list is reinitialised
|
||||||
|
*/
|
||||||
|
static __inline void list_splice_init(struct list_head *list,
|
||||||
|
struct list_head *head)
|
||||||
|
{
|
||||||
|
if (!list_empty(list)) {
|
||||||
|
__list_splice(list, head);
|
||||||
|
INIT_LIST_HEAD(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_entry - get the struct for this entry
|
||||||
|
* @ptr: the &struct list_head pointer.
|
||||||
|
* @type: the type of the struct this is embedded in.
|
||||||
|
* @member: the name of the list_struct within the struct.
|
||||||
|
*/
|
||||||
|
#define list_entry(ptr, type, member) \
|
||||||
|
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each - iterate over a list
|
||||||
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
|
* @head: the head for your list.
|
||||||
|
*/
|
||||||
|
#define list_for_each(pos, head) \
|
||||||
|
for (pos = (head)->next; pos != (head); \
|
||||||
|
pos = pos->next)
|
||||||
|
/**
|
||||||
|
* list_for_each_prev - iterate over a list backwards
|
||||||
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
|
* @head: the head for your list.
|
||||||
|
*/
|
||||||
|
#define list_for_each_prev(pos, head) \
|
||||||
|
for (pos = (head)->prev; pos != (head); \
|
||||||
|
pos = pos->prev)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||||
|
* @pos: the &struct list_head to use as a loop counter.
|
||||||
|
* @n: another &struct list_head to use as temporary storage
|
||||||
|
* @head: the head for your list.
|
||||||
|
*/
|
||||||
|
#define list_for_each_safe(pos, n, head) \
|
||||||
|
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||||
|
pos = n, n = pos->next)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list_for_each_entry - iterate over list of given type
|
||||||
|
* @pos: the type * to use as a loop counter.
|
||||||
|
* @head: the head for your list.
|
||||||
|
* @member: the name of the list_struct within the struct.
|
||||||
|
*/
|
||||||
|
#define list_for_each_entry(pos, head, member) \
|
||||||
|
for (pos = list_entry((head)->next, typeof(*pos), member) \
|
||||||
|
&pos->member != (head); \
|
||||||
|
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "linux_wrapper.h"
|
||||||
|
#define __KERNEL__
|
||||||
|
#undef CONFIG_PCI
|
||||||
|
#define CONFIG_PCI
|
||||||
|
|
||||||
|
#include "linux/usb.h"
|
|
@ -0,0 +1,33 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xusb.h
|
||||||
|
// *
|
||||||
|
// * note : Xbox USB Support
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XUSB_H
|
||||||
|
#define XUSB_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * Xbox USB Support by Georg Archer
|
||||||
|
// ******************************************************************
|
||||||
|
#include "linux_wrapper.h"
|
||||||
|
#include "linux/usb.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xvga.h
|
||||||
|
// *
|
||||||
|
// * note : XBox VGA
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XVGA_H
|
||||||
|
#define XVGA_H
|
||||||
|
|
||||||
|
#include "openxdk.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * xvga video modes
|
||||||
|
// ******************************************************************
|
||||||
|
typedef enum _xvga_mode
|
||||||
|
{
|
||||||
|
XVGA_MODE_256x240 = 0,
|
||||||
|
XVGA_MODE_320x240,
|
||||||
|
XVGA_MODE_320x200
|
||||||
|
}
|
||||||
|
xvga_mode;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * set video mode
|
||||||
|
// ******************************************************************
|
||||||
|
extern void xvga_setmode(xvga_mode mode);
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * wait for vblank / end vblank
|
||||||
|
// ******************************************************************
|
||||||
|
extern void xvga_wait_vblank();
|
||||||
|
extern void xvga_wait_vblank_end();
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,122 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xvga_internal.h
|
||||||
|
// *
|
||||||
|
// * note : XBox VGA
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XVGA_DEF_H
|
||||||
|
#define XVGA_DEF_H
|
||||||
|
|
||||||
|
#include "openxdk.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * vga register flat addresses
|
||||||
|
// ******************************************************************
|
||||||
|
static volatile char * const P_ATTR_REG_INDEX = (char * const)0xFD6013c0;
|
||||||
|
static volatile char * const P_ATTR_REG_DATA = (char * const)0xFD6013c1;
|
||||||
|
static volatile char * const P_CRTC_REG_INDEX = (char * const)0xFD6013d4;
|
||||||
|
static volatile char * const P_CRTC_REG_DATA = (char * const)0xFD6013d5;
|
||||||
|
static volatile char * const P_VERTICAL_BLANK = (char * const)0xFD6013DA;
|
||||||
|
static volatile char * const P_GRA_REG_INDEX = (char * const)0xFD0c03ce;
|
||||||
|
static volatile char * const P_GRA_REG_DATA = (char * const)0xFD0c03cf;
|
||||||
|
static volatile char * const P_SEQ_REG_INDEX = (char * const)0xFD0c03c4;
|
||||||
|
static volatile char * const P_SEQ_REG_DATA = (char * const)0xFD0c03c5;
|
||||||
|
static volatile char * const P_MISC_REG = (char * const)0xFD0c03c2;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * vga_reg
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _vga_reg
|
||||||
|
{
|
||||||
|
unsigned short port;
|
||||||
|
unsigned char index;
|
||||||
|
unsigned char value;
|
||||||
|
}
|
||||||
|
vga_reg;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * vga mode definitions
|
||||||
|
// ******************************************************************
|
||||||
|
extern vga_reg xvga_mode_256x240[];
|
||||||
|
extern vga_reg xvga_mode_320x240[];
|
||||||
|
extern vga_reg xvga_mode_320x200[];
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * mode sizes
|
||||||
|
// ******************************************************************
|
||||||
|
extern uint32 MODE256x240SIZE;
|
||||||
|
extern uint32 MODE320x240SIZE;
|
||||||
|
extern uint32 MODE320x200SIZE;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * NVidia registers base / offsets
|
||||||
|
// ******************************************************************
|
||||||
|
#define NV_REGBASE (0xFD000000)
|
||||||
|
#define NV_PMC (0x00000000)
|
||||||
|
#define NV_PFIFO (0x00002000)
|
||||||
|
#define NV_FB (0x00100000)
|
||||||
|
#define NV_EXTDEV (0x00101000)
|
||||||
|
#define NV_CRTC (0x00600000)
|
||||||
|
#define NV_RAMDAC (0x00680000)
|
||||||
|
#define NV_FIFO (0x00800000)
|
||||||
|
#define NV_MISC (0x000C0000)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * vga registers
|
||||||
|
// ******************************************************************
|
||||||
|
static const int ATTR_REG_INDEX = 0x13c0;
|
||||||
|
static const int ATTR_REG_DATA = 0x13c1;
|
||||||
|
static const int CRTC_REG_INDEX = 0x13d4;
|
||||||
|
static const int CRTC_REG_DATA = 0x13d5;
|
||||||
|
static const int FB_REG = 0x0800;
|
||||||
|
static const int VERTICAL_BLANK = 0x13DA;
|
||||||
|
static const int GRA_REG_INDEX = 0x03ce;
|
||||||
|
static const int GRA_REG_DATA = 0x03cf;
|
||||||
|
static const int SEQ_REG_INDEX = 0x03c4;
|
||||||
|
static const int SEQ_REG_DATA = 0x03c5;
|
||||||
|
static const int MISC_REG = 0x03c2;
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * CRTC register accessors
|
||||||
|
// ******************************************************************
|
||||||
|
#define CRTC_READ(a) (*((volatile uint08*)(NV_REGBASE + NV_CRTC + (a))))
|
||||||
|
#define CRTC_READL(a) (*((volatile uint32*)(NV_REGBASE + NV_CRTC + (a))))
|
||||||
|
#define CRTC_WRITE(a,b) *((volatile uint08*)(NV_REGBASE + NV_CRTC + (a))) = (b)
|
||||||
|
#define CRTC_WRITEL(a,b) *((volatile uint32*)(NV_REGBASE + NV_CRTC + (a))) = (b)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * ATTR register accessors
|
||||||
|
// ******************************************************************
|
||||||
|
#define ATTR_READ(a) (*((volatile uint08*)(NV_REGBASE + NV_CRTC + (a))))
|
||||||
|
#define ATTR_READL(a) (*((volatile uint32*)(NV_REGBASE + NV_CRTC + (a))))
|
||||||
|
#define ATTR_WRITE(a,b) *((volatile uint08*)(NV_REGBASE + NV_CRTC + (a))) = (b)
|
||||||
|
#define ATTR_WRITEL(a,b) *((volatile uint32*)(NV_REGBASE + NV_CRTC + (a))) = (b)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * MISC register accessors
|
||||||
|
// ******************************************************************
|
||||||
|
#define MISC_READ(a) (*((volatile uint08*)(NV_REGBASE + NV_MISC + (a))))
|
||||||
|
#define MISC_READL(a) (*((volatile uint32*)(NV_REGBASE + NV_MISC + (a))))
|
||||||
|
#define MISC_WRITE(a,b) *((volatile uint08*)(NV_REGBASE + NV_MISC + (a))) = (b)
|
||||||
|
#define MISC_WRITEL(a,b) *((volatile uint32*)(NV_REGBASE + NV_MISC + (a))) = (b)
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * frame buffer
|
||||||
|
// ******************************************************************
|
||||||
|
#define FRAMEBUFFER ((void*)(0xF0040240))
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,52 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xvga_internal.h
|
||||||
|
// *
|
||||||
|
// * note : XBox VGA
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XVGA_INTERNAL_H
|
||||||
|
#define XVGA_INTERNAL_H
|
||||||
|
|
||||||
|
#include "openxdk.h"
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * vga registers
|
||||||
|
// ******************************************************************
|
||||||
|
static volatile char * const ATTR_REG_INDEX = (char * const)0xFD6013c0;
|
||||||
|
static volatile char * const ATTR_REG_DATA = (char * const)0xFD6013c1;
|
||||||
|
static volatile char * const CRTC_REG_INDEX = (char * const)0xFD6013d4;
|
||||||
|
static volatile char * const CRTC_REG_DATA = (char * const)0xFD6013d5;
|
||||||
|
static volatile char * const GRA_REG_INDEX = (char * const)0xFD0c03ce;
|
||||||
|
static volatile char * const GRA_REG_DATA = (char * const)0xFD0c03cf;
|
||||||
|
static volatile char * const SEQ_REG_INDEX = (char * const)0xFD0c03c4;
|
||||||
|
static volatile char * const SEQ_REG_DATA = (char * const)0xFD0c03c5;
|
||||||
|
static volatile char * const MISC_REG = (char * const)0xFD0c03c2;
|
||||||
|
|
||||||
|
#define XVGA_VBL 0xfd6013da
|
||||||
|
|
||||||
|
// ******************************************************************
|
||||||
|
// * vga_reg
|
||||||
|
// ******************************************************************
|
||||||
|
typedef struct _vga_reg
|
||||||
|
{
|
||||||
|
unsigned short port;
|
||||||
|
unsigned char index;
|
||||||
|
unsigned char value;
|
||||||
|
}
|
||||||
|
vga_reg;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,26 @@
|
||||||
|
// ******************************************************************
|
||||||
|
// *
|
||||||
|
// * proj : OpenXDK
|
||||||
|
// *
|
||||||
|
// * desc : Open Source XBox Development Kit
|
||||||
|
// *
|
||||||
|
// * file : xvga_tables.h
|
||||||
|
// *
|
||||||
|
// * note : XBox VGA
|
||||||
|
// *
|
||||||
|
// ******************************************************************
|
||||||
|
#ifndef XVGA_TABLES_H
|
||||||
|
#define XVGA_TABLES_H
|
||||||
|
|
||||||
|
#include "xvga_internal.h"
|
||||||
|
|
||||||
|
#define MODE256x240SIZE 25
|
||||||
|
extern vga_reg mode_256x240[];
|
||||||
|
|
||||||
|
#define MODE320x240SIZE 25
|
||||||
|
extern vga_reg mode_320x240[];
|
||||||
|
|
||||||
|
#define MODE320x200SIZE 25
|
||||||
|
extern vga_reg mode_320x200[];
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue