add psp gcc 11.2.0 patch
[rofl0r-mmix-cross.git] / patches / newlib-1.20.0-pspsdk.diff
blobec3a4e0d44097e4f4b9ee53e80f3211c2f6cc64d
1 From eecfbdafdcdbb87fac1c4119fb1b1b7537c8ac03 Mon Sep 17 00:00:00 2001
2 From: rofl0r <rofl0r@users.noreply.github.com>
3 Date: Wed, 16 Mar 2022 18:34:21 +0000
4 Subject: [PATCH] add sdk headers
6 diff --git a/newlib/psp/include/arpa/inet.h b/newlib/psp/include/arpa/inet.h
7 new file mode 100644
8 index 0000000..f441b9c
9 --- /dev/null
10 +++ b/newlib/psp/include/arpa/inet.h
11 @@ -0,0 +1,26 @@
12 +/* arpa/inet.h - Functions for converting IP addresses between strings and numbers */
14 +#ifndef _ARPA_INET_H_
15 +#define _ARPA_INET_H_
17 +#ifdef __cplusplus
18 +extern "C" {
19 +#endif
21 +#include <netinet/in.h>
23 +in_addr_t sceNetInetInetAddr(const char *ip);
24 +int sceNetInetInetAton(const char *ip, struct in_addr *in);
25 +const char* sceNetInetInetNtop(int af, const void *src, char *dst, socklen_t cnt);
26 +int sceNetInetInetPton(int af, const char *src, void *dst);
28 +char *inet_ntoa(struct in_addr in);
29 +#define inet_addr sceNetInetInetAddr
30 +#define inet_aton sceNetInetInetAton
31 +#define inet_ntop sceNetInetInetNtop
32 +#define inet_pton sceNetInetInetPton
34 +#ifdef __cplusplus
36 +#endif
37 +#endif /* _ARPA_INET_H_ */
38 diff --git a/newlib/psp/include/as_reg_compat.h b/newlib/psp/include/as_reg_compat.h
39 new file mode 100644
40 index 0000000..346753c
41 --- /dev/null
42 +++ b/newlib/psp/include/as_reg_compat.h
43 @@ -0,0 +1,51 @@
44 +/*
45 + * PSP Software Development Kit - https://github.com/pspdev
46 + * -----------------------------------------------------------------------
47 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
48 + *
49 + * as_reg_compat.h - Register name mapping.
50 + *
51 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
52 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
53 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
54 + *
55 + */
56 +#ifndef __AS_REG_COMPAT_H__
57 +#define __AS_REG_COMPAT_H__
59 +/* register defines for the GNU assembler */
61 +#define zero 0
62 +#define at 1
63 +#define v0 2
64 +#define v1 3
65 +#define a0 4
66 +#define a1 5
67 +#define a2 6
68 +#define a3 7
69 +#define t0 8
70 +#define t1 9
71 +#define t2 10
72 +#define t3 11
73 +#define t4 12
74 +#define t5 13
75 +#define t6 14
76 +#define t7 15
77 +#define s0 16
78 +#define s1 17
79 +#define s2 18
80 +#define s3 19
81 +#define s4 20
82 +#define s5 21
83 +#define s6 22
84 +#define s7 23
85 +#define t8 24
86 +#define t9 25
87 +#define k0 26
88 +#define k1 27
89 +#define gp 28
90 +#define sp 29
91 +#define fp 30
92 +#define ra 31
94 +#endif
95 diff --git a/newlib/psp/include/netdb.h b/newlib/psp/include/netdb.h
96 new file mode 100644
97 index 0000000..bb8cdb4
98 --- /dev/null
99 +++ b/newlib/psp/include/netdb.h
100 @@ -0,0 +1,36 @@
101 +/* Simple gethostbyname and gethostbyaddr replacements, note not thread safe */
102 +#ifndef __NETDB_H__
103 +#define __NETDB_H__
105 +#ifdef __cplusplus
106 +extern "C" {
107 +#endif
109 +#define NETDB_INTERNAL -1 /* see errno */
110 +#define NETDB_SUCCESS 0 /* no problem */
111 +#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
112 +#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
113 +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
114 +#define NO_DATA 4 /* Valid name, no data record of requested type */
115 +#define NO_ADDRESS NO_DATA /* no address, look for MX record */
117 +extern int h_errno;
119 +struct hostent
121 + char *h_name;
122 + char **h_aliases;
123 + int h_addrtype;
124 + int h_length;
125 + char **h_addr_list;
126 + char *h_addr;
129 +struct hostent *gethostbyaddr(const void *addr, int len, int type);
130 +struct hostent *gethostbyname(const char *name);
132 +#ifdef __cplusplus
134 +#endif
136 +#endif
137 diff --git a/newlib/psp/include/netinet/in.h b/newlib/psp/include/netinet/in.h
138 new file mode 100644
139 index 0000000..86134a9
140 --- /dev/null
141 +++ b/newlib/psp/include/netinet/in.h
142 @@ -0,0 +1,280 @@
143 +/* $NetBSD: in.h,v 1.71 2005/08/05 09:21:25 elad Exp $ */
146 + * Copyright (c) 1982, 1986, 1990, 1993
147 + * The Regents of the University of California. All rights reserved.
149 + * Redistribution and use in source and binary forms, with or without
150 + * modification, are permitted provided that the following conditions
151 + * are met:
152 + * 1. Redistributions of source code must retain the above copyright
153 + * notice, this list of conditions and the following disclaimer.
154 + * 2. Redistributions in binary form must reproduce the above copyright
155 + * notice, this list of conditions and the following disclaimer in the
156 + * documentation and/or other materials provided with the distribution.
157 + * 3. Neither the name of the University nor the names of its contributors
158 + * may be used to endorse or promote products derived from this software
159 + * without specific prior written permission.
161 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
162 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
163 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
164 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
165 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
166 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
167 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
168 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
169 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
170 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
171 + * SUCH DAMAGE.
173 + * @(#)in.h 8.3 (Berkeley) 1/3/94
174 + */
177 + * Constants and structures defined by the internet system,
178 + * Per RFC 790, September 1981, and numerous additions.
179 + */
181 +#ifndef _NETINET_IN_H_
182 +#define _NETINET_IN_H_
184 +#ifdef __cplusplus
185 +extern "C" {
186 +#endif
188 +#include <sys/socket.h>
190 +typedef uint32_t in_addr_t;
191 +typedef uint16_t in_port_t;
194 + * Protocols
195 + */
196 +#define IPPROTO_IP 0 /* dummy for IP */
197 +#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */
198 +#define IPPROTO_ICMP 1 /* control message protocol */
199 +#define IPPROTO_IGMP 2 /* group mgmt protocol */
200 +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
201 +#define IPPROTO_IPV4 4 /* IP header */
202 +#define IPPROTO_IPIP 4 /* IP inside IP */
203 +#define IPPROTO_TCP 6 /* tcp */
204 +#define IPPROTO_EGP 8 /* exterior gateway protocol */
205 +#define IPPROTO_PUP 12 /* pup */
206 +#define IPPROTO_UDP 17 /* user datagram protocol */
207 +#define IPPROTO_IDP 22 /* xns idp */
208 +#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
209 +#define IPPROTO_IPV6 41 /* IP6 header */
210 +#define IPPROTO_ROUTING 43 /* IP6 routing header */
211 +#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */
212 +#define IPPROTO_RSVP 46 /* resource reservation */
213 +#define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */
214 +#define IPPROTO_ESP 50 /* encap. security payload */
215 +#define IPPROTO_AH 51 /* authentication header */
216 +#define IPPROTO_MOBILE 55 /* IP Mobility RFC 2004 */
217 +#define IPPROTO_IPV6_ICMP 58 /* IPv6 ICMP */
218 +#define IPPROTO_ICMPV6 58 /* ICMP6 */
219 +#define IPPROTO_NONE 59 /* IP6 no next header */
220 +#define IPPROTO_DSTOPTS 60 /* IP6 destination option */
221 +#define IPPROTO_EON 80 /* ISO cnlp */
222 +#define IPPROTO_ETHERIP 97 /* Ethernet-in-IP */
223 +#define IPPROTO_ENCAP 98 /* encapsulation header */
224 +#define IPPROTO_PIM 103 /* Protocol indep. multicast */
225 +#define IPPROTO_IPCOMP 108 /* IP Payload Comp. Protocol */
226 +#define IPPROTO_VRRP 112 /* VRRP RFC 2338 */
228 +#define IPPROTO_RAW 255 /* raw IP packet */
229 +#define IPPROTO_MAX 256
231 +/* last return value of *_input(), meaning "all job for this pkt is done". */
232 +#define IPPROTO_DONE 257
234 +/* sysctl placeholder for (FAST_)IPSEC */
235 +#define CTL_IPPROTO_IPSEC 258
239 + * Local port number conventions:
241 + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root),
242 + * unless a kernel is compiled with IPNOPRIVPORTS defined.
244 + * When a user does a bind(2) or connect(2) with a port number of zero,
245 + * a non-conflicting local port address is chosen.
247 + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although
248 + * that is settable by sysctl(3); net.inet.ip.anonportmin and
249 + * net.inet.ip.anonportmax respectively.
251 + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
252 + * default assignment range.
254 + * The value IP_PORTRANGE_DEFAULT causes the default behavior.
256 + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT,
257 + * and exists only for FreeBSD compatibility purposes.
259 + * The value IP_PORTRANGE_LOW changes the range to the "low" are
260 + * that is (by convention) restricted to privileged processes.
261 + * This convention is based on "vouchsafe" principles only.
262 + * It is only secure if you trust the remote host to restrict these ports.
263 + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX.
264 + */
266 +#define IPPORT_RESERVED 1024
267 +#define IPPORT_ANONMIN 49152
268 +#define IPPORT_ANONMAX 65535
269 +#define IPPORT_RESERVEDMIN 600
270 +#define IPPORT_RESERVEDMAX (IPPORT_RESERVED-1)
273 + * Internet address (a structure for historical reasons)
274 + */
275 +struct in_addr {
276 + in_addr_t s_addr;
277 +} __attribute__((__packed__));
279 +#define __IPADDR(x) ((uint32_t)(x))
281 +#define IN_CLASSA(i) (((uint32_t)(i) & __IPADDR(0x80000000)) == \
282 + __IPADDR(0x00000000))
283 +#define IN_CLASSA_NET __IPADDR(0xff000000)
284 +#define IN_CLASSA_NSHIFT 24
285 +#define IN_CLASSA_HOST __IPADDR(0x00ffffff)
286 +#define IN_CLASSA_MAX 128
288 +#define IN_CLASSB(i) (((uint32_t)(i) & __IPADDR(0xc0000000)) == \
289 + __IPADDR(0x80000000))
290 +#define IN_CLASSB_NET __IPADDR(0xffff0000)
291 +#define IN_CLASSB_NSHIFT 16
292 +#define IN_CLASSB_HOST __IPADDR(0x0000ffff)
293 +#define IN_CLASSB_MAX 65536
295 +#define IN_CLASSC(i) (((uint32_t)(i) & __IPADDR(0xe0000000)) == \
296 + __IPADDR(0xc0000000))
297 +#define IN_CLASSC_NET __IPADDR(0xffffff00)
298 +#define IN_CLASSC_NSHIFT 8
299 +#define IN_CLASSC_HOST __IPADDR(0x000000ff)
301 +#define IN_CLASSD(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \
302 + __IPADDR(0xe0000000))
303 +/* These ones aren't really net and host fields, but routing needn't know. */
304 +#define IN_CLASSD_NET __IPADDR(0xf0000000)
305 +#define IN_CLASSD_NSHIFT 28
306 +#define IN_CLASSD_HOST __IPADDR(0x0fffffff)
307 +#define IN_MULTICAST(i) IN_CLASSD(i)
309 +#define IN_EXPERIMENTAL(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \
310 + __IPADDR(0xf0000000))
311 +#define IN_BADCLASS(i) (((uint32_t)(i) & __IPADDR(0xf0000000)) == \
312 + __IPADDR(0xf0000000))
314 +#define IN_LOCAL_GROUP(i) (((uint32_t)(i) & __IPADDR(0xffffff00)) == \
315 + __IPADDR(0xe0000000))
317 +#define INADDR_ANY __IPADDR(0x00000000)
318 +#define INADDR_LOOPBACK __IPADDR(0x7f000001)
319 +#define INADDR_BROADCAST __IPADDR(0xffffffff) /* must be masked */
321 +#define INADDR_UNSPEC_GROUP __IPADDR(0xe0000000) /* 224.0.0.0 */
322 +#define INADDR_ALLHOSTS_GROUP __IPADDR(0xe0000001) /* 224.0.0.1 */
323 +#define INADDR_ALLRTRS_GROUP __IPADDR(0xe0000002) /* 224.0.0.2 */
324 +#define INADDR_MAX_LOCAL_GROUP __IPADDR(0xe00000ff) /* 224.0.0.255 */
326 +#define IN_LOOPBACKNET 127 /* official! */
329 + * Socket address, internet style.
330 + */
331 +struct sockaddr_in {
332 + uint8_t sin_len;
333 + sa_family_t sin_family;
334 + in_port_t sin_port;
335 + struct in_addr sin_addr;
336 + int8_t sin_zero[8];
339 +#define INET_ADDRSTRLEN 16
342 + * Structure used to describe IP options.
343 + * Used to store options internally, to pass them to a process,
344 + * or to restore options retrieved earlier.
345 + * The ip_dst is used for the first-hop gateway when using a source route
346 + * (this gets put into the header proper).
347 + */
348 +struct ip_opts {
349 + struct in_addr ip_dst; /* first hop, 0 w/o src rt */
350 +#if defined(__cplusplus)
351 + int8_t Ip_opts[40]; /* actually variable in size */
352 +#else
353 + int8_t ip_opts[40]; /* actually variable in size */
354 +#endif
358 + * Options for use with [gs]etsockopt at the IP level.
359 + * First word of comment is data type; bool is stored in int.
360 + */
361 +#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
362 +#define IP_HDRINCL 2 /* int; header is included with data */
363 +#define IP_TOS 3 /* int; IP type of service and preced. */
364 +#define IP_TTL 4 /* int; IP time to live */
365 +#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
366 +#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
367 +#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
368 +#define IP_RETOPTS 8 /* ip_opts; set/get IP options */
369 +#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */
370 +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */
371 +#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */
372 +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
373 +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
374 +#define IP_PORTRANGE 19 /* int; range to use for ephemeral port */
375 +#define IP_RECVIF 20 /* bool; receive reception if w/dgram */
376 +#define IP_ERRORMTU 21 /* int; get MTU of last xmit = EMSGSIZE */
377 +#if 1 /*IPSEC*/
378 +#define IP_IPSEC_POLICY 22 /* struct; get/set security policy */
379 +#endif
382 + * Defaults and limits for options
383 + */
384 +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
385 +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
386 +#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
389 + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
390 + */
391 +struct ip_mreq {
392 + struct in_addr imr_multiaddr; /* IP multicast address of group */
393 + struct in_addr imr_interface; /* local IP address of interface */
397 + * Argument for IP_PORTRANGE:
398 + * - which range to search when port is unspecified at bind() or connect()
399 + */
400 +#define IP_PORTRANGE_DEFAULT 0 /* default range */
401 +#define IP_PORTRANGE_HIGH 1 /* same as DEFAULT (FreeBSD compat) */
402 +#define IP_PORTRANGE_LOW 2 /* use privileged range */
405 +#if 0
406 +// FIXME: These are optimized (one instruction), but currently not part of psp-gcc
407 +#define ntohs(x) __builtin_allegrex_wsbh(x)
408 +#define ntohl(x) __builtin_allegrex_wsbw(x)
409 +#define htons(x) __builtin_allegrex_wsbh(x)
410 +#define htonl(x) __builtin_allegrex_wsbw(x)
411 +#else
412 +#define ntohs(x) __builtin_bswap16(x)
413 +#define ntohl(x) __builtin_bswap32(x)
414 +#define htons(x) __builtin_bswap16(x)
415 +#define htonl(x) __builtin_bswap32(x)
416 +#endif
418 +#ifdef __cplusplus
420 +#endif
422 +#endif /* !_NETINET_IN_H_ */
423 diff --git a/newlib/psp/include/netinet/tcp.h b/newlib/psp/include/netinet/tcp.h
424 new file mode 100644
425 index 0000000..deda3f2
426 --- /dev/null
427 +++ b/newlib/psp/include/netinet/tcp.h
428 @@ -0,0 +1,12 @@
429 +#ifndef __NETINET_TCP_H__
430 +#define __NETINET_TCP_H__
432 +#include <netinet/in.h>
434 +#define SOL_TCP IPPROTO_TCP
436 +/* Socket options */
437 +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
438 +#define TCP_MAXSEG 0x02 /* set maximum segment size */
440 +#endif
441 diff --git a/newlib/psp/include/pspatrac3.h b/newlib/psp/include/pspatrac3.h
442 new file mode 100644
443 index 0000000..5482743
444 --- /dev/null
445 +++ b/newlib/psp/include/pspatrac3.h
446 @@ -0,0 +1,213 @@
448 + * PSP Software Development Kit - https://github.com/pspdev
449 + * -----------------------------------------------------------------------
450 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
452 + * pspatrac3.h - Prototypes for the sceAtrac3plus library
454 + * Copyright (c) 2006 moonlight
456 + */
457 +#ifndef __LIBATRAC3_H__
458 +#define __LIBATRAC3_H__
460 +#include <psptypes.h>
462 +#ifdef __cplusplus
463 +extern "C" {
464 +#endif
466 +/* Error code definition */
467 +#define PSP_ATRAC_SUCCESS SCE_OK
469 +#define PSP_ATRAC_ERROR_PARAM_FAIL (0x80630001)
470 +#define PSP_ATRAC_ERROR_API_FAIL (0x80630002)
471 +#define PSP_ATRAC_ERROR_NO_ATRACID (0x80630003)
472 +#define PSP_ATRAC_ERROR_BAD_CODECTYPE (0x80630004)
473 +#define PSP_ATRAC_ERROR_BAD_ATRACID (0x80630005)
474 +#define PSP_ATRAC_ERROR_UNKNOWN_FORMAT (0x80630006)
475 +#define PSP_ATRAC_ERROR_UNMATCH_FORMAT (0x80630007)
476 +#define PSP_ATRAC_ERROR_BAD_DATA (0x80630008)
477 +#define PSP_ATRAC_ERROR_ALLDATA_IS_ONMEMORY (0x80630009)
478 +#define PSP_ATRAC_ERROR_UNSET_DATA (0x80630010)
480 +#define PSP_ATRAC_ERROR_READSIZE_IS_TOO_SMALL (0x80630011)
481 +#define PSP_ATRAC_ERROR_NEED_SECOND_BUFFER (0x80630012)
482 +#define PSP_ATRAC_ERROR_READSIZE_OVER_BUFFER (0x80630013)
483 +#define PSP_ATRAC_ERROR_NOT_4BYTE_ALIGNMENT (0x80630014)
484 +#define PSP_ATRAC_ERROR_BAD_SAMPLE (0x80630015)
485 +#define PSP_ATRAC_ERROR_WRITEBYTE_FIRST_BUFFER (0x80630016)
486 +#define PSP_ATRAC_ERROR_WRITEBYTE_SECOND_BUFFER (0x80630017)
487 +#define PSP_ATRAC_ERROR_ADD_DATA_IS_TOO_BIG (0x80630018)
489 +#define PSP_ATRAC_ERROR_UNSET_PARAM (0x80630021)
490 +#define PSP_ATRAC_ERROR_NONEED_SECOND_BUFFER (0x80630022)
491 +#define PSP_ATRAC_ERROR_NODATA_IN_BUFFER (0x80630023)
492 +#define PSP_ATRAC_ERROR_ALLDATA_WAS_DECODED (0x80630024)
494 +/* Audio Codec ID */
495 +#define PSP_ATRAC_AT3PLUS (0x00001000)
496 +#define PSP_ATRAC_AT3 (0x00001001)
498 +/* Remain Frame typical Status */
499 +#define PSP_ATRAC_ALLDATA_IS_ON_MEMORY (-1)
500 +#define PSP_ATRAC_NONLOOP_STREAM_DATA_IS_ON_MEMORY (-2)
501 +#define PSP_ATRAC_LOOP_STREAM_DATA_IS_ON_MEMORY (-3)
503 +typedef struct {
504 + u8 *pucWritePositionFirstBuf;
505 + u32 uiWritableByteFirstBuf;
506 + u32 uiMinWriteByteFirstBuf;
507 + u32 uiReadPositionFirstBuf;
509 + u8 *pucWritePositionSecondBuf;
510 + u32 uiWritableByteSecondBuf;
511 + u32 uiMinWriteByteSecondBuf;
512 + u32 uiReadPositionSecondBuf;
513 +} PspBufferInfo;
515 +int sceAtracGetAtracID(uint uiCodecType);
517 +/**
518 + * Creates a new Atrac ID from the specified data
520 + * @param buf - the buffer holding the atrac3 data, including the RIFF/WAVE header.
521 + * @param bufsize - the size of the buffer pointed by buf
523 + * @return the new atrac ID, or < 0 on error
525 +int sceAtracSetDataAndGetID(void *buf, SceSize bufsize);
527 +/**
528 + * Decode a frame of data.
530 + * @param atracID - the atrac ID
531 + * @param outSamples - pointer to a buffer that receives the decoded data of the current frame
532 + * @param outN - pointer to a integer that receives the number of audio samples of the decoded frame
533 + * @param outEnd - pointer to a integer that receives a boolean value indicating if the decoded frame is the last one
534 + * @param outRemainFrame - pointer to a integer that receives either -1 if all at3 data is already on memory,
535 + * or the remaining (not decoded yet) frames at memory if not all at3 data is on memory
537 + *
538 + * @return < 0 on error, otherwise 0
541 +int sceAtracDecodeData(int atracID, u16 *outSamples, int *outN, int *outEnd, int *outRemainFrame);
543 +/**
544 + * Gets the remaining (not decoded) number of frames
545 + *
546 + * @param atracID - the atrac ID
547 + * @param outRemainFrame - pointer to a integer that receives either -1 if all at3 data is already on memory,
548 + * or the remaining (not decoded yet) frames at memory if not all at3 data is on memory
550 + * @return < 0 on error, otherwise 0
553 +int sceAtracGetRemainFrame(int atracID, int *outRemainFrame);
555 +/**
557 + * @param atracID - the atrac ID
558 + * @param writePointer - Pointer to where to read the atrac data
559 + * @param availableBytes - Number of bytes available at the writePointer location
560 + * @param readOffset - Offset where to seek into the atrac file before reading
562 + * @return < 0 on error, otherwise 0
566 +int sceAtracGetStreamDataInfo(int atracID, u8** writePointer, u32* availableBytes, u32* readOffset);
568 +/**
570 + * @param atracID - the atrac ID
571 + * @param bytesToAdd - Number of bytes read into location given by sceAtracGetStreamDataInfo().
573 + * @return < 0 on error, otherwise 0
575 +int sceAtracAddStreamData(int atracID, unsigned int bytesToAdd);
577 +/**
578 + * Gets the bitrate.
580 + * @param atracID - the atracID
581 + * @param outBitrate - pointer to a integer that receives the bitrate in kbps
583 + * @return < 0 on error, otherwise 0
586 +int sceAtracGetBitrate(int atracID, int *outBitrate);
588 +/**
589 + * Sets the number of loops for this atrac ID
591 + * @param atracID - the atracID
592 + * @param nloops - the number of loops to set
594 + * @return < 0 on error, otherwise 0
597 +int sceAtracSetLoopNum(int atracID, int nloops);
599 +/**
600 + * It releases an atrac ID
602 + * @param atracID - the atrac ID to release
604 + * @return < 0 on error
607 +int sceAtracReleaseAtracID(int atracID);
609 +/**
610 + * Gets the number of samples of the next frame to be decoded.
612 + * @param atracID - the atrac ID
613 + * @param outN - pointer to receives the number of samples of the next frame.
615 + * @return < 0 on error, otherwise 0
617 + */
618 +int sceAtracGetNextSample(int atracID, int *outN);
620 +/**
621 + * Gets the maximum number of samples of the atrac3 stream.
623 + * @param atracID - the atrac ID
624 + * @param outMax - pointer to a integer that receives the maximum number of samples.
626 + * @return < 0 on error, otherwise 0
628 + */
629 +int sceAtracGetMaxSample(int atracID, int *outMax);
631 +int sceAtracGetBufferInfoForReseting(int atracID, u32 uiSample, PspBufferInfo *pBufferInfo);
633 +int sceAtracGetChannel(int atracID, u32 *puiChannel);
635 +int sceAtracGetInternalErrorInfo(int atracID, int *piResult);
637 +int sceAtracGetLoopStatus(int atracID, int *piLoopNum, u32 *puiLoopStatus);
639 +int sceAtracGetNextDecodePosition(int atracID, u32 *puiSamplePosition);
641 +int sceAtracGetSecondBufferInfo(int atracID, u32 *puiPosition, u32 *puiDataByte);
643 +int sceAtracGetSoundSample(int atracID, int *piEndSample, int *piLoopStartSample, int *piLoopEndSample);
645 +int sceAtracResetPlayPosition(int atracID, u32 uiSample, u32 uiWriteByteFirstBuf, u32 uiWriteByteSecondBuf);
647 +int sceAtracSetData(int atracID, u8 *pucBufferAddr, u32 uiBufferByte);
649 +int sceAtracSetHalfwayBuffer(int atracID, u8 *pucBufferAddr, u32 uiReadByte, u32 uiBufferByte);
651 +int sceAtracSetHalfwayBufferAndGetID(u8 *pucBufferAddr, u32 uiReadByte, u32 uiBufferByte);
653 +int sceAtracSetSecondBuffer(int atracID, u8 *pucSecondBufferAddr, u32 uiSecondBufferByte);
655 +#ifdef __cplusplus
657 +#endif
659 +#endif
660 diff --git a/newlib/psp/include/pspaudio.h b/newlib/psp/include/pspaudio.h
661 new file mode 100644
662 index 0000000..4edd352
663 --- /dev/null
664 +++ b/newlib/psp/include/pspaudio.h
665 @@ -0,0 +1,367 @@
667 + * PSP Software Development Kit - https://github.com/pspdev
668 + * -----------------------------------------------------------------------
669 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
671 + * pspaudio.h - Prototypes for the sceAudio library.
673 + * Copyright (c) 2005 Adresd
674 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
675 + * Copyright (c) 2007 cooleyes
676 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
677 + * Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
679 + */
680 +#ifndef PSPAUDIO_H
681 +#define PSPAUDIO_H
683 +#ifdef __cplusplus
684 +extern "C" {
685 +#endif
687 +/** @defgroup Audio User Audio Library */
689 +/** @addtogroup Audio */
691 +/*@{*/
693 +/** The maximum output volume. */
694 +#define PSP_AUDIO_VOLUME_MAX 0x8000
696 +/** The maximum number of hardware channels. */
697 +#define PSP_AUDIO_CHANNEL_MAX 8
699 +/** Used to request the next available hardware channel. */
700 +#define PSP_AUDIO_NEXT_CHANNEL (-1)
702 +/** Error codes used as return values for the Audio Driver. */
703 +#define SCE_AUDIO_ERROR_NOT_INITIALIZED (0x80260001)
704 +#define SCE_AUDIO_ERROR_OUTPUT_BUSY (0x80260002)
705 +#define SCE_AUDIO_ERROR_INVALID_CH (0x80260003)
706 +#define SCE_AUDIO_ERROR_PRIV_REQUIRED (0x80260004)
707 +#define SCE_AUDIO_ERROR_NOT_FOUND (0x80260005)
708 +#define SCE_AUDIO_ERROR_INVALID_SIZE (0x80260006)
709 +#define SCE_AUDIO_ERROR_INVALID_FORMAT (0x80260007)
710 +#define SCE_AUDIO_ERROR_NOT_RESERVED (0x80260008)
711 +#define SCE_AUDIO_ERROR_NOT_OUTPUT (0x80260009)
712 +#define SCE_AUDIO_ERROR_INVALID_FREQUENCY (0x8026000A)
713 +#define SCE_AUDIO_ERROR_INVALID_VOLUME (0x8026000B)
714 +#define SCE_AUDIO_ERROR_INPUT_BUSY (0x80260010)
716 +enum PspAudioFormats
718 + /** Channel is set to stereo output. */
719 + PSP_AUDIO_FORMAT_STEREO = 0,
720 + /** Channel is set to mono output. */
721 + PSP_AUDIO_FORMAT_MONO = 0x10
724 +typedef struct
726 + /** Unknown. Pass 0 */
727 + int unknown1;
728 + int gain;
729 + /** Unknown. Pass 0 */
730 + int unknown2;
731 + /** Unknown. Pass 0 */
732 + int unknown3;
733 + /** Unknown. Pass 0 */
734 + int unknown4;
735 + /** Unknown. Pass 0 */
736 + int unknown5;
738 +} pspAudioInputParams;
740 +/** The minimum number of samples that can be allocated to a channel. */
741 +#define PSP_AUDIO_SAMPLE_MIN 64
743 +/** The maximum number of samples that can be allocated to a channel. */
744 +#define PSP_AUDIO_SAMPLE_MAX 65472
746 +/** Make the given sample count a multiple of 64. */
747 +#define PSP_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63)
749 +/**
750 + * Allocate and initialize a hardware output channel.
752 + * @param channel - Use a value between 0 - 7 to reserve a specific channel.
753 + * Pass PSP_AUDIO_NEXT_CHANNEL to get the first available channel.
754 + * @param samplecount - The number of samples that can be output on the channel per
755 + * output call. It must be a value between ::PSP_AUDIO_SAMPLE_MIN
756 + * and ::PSP_AUDIO_SAMPLE_MAX, and it must be aligned to 64 bytes
757 + * (use the ::PSP_AUDIO_SAMPLE_ALIGN macro to align it).
758 + * @param format - The output format to use for the channel. One of ::PspAudioFormats.
760 + * @return The channel number on success, an error code if less than 0.
761 + */
762 +int sceAudioChReserve(int channel, int samplecount, int format);
764 +/**
765 + * Release a hardware output channel.
767 + * @param channel - The channel to release.
769 + * @return 0 on success, an error if less than 0.
770 + */
771 +int sceAudioChRelease(int channel);
773 +/**
774 + * Output audio of the specified channel
776 + * @param channel - The channel number.
778 + * @param vol - The volume.
780 + * @param buf - Pointer to the PCM data to output.
782 + * @return 0 on success, an error if less than 0.
783 + */
784 +int sceAudioOutput(int channel, int vol, void *buf);
786 +/**
787 + * Output audio of the specified channel (blocking)
789 + * @param channel - The channel number.
791 + * @param vol - The volume.
793 + * @param buf - Pointer to the PCM data to output.
795 + * @return 0 on success, an error if less than 0.
796 + */
797 +int sceAudioOutputBlocking(int channel, int vol, void *buf);
799 +/**
800 + * Output panned audio of the specified channel
802 + * @param channel - The channel number.
804 + * @param leftvol - The left volume.
806 + * @param rightvol - The right volume.
808 + * @param buf - Pointer to the PCM data to output.
810 + * @return 0 on success, an error if less than 0.
811 + */
812 +int sceAudioOutputPanned(int channel, int leftvol, int rightvol, void *buf);
814 +/**
815 + * Output panned audio of the specified channel (blocking)
817 + * @param channel - The channel number.
819 + * @param leftvol - The left volume.
821 + * @param rightvol - The right volume.
823 + * @param buf - Pointer to the PCM data to output.
825 + * @return 0 on success, an error if less than 0.
826 + */
827 +int sceAudioOutputPannedBlocking(int channel, int leftvol, int rightvol, void *buf);
829 +/**
830 + * Get count of unplayed samples remaining
832 + * @param channel - The channel number.
834 + * @return Number of samples to be played, an error if less than 0.
835 + */
836 +int sceAudioGetChannelRestLen(int channel);
838 +/**
839 + * Get count of unplayed samples remaining
841 + * @param channel - The channel number.
843 + * @return Number of samples to be played, an error if less than 0.
844 + */
845 +int sceAudioGetChannelRestLength(int channel);
847 +/**
848 + * Change the output sample count, after it's already been reserved
850 + * @param channel - The channel number.
851 + * @param samplecount - The number of samples to output in one output call.
853 + * @return 0 on success, an error if less than 0.
854 + */
855 +int sceAudioSetChannelDataLen(int channel, int samplecount);
857 +/**
858 + * Change the format of a channel
860 + * @param channel - The channel number.
862 + * @param format - One of ::PspAudioFormats
864 + * @return 0 on success, an error if less than 0.
865 + */
866 +int sceAudioChangeChannelConfig(int channel, int format);
868 +/**
869 + * Change the volume of a channel
871 + * @param channel - The channel number.
873 + * @param leftvol - The left volume.
875 + * @param rightvol - The right volume.
877 + * @return 0 on success, an error if less than 0.
878 + */
879 +int sceAudioChangeChannelVolume(int channel, int leftvol, int rightvol);
881 +//sceAudioOneshotOutput ???
883 +/**
884 + * Reserve the audio output and set the output sample count
886 + * @param samplecount - The number of samples to output in one output call (min 17, max 4111).
888 + * @return 0 on success, an error if less than 0.
889 + */
890 +int sceAudioOutput2Reserve(int samplecount);
892 +/**
893 + * Release the audio output
895 + * @return 0 on success, an error if less than 0.
896 + */
897 +int sceAudioOutput2Release(void);
899 +/**
900 + * Change the output sample count, after it's already been reserved
902 + * @param samplecount - The number of samples to output in one output call (min 17, max 4111).
904 + * @return 0 on success, an error if less than 0.
905 + */
906 +int sceAudioOutput2ChangeLength(int samplecount);
908 +/**
909 + * Output audio (blocking)
911 + * @param vol - The volume.
913 + * @param buf - Pointer to the PCM data.
915 + * @return 0 on success, an error if less than 0.
916 + */
917 +int sceAudioOutput2OutputBlocking(int vol, void *buf);
919 +/**
920 + * Get count of unplayed samples remaining
922 + * @return Number of samples to be played, an error if less than 0.
923 + */
924 +int sceAudioOutput2GetRestSample(void);
926 +/**
927 + * Reserve the audio output
929 + * @param samplecount - The number of samples to output in one output call (min 17, max 4111).
931 + * @param freq - The frequency. One of 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11050, 8000.
933 + * @param channels - Number of channels. Pass 2 (stereo).
935 + * @return 0 on success, an error if less than 0.
936 + */
937 +int sceAudioSRCChReserve(int samplecount, int freq, int channels);
939 +/**
940 + * Release the audio output
942 + * @return 0 on success, an error if less than 0.
943 + */
944 +int sceAudioSRCChRelease(void);
946 +/**
947 + * Output audio
949 + * @param vol - The volume.
951 + * @param buf - Pointer to the PCM data to output.
953 + * @return 0 on success, an error if less than 0.
954 + */
955 +int sceAudioSRCOutputBlocking(int vol, void *buf);
957 +/**
958 + * Init audio input
960 + * @param unknown1 - Unknown. Pass 0.
962 + * @param gain - Gain.
964 + * @param unknown2 - Unknown. Pass 0.
966 + * @return 0 on success, an error if less than 0.
967 + */
968 +int sceAudioInputInit(int unknown1, int gain, int unknown2);
970 +/**
971 + * Init audio input (with extra arguments)
973 + * @param params - A pointer to a ::pspAudioInputParams struct.
975 + * @return 0 on success, an error if less than 0.
976 + */
977 +int sceAudioInputInitEx(pspAudioInputParams *params);
979 +/**
980 + * Perform audio input (blocking)
982 + * @param samplecount - Number of samples.
984 + * @param freq - Either 44100, 22050 or 11025.
986 + * @param buf - Pointer to where the audio data will be stored.
988 + * @return 0 on success, an error if less than 0.
989 + */
990 +int sceAudioInputBlocking(int samplecount, int freq, void *buf);
992 +/**
993 + * Perform audio input
995 + * @param samplecount - Number of samples.
997 + * @param freq - Either 44100, 22050 or 11025.
999 + * @param buf - Pointer to where the audio data will be stored.
1001 + * @return 0 on success, an error if less than 0.
1002 + */
1003 +int sceAudioInput(int samplecount, int freq, void *buf);
1005 +/**
1006 + * Get the number of samples that were acquired
1008 + * @return Number of samples acquired, an error if less than 0.
1009 + */
1010 +int sceAudioGetInputLength(void);
1012 +/**
1013 + * Wait for non-blocking audio input to complete
1015 + * @return 0 on success, an error if less than 0.
1016 + */
1017 +int sceAudioWaitInputEnd(void);
1019 +/**
1020 + * Poll for non-blocking audio input status
1022 + * @return 0 if input has completed, 1 if not completed or an error if less than 0.
1023 + */
1024 +int sceAudioPollInputEnd(void);
1026 +/*@}*/
1028 +#ifdef __cplusplus
1030 +#endif
1032 +#endif /* PSPAUDIO_H */
1033 diff --git a/newlib/psp/include/pspaudio_kernel.h b/newlib/psp/include/pspaudio_kernel.h
1034 new file mode 100644
1035 index 0000000..ffc27ff
1036 --- /dev/null
1037 +++ b/newlib/psp/include/pspaudio_kernel.h
1038 @@ -0,0 +1,48 @@
1040 + * PSP Software Development Kit - https://github.com/pspdev
1041 + * -----------------------------------------------------------------------
1042 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1044 + * pspaudio.h - Prototypes for the sceAudio library.
1046 + * Copyright (c) 2005 Adresd
1047 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
1048 + * Copyright (c) 2007 cooleyes
1049 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
1051 + */
1052 +#ifndef PSPAUDIO_KERNEL_H
1053 +#define PSPAUDIO_KERNEL_H
1055 +#ifdef __cplusplus
1056 +extern "C" {
1057 +#endif
1059 +/** @defgroup Audio User Audio Library */
1061 +/** @addtogroup Audio */
1063 +/**@{*/
1065 +enum PspAudioFrequencies {
1066 + /** Sampling frequency set to 44100Hz. */
1067 + PSP_AUDIO_FREQ_44K = 44100,
1068 + /** Sampling frequency set to 48000Hz. */
1069 + PSP_AUDIO_FREQ_48K = 48000
1072 +/**
1073 + * Set audio sampling frequency
1075 + * @param frequency - Sampling frequency to set audio output to - either 44100 or 48000.
1077 + * @return 0 on success, an error if less than 0.
1078 + */
1079 +int sceAudioSetFrequency(int frequency);
1080 +/**@}*/
1082 +#ifdef __cplusplus
1084 +#endif
1086 +#endif /* PSPAUDIO_KERNEL_H */
1087 diff --git a/newlib/psp/include/pspaudiocodec.h b/newlib/psp/include/pspaudiocodec.h
1088 new file mode 100644
1089 index 0000000..f4ebe26
1090 --- /dev/null
1091 +++ b/newlib/psp/include/pspaudiocodec.h
1092 @@ -0,0 +1,30 @@
1094 + * PSP Software Development Kit - https://github.com/pspdev
1095 + * -----------------------------------------------------------------------
1096 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1098 + * pspaudiocodec.h - Prototypes for the sceAudiocodec library.
1100 + * Copyright (c) 2006 hitchhikr
1102 + */
1104 +#ifdef __cplusplus
1105 +extern "C" {
1106 +#endif
1108 +#define PSP_CODEC_AT3PLUS (0x00001000)
1109 +#define PSP_CODEC_AT3 (0x00001001)
1110 +#define PSP_CODEC_MP3 (0x00001002)
1111 +#define PSP_CODEC_AAC (0x00001003)
1114 +int sceAudiocodecCheckNeedMem(unsigned long *Buffer, int Type);
1115 +int sceAudiocodecInit(unsigned long *Buffer, int Type);
1116 +int sceAudiocodecDecode(unsigned long *Buffer, int Type);
1117 +int sceAudiocodecGetEDRAM(unsigned long *Buffer, int Type);
1118 +int sceAudiocodecReleaseEDRAM(unsigned long *Buffer);
1120 +#ifdef __cplusplus
1122 +#endif
1123 diff --git a/newlib/psp/include/pspaudiolib.h b/newlib/psp/include/pspaudiolib.h
1124 new file mode 100644
1125 index 0000000..e347221
1126 --- /dev/null
1127 +++ b/newlib/psp/include/pspaudiolib.h
1128 @@ -0,0 +1,52 @@
1130 + * PSP Software Development Kit - https://github.com/pspdev
1131 + * -----------------------------------------------------------------------
1132 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1134 + * pspaudiolib.h - Audio library build on top of sceAudio, but to provide
1135 + * multiple thread usage and callbacks.
1137 + * Copyright (c) 2005 Adresd
1138 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
1140 + */
1141 +#ifndef __AUDIOLIB_H__
1142 +#define __AUDIOLIB_H__
1144 +#ifdef __cplusplus
1145 +extern "C" {
1146 +#endif
1148 +#define PSP_NUM_AUDIO_CHANNELS 4
1149 +/** This is the number of frames you can update per callback, a frame being
1150 + * 1 sample for mono, 2 samples for stereo etc. */
1151 +#define PSP_NUM_AUDIO_SAMPLES 1024
1152 +#define PSP_VOLUME_MAX 0x8000
1154 +typedef void (* pspAudioCallback_t)(void *buf, unsigned int reqn, void *pdata);
1156 +typedef struct {
1157 + int threadhandle;
1158 + int handle;
1159 + int volumeleft;
1160 + int volumeright;
1161 + pspAudioCallback_t callback;
1162 + void *pdata;
1163 +} psp_audio_channelinfo;
1165 +typedef int (* pspAudioThreadfunc_t)(int args, void *argp);
1167 +int pspAudioInit();
1168 +void pspAudioEndPre();
1169 +void pspAudioEnd();
1171 +void pspAudioSetVolume(int channel, int left, int right);
1172 +void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn);
1173 +void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata);
1174 +int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf);
1176 +#ifdef __cplusplus
1178 +#endif
1180 +#endif
1181 diff --git a/newlib/psp/include/pspaudiorouting.h b/newlib/psp/include/pspaudiorouting.h
1182 new file mode 100644
1183 index 0000000..16891bc
1184 --- /dev/null
1185 +++ b/newlib/psp/include/pspaudiorouting.h
1186 @@ -0,0 +1,31 @@
1188 + * PSP Software Development Kit - https://github.com/pspdev
1189 + * -----------------------------------------------------------------------
1190 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1192 + * pspaudiorouting.h - Interface to sceAudioRouting.
1194 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
1196 + */
1197 +#ifndef __PSPAUDIOROUTING_H__
1198 +#define __PSPAUDIOROUTING_H__
1200 +/**
1201 + * Set routing mode.
1203 + * @param mode The routing mode to set (0 or 1)
1205 + * @return the previous routing mode, or < 0 on error
1207 +int sceAudioRoutingSetMode( int mode );
1209 +/**
1210 + * Get routing mode.
1212 + * @return the current routing mode.
1214 +int sceAudioRoutingGetMode();
1216 +#endif
1218 diff --git a/newlib/psp/include/pspchnnlsv.h b/newlib/psp/include/pspchnnlsv.h
1219 new file mode 100644
1220 index 0000000..848cec2
1221 --- /dev/null
1222 +++ b/newlib/psp/include/pspchnnlsv.h
1223 @@ -0,0 +1,113 @@
1225 + * PSP Software Development Kit - https://github.com/pspdev
1226 + * -----------------------------------------------------------------------
1227 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1229 + * pspchnnlsv.h - Include for the pspChnnlsv library.
1231 + * Copyright (c) 2005 Jim Paris <jim@jtan.com>
1232 + * Copyright (c) 2005 psp123
1234 + */
1235 +#ifndef __PSPCHNNLSV_H__
1236 +#define __PSPCHNNLSV_H__
1238 +/* The descriptions are mostly speculation. */
1240 +/** @defgroup Chnnlsv Chnnlsv Library
1241 + * Library imports for the vsh chnnlsv library.
1242 + */
1244 +#ifdef __cplusplus
1245 +extern "C" {
1246 +#endif
1248 +#include <psptypes.h>
1250 +/** @addtogroup Chnnlsv Chnnlsv Library */
1251 +/**@{*/
1253 +typedef struct _pspChnnlsvContext1 {
1254 + /** Cipher mode */
1255 + int mode;
1257 + /** Context data */
1258 + char buffer1[0x10];
1259 + char buffer2[0x10];
1260 + int unknown;
1261 +} pspChnnlsvContext1;
1263 +typedef struct _pspChnnlsvContext2 {
1264 + /** Context data */
1265 + char unknown[0x100];
1266 +} pspChnnlsvContext2;
1268 +/**
1269 + * Initialize context
1271 + * @param ctx - Context
1272 + * @param mode - Cipher mode
1273 + * @return < 0 on error
1274 + */
1275 +int sceChnnlsv_E7833020(pspChnnlsvContext1 *ctx, int mode);
1277 +/**
1278 + * Process data
1280 + * @param ctx - Context
1281 + * @param data - Data (aligned to 0x10)
1282 + * @param len - Length (aligned to 0x10)
1283 + * @return < 0 on error
1284 + */
1285 +int sceChnnlsv_F21A1FCA(pspChnnlsvContext1 *ctx, unsigned char *data, int len);
1287 +/**
1288 + * Finalize hash
1290 + * @param ctx - Context
1291 + * @param hash - Hash output (aligned to 0x10, 0x10 bytes long)
1292 + * @param cryptkey - Crypt key or NULL.
1293 + * @return < 0 on error
1294 + */
1295 +int sceChnnlsv_C4C494F8(pspChnnlsvContext1 *ctx,
1296 + unsigned char *hash, unsigned char *cryptkey);
1298 +/**
1299 + * Prepare a key, and set up integrity check
1301 + * @param ctx - Context
1302 + * @param mode1 - Cipher mode
1303 + * @param mode2 - Encrypt mode (1 = encrypting, 2 = decrypting)
1304 + * @param hashkey - Key out
1305 + * @param cipherkey - Key in
1306 + * @return < 0 on error
1307 + */
1308 +int sceChnnlsv_ABFDFC8B(pspChnnlsvContext2 *ctx, int mode1, int mode2,
1309 + unsigned char *hashkey, unsigned char *cipherkey);
1311 +/**
1312 + * Process data for integrity check
1314 + * @param ctx - Context
1315 + * @param data - Data (aligned to 0x10)
1316 + * @param len - Length (aligned to 0x10)
1317 + * @return < 0 on error
1318 + */
1319 +int sceChnnlsv_850A7FA1(pspChnnlsvContext2 *ctx, unsigned char *data, int len);
1321 +/**
1322 + * Check integrity
1324 + * @param ctx - Context
1325 + * @return < 0 on error
1326 + */
1327 +int sceChnnlsv_21BE78B4(pspChnnlsvContext2 *ctx);
1329 +/**@}*/
1331 +#ifdef __cplusplus
1333 +#endif
1335 +#endif
1337 diff --git a/newlib/psp/include/pspctrl.h b/newlib/psp/include/pspctrl.h
1338 new file mode 100644
1339 index 0000000..d792618
1340 --- /dev/null
1341 +++ b/newlib/psp/include/pspctrl.h
1342 @@ -0,0 +1,317 @@
1344 + * PSP Software Development Kit - https://github.com/pspdev
1345 + * -----------------------------------------------------------------------
1346 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1348 + * pspctrl.h - Prototypes for the sceCtrl library.
1350 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
1351 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
1352 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
1354 + */
1356 +/* Note: Some of the structures, types, and definitions in this file were
1357 + extrapolated from symbolic debugging information found in the Japanese
1358 + version of Puzzle Bobble. */
1360 +#ifndef __CTRL_H__
1361 +#define __CTRL_H__
1363 +#ifdef __cplusplus
1364 +extern "C" {
1365 +#endif
1367 +/** @addtogroup Ctrl Controller Kernel Library */
1368 +/**@{*/
1370 +/**
1371 + * Enumeration for the digital controller buttons.
1373 + * @note PSP_CTRL_HOME, PSP_CTRL_NOTE, PSP_CTRL_SCREEN, PSP_CTRL_VOLUP, PSP_CTRL_VOLDOWN, PSP_CTRL_DISC, PSP_CTRL_WLAN_UP, PSP_CTRL_REMOTE, PSP_CTRL_MS can only be read in kernel mode
1374 + */
1375 +enum PspCtrlButtons
1377 + /** Select button. */
1378 + PSP_CTRL_SELECT = 0x000001,
1379 + /** Start button. */
1380 + PSP_CTRL_START = 0x000008,
1381 + /** Up D-Pad button. */
1382 + PSP_CTRL_UP = 0x000010,
1383 + /** Right D-Pad button. */
1384 + PSP_CTRL_RIGHT = 0x000020,
1385 + /** Down D-Pad button. */
1386 + PSP_CTRL_DOWN = 0x000040,
1387 + /** Left D-Pad button. */
1388 + PSP_CTRL_LEFT = 0x000080,
1389 + /** Left trigger. */
1390 + PSP_CTRL_LTRIGGER = 0x000100,
1391 + /** Right trigger. */
1392 + PSP_CTRL_RTRIGGER = 0x000200,
1393 + /** Triangle button. */
1394 + PSP_CTRL_TRIANGLE = 0x001000,
1395 + /** Circle button. */
1396 + PSP_CTRL_CIRCLE = 0x002000,
1397 + /** Cross button. */
1398 + PSP_CTRL_CROSS = 0x004000,
1399 + /** Square button. */
1400 + PSP_CTRL_SQUARE = 0x008000,
1401 + /** Home button. In user mode this bit is set if the exit dialog is visible. */
1402 + PSP_CTRL_HOME = 0x010000,
1403 + /** Hold button. */
1404 + PSP_CTRL_HOLD = 0x020000,
1405 + /** Music Note button. */
1406 + PSP_CTRL_NOTE = 0x800000,
1407 + /** Screen button. */
1408 + PSP_CTRL_SCREEN = 0x400000,
1409 + /** Volume up button. */
1410 + PSP_CTRL_VOLUP = 0x100000,
1411 + /** Volume down button. */
1412 + PSP_CTRL_VOLDOWN = 0x200000,
1413 + /** Wlan switch up. */
1414 + PSP_CTRL_WLAN_UP = 0x040000,
1415 + /** Remote hold position. */
1416 + PSP_CTRL_REMOTE = 0x080000,
1417 + /** Disc present. */
1418 + PSP_CTRL_DISC = 0x1000000,
1419 + /** Memory stick present. */
1420 + PSP_CTRL_MS = 0x2000000,
1423 +/** Controller mode. */
1424 +enum PspCtrlMode
1426 + /* Digital. */
1427 + PSP_CTRL_MODE_DIGITAL = 0,
1428 + /* Analog. */
1429 + PSP_CTRL_MODE_ANALOG
1432 +/** Returned controller data */
1433 +typedef struct SceCtrlData {
1434 + /** The current read frame. */
1435 + unsigned int TimeStamp;
1436 + /** Bit mask containing zero or more of ::PspCtrlButtons. */
1437 + unsigned int Buttons;
1438 + /** Analogue stick, X axis. */
1439 + unsigned char Lx;
1440 + /** Analogue stick, Y axis. */
1441 + unsigned char Ly;
1442 + /** Reserved. */
1443 + unsigned char Rsrv[6];
1444 +} SceCtrlData;
1446 +/**
1447 + * This structure represents controller button latch data.
1448 + *
1449 + * With each sampling cycle, the controller service compares the new pressed & released button states
1450 + * with the previously collected pressed button states. This comparison will result in the following possible
1451 + * states for each button:
1453 + * • [make]: The button has just been pressed with its prior state being the released state. Transition from
1454 + * 'released' state to 'pressed' state.\n
1455 + * • [press]: The button is currently in the 'pressed' state.\n
1456 + * • [break]: The button has just been released with its prior state being the 'pressed' state. Transition from
1457 + * 'pressed' state to 'release' state.\n
1458 + * • [release]: The button is currently in the 'released' state.
1459 + *
1460 + * It is possible for a button to (briefly) be in two states at the same time. Valid combinations are as follows:
1461 + *
1462 + * • [make] & [press]\n
1463 + * • [break] & [release]
1464 + *
1465 + * In other words, if a button is in the [make] state, then it is also in the [press] state. However, this is not the case
1466 + * for the inverse. A button in the [press] state does not need to be in the [make] state.
1467 + *
1468 + * These comparison results are stored internally as latch data and can be retrieved using the APIs ::sceCtrlPeekLatch() and
1469 + * ::sceCtrlReadLatch(). ::PspCtrlButtons can be used to find out the state of each button.
1470 + *
1471 + * @remark The same can be accomplished by using the different sceCtrl[Read/Peek]Buffer[Positive/Negative]() APIs
1472 + * and comparing the currently collected button sampling data with the previously collected one.
1473 + *
1474 + * @see ::sceCtrlPeekLatch()
1475 + * @see ::sceCtrlReadLatch()
1476 + */
1477 +typedef struct SceCtrlLatch {
1478 + /** Button transitioned to pressed state. */
1479 + unsigned int uiMake;
1480 + /** Button transitioned to released state. */
1481 + unsigned int uiBreak;
1482 + /** Button is in the pressed state. */
1483 + unsigned int uiPress;
1484 + /** Button is in the released state. */
1485 + unsigned int uiRelease;
1486 +} SceCtrlLatch;
1488 +/**
1489 + * Set the controller cycle setting.
1491 + * @param cycle - Cycle. Normally set to 0.
1493 + * @return The previous cycle setting.
1494 + */
1495 +int sceCtrlSetSamplingCycle(int cycle);
1497 +/**
1498 + * Get the controller current cycle setting.
1500 + * @param pcycle - Return value.
1502 + * @return 0.
1503 + */
1504 +int sceCtrlGetSamplingCycle(int *pcycle);
1506 +/**
1507 + * Set the controller mode.
1509 + * @param mode - One of ::PspCtrlMode. If this is PSP_CTRL_MODE_DIGITAL, no data about the analog stick
1510 + * will be present in the SceCtrlData struct read by SceCtrlReadBuffer.
1512 + * @return The previous mode.
1513 + */
1514 +int sceCtrlSetSamplingMode(int mode);
1516 +/**
1517 + * Get the current controller mode.
1519 + * @param pmode - Return value.
1521 + * @return 0.
1522 + */
1523 +int sceCtrlGetSamplingMode(int *pmode);
1525 +int sceCtrlPeekBufferPositive(SceCtrlData *pad_data, int count);
1527 +int sceCtrlPeekBufferNegative(SceCtrlData *pad_data, int count);
1529 +/**
1530 + * Read buffer positive
1532 + * @par Example:
1533 + * @code
1534 + * SceCtrlData pad;
1536 + * sceCtrlSetSamplingCycle(0);
1537 + * sceCtrlSetSamplingMode(1);
1538 + * sceCtrlReadBufferPositive(&pad, 1);
1539 + * // Do something with the read controller data
1540 + * @endcode
1542 + * @param pad_data - Pointer to a ::SceCtrlData structure used hold the returned pad data.
1543 + * @param count - Number of ::SceCtrlData buffers to read.
1544 + */
1545 +int sceCtrlReadBufferPositive(SceCtrlData *pad_data, int count);
1547 +int sceCtrlReadBufferNegative(SceCtrlData *pad_data, int count);
1549 +/**
1550 + * @brief Get the latch data.
1552 + * This function reads the latch data collected by the controller service. At each sampling
1553 + * interval, the controller service compares the new pressed/released button states with the previously sampled pressed
1554 + * button states and stores that comparison as latch data.
1556 + * Compared to ::sceCtrlReadLatch(), calling this API will not result in clearing the internal latch data. As such,
1557 + * the data returned is the accumulated latch data since the last time ::sceCtrlReadLatch() was called. Consequently,
1558 + * the returned data should not be relied on whether a button is currently in a pressed or released state.
1560 + * @param latch_data Pointer to a ::SceCtrlLatch variable which is to receive the accumulated button latch data.
1562 + * @return On success, the number of times the controller service performed sampling since the last time
1563 + * ::sceCtrlReadLatch() was called.
1564 + * @return < 0 on error.
1565 + *
1566 + * @see ::SceCtrlLatch
1567 + * @see ::sceCtrlReadLatch()
1568 + */
1569 +int sceCtrlPeekLatch(SceCtrlLatch *latch_data);
1571 +/**
1572 + * @brief Get the latch data.
1573 + *
1574 + * This function reads the most recent latch data collected by the controller service. At each sampling
1575 + * interval, the controller service compares the new pressed/released button states with the previously sampled pressed
1576 + * button states and stores that comparison as latch data.
1577 + *
1578 + * Compared to ::sceCtrlPeekLatch(), calling this API will result in clearing the internal latch data. As such,
1579 + * calling code might have to explicitly wait for the controller service to update its collected latch data.
1580 + *
1581 + * @param latch_data Pointer to a ::SceCtrlLatch variable which is to receive the current button latch data.
1582 + *
1583 + * @return On success, the number of times the controller service performed sampling since the last time
1584 + * ::sceCtrlReadLatch() was called.
1585 + * @return < 0 on error.
1586 + *
1587 + * @par Example:
1588 + * @code
1589 + * SceCtrlLatch latchData;
1590 + *
1591 + * while (1) {
1592 + * // Obtain latch data
1593 + * sceCtrlReadLatch(&latchData);
1594 + *
1595 + * if (latchData.buttonMake & PSP_CTRL_CROSS)
1596 + * {
1597 + * // The Cross button has just been pressed (transition from 'released' state to 'pressed' state)
1598 + * }
1599 + *
1600 + * if (latchData.buttonPress & PSP_CTRL_SQUARE)
1601 + * {
1602 + * // The Square button is currently in the 'pressed' state
1603 + * }
1604 + *
1605 + * if (latchData.buttonBreak & PSP_CTRL_TRIANGLE)
1606 + * {
1607 + * // The Triangle button has just been released (transition from 'pressed' state to 'released' state)
1608 + * }
1609 + *
1610 + * if (latchData.buttonRelease & PSP_CTRL_CIRCLE)
1611 + * {
1612 + * // The Circle button is currently in the 'released' state
1613 + * }
1614 + *
1615 + * // As we clear the internal latch data with the ReadLatch() call, we can explicitly wait for the VBLANK interval
1616 + * // to give the controller service the time it needs to collect new latch data again. This guarantees the next call
1617 + * // to sceCtrlReadLatch() will return collected data again.
1618 + * //
1619 + * // Note: The sceCtrlReadBuffer*() APIs are implicitly waiting for a VBLANK interval if necessary.
1620 + * sceDisplayWaitVBlank();
1621 + * }
1622 + * @endcode
1623 + *
1624 + * @see ::SceCtrlLatch
1625 + * @see ::sceCtrlPeekLatch()
1626 + */
1627 +int sceCtrlReadLatch(SceCtrlLatch *latch_data);
1629 +/**
1630 + * Set analog threshold relating to the idle timer.
1632 + * @param idlereset - Movement needed by the analog to reset the idle timer.
1633 + * @param idleback - Movement needed by the analog to bring the PSP back from an idle state.
1635 + * Set to -1 for analog to not cancel idle timer.
1636 + * Set to 0 for idle timer to be cancelled even if the analog is not moved.
1637 + * Set between 1 - 128 to specify the movement on either axis needed by the analog to fire the event.
1639 + * @return < 0 on error.
1640 + */
1641 +int sceCtrlSetIdleCancelThreshold(int idlereset, int idleback);
1643 +/**
1644 + * Get the idle threshold values.
1646 + * @param idlerest - Movement needed by the analog to reset the idle timer.
1647 + * @param idleback - Movement needed by the analog to bring the PSP back from an idle state.
1649 + * @return < 0 on error.
1650 + */
1651 +int sceCtrlGetIdleCancelThreshold(int *idlerest, int *idleback);
1653 +/**@}*/
1655 +#ifdef __cplusplus
1657 +#endif
1659 +#endif
1660 diff --git a/newlib/psp/include/pspctrl_kernel.h b/newlib/psp/include/pspctrl_kernel.h
1661 new file mode 100644
1662 index 0000000..074b78b
1663 --- /dev/null
1664 +++ b/newlib/psp/include/pspctrl_kernel.h
1665 @@ -0,0 +1,69 @@
1667 + * PSP Software Development Kit - https://github.com/pspdev
1668 + * -----------------------------------------------------------------------
1669 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1671 + * pspctrl_kernel.h - Prototypes for the sceCtrl_driver library.
1673 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
1674 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
1675 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
1677 + */
1679 +#ifndef __CTRL_KERNEL_H__
1680 +#define __CTRL_KERNEL_H__
1682 +#ifdef __cplusplus
1683 +extern "C" {
1684 +#endif
1686 +/**
1687 + * Set the controller button masks
1689 + * @param mask - The bits to setup
1690 + * @param type - The type of operation (0 clear, 1 set mask, 2 set button)
1692 + * @par Example:
1693 + * @code
1694 + * sceCtrl_driver_7CA723DC(0xFFFF, 1); // Mask lower 16bits
1695 + * sceCtrl_driver_7CA723DC(0x10000, 2); // Always return HOME key
1696 + * // Do something
1697 + * sceCtrl_driver_7CA723DC(0x10000, 0); // Unset HOME key
1698 + * sceCtrl_driver_7CA723DC(0xFFFF, 0); // Unset mask
1699 + * @endcode
1700 + */
1701 +void sceCtrl_driver_7CA723DC(unsigned int mask, unsigned type);
1703 +/**
1704 + * Get button mask mode
1706 + * @param mask - The bitmask to check
1708 + * @return 0 no setting, 1 set in button mask, 2 set in button set
1709 + */
1710 +int sceCtrl_driver_5E77BC8A(unsigned int mask);
1712 +/**
1713 + * Setup a controller callback
1715 + * @param no - The number of the callback (0-3)
1716 + * @param mask - The bits to check for
1717 + * @param cb - The callback function (int curr_but, int last_but, void *arg)
1718 + * @param arg - User defined argument passed
1720 + * @return 0 on success, < 0 on error
1721 + */
1722 +int sceCtrl_driver_5C56C779(int no, unsigned int mask, void (*cb)(int, int, void*), void *arg);
1724 +/* Just define some random names for the functions to make them easier to use */
1725 +#define sceCtrlSetButtonMasks sceCtrl_driver_7CA723DC
1726 +#define sceCtrlGetButtonMask sceCtrl_driver_5E77BC8A
1727 +#define sceCtrlRegisterButtonCallback sceCtrl_driver_5C56C779
1730 +#ifdef __cplusplus
1732 +#endif
1734 +#endif
1735 diff --git a/newlib/psp/include/pspdebug.h b/newlib/psp/include/pspdebug.h
1736 new file mode 100644
1737 index 0000000..9a01191
1738 --- /dev/null
1739 +++ b/newlib/psp/include/pspdebug.h
1740 @@ -0,0 +1,442 @@
1742 + * PSP Software Development Kit - https://github.com/pspdev
1743 + * -----------------------------------------------------------------------
1744 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
1746 + * pspdebug.h - Prototypes for the pspDebug library
1748 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
1749 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
1750 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
1752 + */
1753 +#ifndef __DEBUG_H__
1754 +#define __DEBUG_H__
1756 +#include <psptypes.h>
1757 +#include <pspmoduleinfo.h>
1759 +#ifdef __cplusplus
1760 +extern "C" {
1761 +#endif
1763 +/** @defgroup Debug Debug Utility Library */
1765 +/** @addtogroup Debug */
1766 +/**@{*/
1768 +/**
1769 + * Initialise the debug screen
1770 + */
1771 +void pspDebugScreenInit(void);
1773 +/**
1774 + * Extended debug screen init
1776 + * @param vram_base - Base address of frame buffer, if NULL then sets a default
1777 + * @param mode - Colour mode
1778 + * @param setup - Setup the screen if 1
1779 + */
1780 +void pspDebugScreenInitEx(void *vram_base, int mode, int setup);
1782 +/**
1783 + * Do a printf to the debug screen.
1785 + * @param fmt - Format string to print
1786 + * @param ... - Arguments
1787 + */
1788 +void pspDebugScreenPrintf(const char *fmt, ...) __attribute__((format(printf,1,2)));
1790 +/**
1791 + * Do a printf to the debug screen.
1792 + * @note This is for kernel mode only as it uses a kernel function
1793 + * to perform the printf instead of using vsnprintf, use normal printf for
1794 + * user mode.
1796 + * @param format - Format string to print
1797 + * @param ... - Arguments
1798 + */
1799 +void pspDebugScreenKprintf(const char *format, ...) __attribute__((format(printf,1,2)));
1801 +/**
1802 + * Enable or disable background colour writing (defaults to enabled)
1803 + *
1804 + * @param enable - Set 1 to to enable background color, 0 for disable
1805 + */
1806 +void pspDebugScreenEnableBackColor(int enable);
1808 +/**
1809 + * Set the background color for the text
1810 + * @note To reset the entire screens bg colour you need to call pspDebugScreenClear
1812 + * @param color - A 32bit RGB colour
1813 + */
1814 +void pspDebugScreenSetBackColor(u32 color);
1816 +/**
1817 + * Set the text color
1819 + * @param color - A 32 bit RGB color
1820 + */
1821 +void pspDebugScreenSetTextColor(u32 color);
1823 +/**
1824 + * Set the color mode (you must have switched the frame buffer appropriately)
1826 + * @param mode - Color mode
1827 + */
1828 +void pspDebugScreenSetColorMode(int mode);
1830 +/**
1831 + * Draw a single character to the screen.
1833 + * @param x - The x co-ordinate to draw to (pixel units)
1834 + * @param y - The y co-ordinate to draw to (pixel units)
1835 + * @param color - The text color to draw
1836 + * @param ch - The character to draw
1837 + */
1838 +void pspDebugScreenPutChar(int x, int y, u32 color, u8 ch);
1840 +/**
1841 + * Set the current X and Y co-ordinate for the screen (in character units)
1842 + */
1843 +void pspDebugScreenSetXY(int x, int y);
1845 +/**
1846 + * Set the video ram offset used for the screen
1848 + * @param offset - Offset in bytes
1849 + */
1850 +void pspDebugScreenSetOffset(int offset);
1852 +/**
1853 + * Set the video ram base used for the screen
1855 + * @param base - Base address in bytes
1856 + */
1857 +void pspDebugScreenSetBase(u32* base);
1859 +/**
1860 + * Get the current X co-ordinate (in character units)
1862 + * @return The X co-ordinate
1863 + */
1864 +int pspDebugScreenGetX(void);
1866 +/**
1867 + * Get the current Y co-ordinate (in character units)
1869 + * @return The Y co-ordinate
1870 + */
1871 +int pspDebugScreenGetY(void);
1873 +/**
1874 + * Clear the debug screen.
1875 + */
1876 +void pspDebugScreenClear(void);
1878 +/**
1879 + * Print non-nul terminated strings.
1880 + *
1881 + * @param buff - Buffer containing the text.
1882 + * @param size - Size of the data
1884 + * @return The number of characters written
1885 + */
1886 +int pspDebugScreenPrintData(const char *buff, int size);
1888 +/**
1889 + * Print a string
1891 + * @param str - String
1893 + * @return The number of characters written
1894 + */
1895 +int pspDebugScreenPuts(const char *str);
1897 +/**
1898 + * Get a MIPS stack trace (might work :P)
1900 + * @param results - List of points to store the results of the trace, (up to max)
1901 + * @param max - Maximum number of back traces
1903 + * @return The number of frames stored in results.
1905 +int pspDebugGetStackTrace(unsigned int* results, int max);
1907 +/**
1908 + * Enable the clear line function that allows debug to clear the screen
1910 +void pspDebugScreenClearLineEnable(void);
1912 +/**
1913 + * Disable the clear line function that causes flicker on constant refreshes
1915 +void pspDebugScreenClearLineDisable(void);
1917 +/** Structure to hold the register data associated with an exception */
1918 +typedef struct _PspDebugRegBlock
1920 + u32 frame[6];
1921 + /** Array of the 32 GPRs */
1922 + u32 r[32];
1923 + /** The status register */
1924 + u32 status;
1925 + /** lo */
1926 + u32 lo;
1927 + u32 hi;
1928 + u32 badvaddr;
1929 + u32 cause;
1930 + u32 epc;
1931 + float fpr[32];
1932 + u32 fsr;
1933 + u32 fir;
1934 + u32 frame_ptr;
1935 + u32 unused;
1936 + /* Unused on PSP */
1937 + u32 index;
1938 + u32 random;
1939 + u32 entrylo0;
1940 + u32 entrylo1;
1941 + u32 context;
1942 + u32 pagemask;
1943 + u32 wired;
1944 + u32 cop0_7;
1945 + u32 cop0_8;
1946 + u32 cop0_9;
1947 + u32 entryhi;
1948 + u32 cop0_11;
1949 + u32 cop0_12;
1950 + u32 cop0_13;
1951 + u32 cop0_14;
1952 + /* PRId should still be okay */
1953 + u32 prid;
1954 + u32 padding[100];
1955 +} PspDebugRegBlock;
1957 +/** Defines a debug error handler */
1958 +typedef void (*PspDebugErrorHandler)(PspDebugRegBlock *regs);
1960 +/**
1961 + * Install an error handler to catch unhandled exceptions.
1962 + *
1963 + * @param handler - Pointer to a handler function. If set to NULL it will default
1964 + * to resetting the screen and dumping the error.
1965 + * @return < 0 on error
1966 + */
1967 +int pspDebugInstallErrorHandler(PspDebugErrorHandler handler);
1969 +/**
1970 + * Dump an exception to screen using the pspDebugScreen functions.
1971 + * @note This function will not setup the screen for debug output, you should call sceDebugScreenInit
1972 + * before using it if it isn't already.
1974 + * @param regs - Pointer to a register block.
1976 + */
1977 +void pspDebugDumpException(PspDebugRegBlock *regs);
1979 +/** Type for Kprintf handler */
1980 +typedef int (*PspDebugKprintfHandler)(const char *format, u32 *args);
1982 +/**
1983 + * Install a Kprintf handler into the system.
1985 + * @param handler - Function pointer to the handler.
1986 + * @return < 0 on error.
1987 + */
1988 +int pspDebugInstallKprintfHandler(PspDebugKprintfHandler handler);
1990 +/** Structure to hold a single stack trace entry */
1991 +typedef struct _PspDebugStackTrace
1993 + /** The address which called the function */
1994 + u32 call_addr;
1995 + /** The address of the function called */
1996 + u32 func_addr;
1997 +} PspDebugStackTrace;
1999 +/**
2000 + * Do a stack trace from the current exception.
2001 + * @note This function really isn't too general purpose and it is more than likely to generate a few
2002 + * false positives but I consider that better then missing out calls entirely. You have to use your
2003 + * discretion, your code and a objdump to work out if some calls are completely surprious or not ;)
2005 + * @param regs - Pointer to a register block from an exception.
2006 + * @param trace - Pointer to an array of PspDebugStackTrace structures.
2007 + * @param max - The maximum number of traces to make.
2009 + * @return The number of functions found.
2010 + */
2011 +int pspDebugGetStackTrace2(PspDebugRegBlock *regs, PspDebugStackTrace *trace, int max);
2013 +/** Structure to hold the psp profiler register values */
2014 +typedef struct _PspDebugProfilerRegs
2016 + volatile u32 enable;
2017 + volatile u32 systemck;
2018 + volatile u32 cpuck;
2019 + volatile u32 internal;
2020 + volatile u32 memory;
2021 + volatile u32 copz;
2022 + volatile u32 vfpu;
2023 + volatile u32 sleep;
2024 + volatile u32 bus_access;
2025 + volatile u32 uncached_load;
2026 + volatile u32 uncached_store;
2027 + volatile u32 cached_load;
2028 + volatile u32 cached_store;
2029 + volatile u32 i_miss;
2030 + volatile u32 d_miss;
2031 + volatile u32 d_writeback;
2032 + volatile u32 cop0_inst;
2033 + volatile u32 fpu_inst;
2034 + volatile u32 vfpu_inst;
2035 + volatile u32 local_bus;
2036 +} PspDebugProfilerRegs;
2038 +/** Enables the profiler hardware */
2039 +void pspDebugProfilerEnable(void);
2041 +/** Disables the profiler hardware */
2042 +void pspDebugProfilerDisable(void);
2044 +/** Clear the profiler registers */
2045 +void pspDebugProfilerClear(void);
2047 +/** Get the profiler register state
2049 + * @param regs - A pointer to a PspDebugProfilerRegs structure.
2050 + */
2051 +void pspDebugProfilerGetRegs(PspDebugProfilerRegs *regs);
2053 +/** Print the profiler registers to screen */
2054 +void pspDebugProfilerPrint(void);
2056 +/** Type for the debug print handlers */
2057 +typedef int (*PspDebugPrintHandler)(const char *data, int len);
2059 +/** Type for the debug input handler */
2060 +typedef int (*PspDebugInputHandler)(char *data, int len);
2062 +/**
2063 + * Install a handler for stdin (so you can use normal stdio functions)
2065 + * @param handler - A pointer to input handler, NULL to disable.
2067 + * @return < 0 on error, else 0.
2068 + */
2069 +int pspDebugInstallStdinHandler(PspDebugInputHandler handler);
2071 +/**
2072 + * Install a print handler for stdout (so you can use normal print functions)
2074 + * @param handler - A pointer to print handler, NULL to disable.
2076 + * @return < 0 on error, else 0.
2077 + */
2078 +int pspDebugInstallStdoutHandler(PspDebugPrintHandler handler);
2080 +/**
2081 + * Install a print handler for stderr (so you can use normal print functions)
2083 + * @param handler - A pointer to print handler, NULL to disable.
2085 + * @return < 0 on error, else 0.
2086 + */
2087 +int pspDebugInstallStderrHandler(PspDebugPrintHandler handler);
2089 +/**
2090 + * Put a character to the remote sio.
2092 + * @param ch - Character to write.
2093 + */
2094 +void pspDebugSioPutchar(int ch);
2096 +/**
2097 + * Get a character from the remote sio
2099 + * @return The character read or -1 if no characters available.
2100 + */
2101 +int pspDebugSioGetchar(void);
2103 +/**
2104 + * Write a string to the sio port.
2106 + * @param str - String to write.
2107 + */
2108 +void pspDebugSioPuts(const char *str);
2110 +/**
2111 + * Write a set of data to the sio port
2113 + * @param data - Pointer to the data to send.
2114 + * @param len - Length of the data.
2116 + * @return Number of characters written.
2117 + */
2118 +int pspDebugSioPutData(const char *data, int len);
2120 +/**
2121 + * Write a set of data to the sio port converting single
2122 + * line feeds to CRLF and single CR to CRLF
2124 + * @param data - Pointer to the data to send.
2125 + * @param len - Length of the data.
2127 + * @return Number of characters written.
2128 + */
2129 +int pspDebugSioPutText(const char *data, int len);
2131 +/**
2132 + * Initialise the remote SIO port (defaults to 4800 8N1).
2133 + * @note will delay 2 seconds to wait for the power to come up.
2134 + */
2135 +void pspDebugSioInit(void);
2137 +/**
2138 + * Set the baud rate of the SIO, e.g. 4800/9600..115200.
2139 + * @param baud - The baudrate to set.
2140 + */
2141 +void pspDebugSioSetBaud(int baud);
2143 +/**
2144 + * Enable debug character output. Needs to be called in order
2145 + * for the default Kprintf handler to work.
2146 + */
2147 +void pspDebugEnablePutchar(void);
2149 +/**
2150 + * Install a kprintf debug putchar handler. Implicitly calls ::pspDebugEnablePutchar
2151 + * so you do not need to call it explicitly. Sio must be initialised before calling
2152 + * this function however.
2153 + */
2154 +void pspDebugSioInstallKprintf(void);
2156 +/**
2157 + * Install the gdb stub handler.
2158 + */
2159 +void pspDebugGdbStubInit(void);
2161 +/**
2162 + * Generate a breakpoint exception.
2163 + */
2164 +void pspDebugBreakpoint(void);
2166 +/**
2167 + * Enable the kprintf handler (once installed)
2168 + */
2169 +void pspDebugSioEnableKprintf(void);
2171 +/**
2172 + * Disable the kprintf handler (once installed)
2173 + */
2174 +void pspDebugSioDisableKprintf(void);
2176 +/**@}*/
2178 +#ifdef __cplusplus
2180 +#endif
2182 +#endif
2183 diff --git a/newlib/psp/include/pspdebugkb.h b/newlib/psp/include/pspdebugkb.h
2184 new file mode 100644
2185 index 0000000..c74bfd9
2186 --- /dev/null
2187 +++ b/newlib/psp/include/pspdebugkb.h
2188 @@ -0,0 +1,95 @@
2190 + * PSP Software Development Kit - https://github.com/pspdev
2191 + * -----------------------------------------------------------------------
2192 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
2194 + * pspdebugkb.h - Simple screen debug keyboard
2196 + * Copyright (c) 2006 Mike Mallett <mike@nerdcore.net>
2198 + */
2200 +#ifndef __PSPDEBUGKB_H
2201 +#define __PSPDEBUGKB_H
2203 +#ifdef __cplusplus
2204 +extern "C" {
2205 +#endif
2207 +enum PspDebugKbSettings {
2208 + /** Maximum string length */
2209 + PSP_DEBUG_KB_MAXLEN = 40,
2210 + /** Place the box' upper-left corner at this location */
2211 + PSP_DEBUG_KB_BOX_X = 6,
2212 + PSP_DEBUG_KB_BOX_Y = 8,
2213 + /** FG and BG colour of unhighlighted characters */
2214 + PSP_DEBUG_KB_CHAR_COLOUR = 0xffffffff,
2215 + PSP_DEBUG_KB_BACK_COLOUR = 0xff000000,
2216 + /** FG and BG colour of highlighted character */
2217 + PSP_DEBUG_KB_CHAR_HIGHLIGHT = 0xff00ff00,
2218 + PSP_DEBUG_KB_BACK_HIGHLIGHT = 0xff101010,
2219 + /** Indent the printed characters by (X_OFFSET,Y_OFFSET) */
2220 + PSP_DEBUG_KB_OFFSET_X = 6,
2221 + PSP_DEBUG_KB_OFFSET_Y = 4,
2222 + /** Distance from one character to the next */
2223 + PSP_DEBUG_KB_SPACING_X = 3,
2224 + PSP_DEBUG_KB_SPACING_Y = 2,
2225 + /** Number of columns/rows (respectively) in charTable(s) */
2226 + PSP_DEBUG_KB_NUM_CHARS = 13,
2227 + PSP_DEBUG_KB_NUM_ROWS = 4,
2228 + /** Box width and height */
2229 + PSP_DEBUG_KB_BOX_WIDTH = (PSP_DEBUG_KB_NUM_CHARS * PSP_DEBUG_KB_SPACING_X) + (2 * PSP_DEBUG_KB_OFFSET_X),
2230 + PSP_DEBUG_KB_BOX_HEIGHT = ((PSP_DEBUG_KB_NUM_ROWS + 1) * PSP_DEBUG_KB_SPACING_Y) + PSP_DEBUG_KB_OFFSET_Y,
2231 + /** Array index of commandRow */
2232 + PSP_DEBUG_KB_COMMAND_ROW = 4,
2233 + /** Number of commands on bottom row */
2234 + PSP_DEBUG_KB_NUM_COMMANDS = 5
2237 +/**
2238 + * Switch charTable when SHIFT is pressed
2240 + * @param shiftState - Pointer to an int indicating Caps Lock
2241 + */
2242 +void pspDebugKbShift(int *shiftState);
2244 +/**
2245 + * Draw the specified key on the keyboard.
2247 + * @param row - The row of the character to print (in charTable)
2248 + * @param col - The column of the character to print (in charTable)
2249 + * @param highlight - 0 for plain; otherwise highlighted
2250 + */
2251 +void pspDebugKbDrawKey(int row, int col, int highlight);
2253 +/**
2254 + * Draw the string at the top of the box
2256 + * @param str - The string to print
2257 + */
2258 +void pspDebugKbDrawString(char *str);
2260 +/**
2261 + * Clear the area where the box resides.
2262 + * Called from pspDebugKbDrawBox and pspDebugKbInit (on exit).
2263 + */
2264 +void pspDebugKbClearBox();
2266 +/**
2267 + * Draw the entire box on the desbug screen.
2268 + * Called from shift() and doInputBox(char*)
2269 + */
2270 +void pspDebugKbDrawBox();
2272 +/**
2273 + * Make the text box happen
2275 + * @param str - The string to edit
2276 + */
2277 +void pspDebugKbInit(char *str);
2279 +#ifdef __cplusplus
2281 +#endif
2283 +#endif
2284 diff --git a/newlib/psp/include/pspdisplay.h b/newlib/psp/include/pspdisplay.h
2285 new file mode 100644
2286 index 0000000..c72ca31
2287 --- /dev/null
2288 +++ b/newlib/psp/include/pspdisplay.h
2289 @@ -0,0 +1,153 @@
2291 + * PSP Software Development Kit - https://github.com/pspdev
2292 + * -----------------------------------------------------------------------
2293 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
2295 + * pspdisplay.h - Prototypes for the sceDisplay library.
2297 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
2298 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
2299 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
2300 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
2302 + */
2303 +#ifndef __DISPLAY_H__
2304 +#define __DISPLAY_H__
2306 +#ifdef __cplusplus
2307 +extern "C" {
2308 +#endif
2310 +/** Framebuffer pixel formats. */
2311 +enum PspDisplayPixelFormats {
2312 + /** 16-bit RGB 5:6:5. */
2313 + PSP_DISPLAY_PIXEL_FORMAT_565 = 0,
2314 + /** 16-bit RGBA 5:5:5:1. */
2315 + PSP_DISPLAY_PIXEL_FORMAT_5551,
2316 + /* 16-bit RGBA 4:4:4:4. */
2317 + PSP_DISPLAY_PIXEL_FORMAT_4444,
2318 + /* 32-bit RGBA 8:8:8:8. */
2319 + PSP_DISPLAY_PIXEL_FORMAT_8888
2322 +enum PspDisplaySetBufSync {
2323 + /** Buffer change effective immediately */
2324 + PSP_DISPLAY_SETBUF_IMMEDIATE = 0,
2325 + /** Buffer change effective next frame */
2326 + PSP_DISPLAY_SETBUF_NEXTFRAME = 1
2330 +enum PspDisplayErrorCodes
2332 + SCE_DISPLAY_ERROR_OK = 0,
2333 + SCE_DISPLAY_ERROR_POINTER = 0x80000103,
2334 + SCE_DISPLAY_ERROR_ARGUMENT = 0x80000107
2338 +/**
2339 + * Set display mode
2341 + * @par Example1:
2342 + * @code
2343 + * @endcode
2345 + * @param mode - Display mode, normally 0.
2346 + * @param width - Width of screen in pixels.
2347 + * @param height - Height of screen in pixels.
2349 + * @return ???
2350 + */
2351 +int sceDisplaySetMode(int mode, int width, int height);
2353 +/**
2354 + * Get display mode
2356 + * @param pmode - Pointer to an integer to receive the current mode.
2357 + * @param pwidth - Pointer to an integer to receive the current width.
2358 + * @param pheight - Pointer to an integer to receive the current height,
2360 + * @return 0 on success
2361 + */
2362 +int sceDisplayGetMode(int *pmode, int *pwidth, int *pheight);
2364 +/**
2365 + * Display set framebuf
2367 + * @param topaddr - address of start of framebuffer
2368 + * @param bufferwidth - buffer width (must be power of 2)
2369 + * @param pixelformat - One of ::PspDisplayPixelFormats.
2370 + * @param sync - One of ::PspDisplaySetBufSync
2372 + * @return 0 on success
2373 + */
2374 +int sceDisplaySetFrameBuf(void *topaddr, int bufferwidth, int pixelformat, int sync);
2376 +/**
2377 + * Get Display Framebuffer information
2379 + * @param topaddr - pointer to void* to receive address of start of framebuffer
2380 + * @param bufferwidth - pointer to int to receive buffer width (must be power of 2)
2381 + * @param pixelformat - pointer to int to receive one of ::PspDisplayPixelFormats.
2382 + * @param sync - One of ::PspDisplaySetBufSync
2384 + * @return 0 on success
2385 + */
2386 +int sceDisplayGetFrameBuf(void **topaddr, int *bufferwidth, int *pixelformat, int sync);
2388 +/**
2389 + * Number of vertical blank pulses up to now
2390 + */
2391 +unsigned int sceDisplayGetVcount(void);
2393 +/**
2394 + * Wait for vertical blank start
2395 + */
2396 +int sceDisplayWaitVblankStart(void);
2398 +/**
2399 + * Wait for vertical blank start with callback
2400 + */
2401 +int sceDisplayWaitVblankStartCB(void);
2403 +/**
2404 + * Wait for vertical blank
2405 + */
2406 +int sceDisplayWaitVblank(void);
2408 +/**
2409 + * Wait for vertical blank with callback
2410 + */
2411 +int sceDisplayWaitVblankCB(void);
2413 +/**
2414 + * Get accumlated HSYNC count
2415 + */
2416 +int sceDisplayGetAccumulatedHcount(void);
2418 +/**
2419 + * Get current HSYNC count
2420 + */
2421 +int sceDisplayGetCurrentHcount(void);
2423 +/**
2424 + * Get number of frames per second
2425 + */
2426 +float sceDisplayGetFramePerSec(void);
2428 +/**
2429 + * Get whether or not frame buffer is being displayed
2430 + */
2431 +int sceDisplayIsForeground(void);
2433 +/**
2434 + * Test whether VBLANK is active
2435 + */
2436 +int sceDisplayIsVblank(void);
2438 +#ifdef __cplusplus
2440 +#endif
2442 +#endif
2443 diff --git a/newlib/psp/include/pspdisplay_kernel.h b/newlib/psp/include/pspdisplay_kernel.h
2444 new file mode 100644
2445 index 0000000..b63fccd
2446 --- /dev/null
2447 +++ b/newlib/psp/include/pspdisplay_kernel.h
2448 @@ -0,0 +1,71 @@
2450 + * PSP Software Development Kit - https://github.com/pspdev
2451 + * -----------------------------------------------------------------------
2452 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
2454 + * pspdisplay_kernel.h - Prototypes for the sceDisplay_driver library.
2456 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
2457 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
2458 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
2459 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
2461 + */
2462 +#ifndef __DISPLAYKERNEL_H__
2463 +#define __DISPLAYKERNEL_H__
2465 +#ifdef __cplusplus
2466 +extern "C" {
2467 +#endif
2469 +/**
2470 + * Display set framebuf
2472 + * @param pri - Priority
2473 + * @param topaddr - address of start of framebuffer
2474 + * @param bufferwidth - buffer width (must be power of 2)
2475 + * @param pixelformat - One of ::PspDisplayPixelFormats.
2476 + * @param sync - One of ::PspDisplaySetBufSync
2478 + * @return 0 on success
2479 + */
2480 +int sceDisplay_driver_63E22A26(int pri, void *topaddr, int bufferwidth, int pixelformat, int sync);
2482 +/**
2483 + * Get Display Framebuffer information
2485 + * @param pri - Priority
2486 + * @param topaddr - pointer to void* to receive address of start of framebuffer
2487 + * @param bufferwidth - pointer to int to receive buffer width (must be power of 2)
2488 + * @param pixelformat - pointer to int to receive one of ::PspDisplayPixelFormats.
2489 + * @param sync - One of ::PspDisplaySetBufSync
2491 + * @return 0 on success
2492 + */
2493 +int sceDisplay_driver_5B5AEFAD(int pri, void **topaddr, int *bufferwidth, int *pixelformat, int sync);
2495 +/* Define some names to make it nicer */
2496 +#define sceDisplaySetFrameBufferInternal sceDisplay_driver_63E22A26
2497 +#define sceDisplayGetFrameBufferInternal sceDisplay_driver_5B5AEFAD
2499 +/**
2500 + * Set Display brightness to a particular level
2502 + * @param level - Level of the brightness. it goes from 0 (black screen) to 100 (max brightness)
2503 + * @param unk1 - Unknown can be 0 or 1 (pass 0)
2504 + */
2505 +void sceDisplaySetBrightness(int level,int unk1);
2507 +/**
2508 + * Get current display brightness
2510 + * @param level - Pointer to int to receive the current brightness level (0-100)
2511 + * @param unk1 - Pointer to int, receives unknown, it's 1 or 0
2512 + */
2513 +void sceDisplayGetBrightness(int *level,int *unk1);
2515 +#ifdef __cplusplus
2517 +#endif
2519 +#endif
2520 diff --git a/newlib/psp/include/pspdmac.h b/newlib/psp/include/pspdmac.h
2521 new file mode 100644
2522 index 0000000..f538e38
2523 --- /dev/null
2524 +++ b/newlib/psp/include/pspdmac.h
2525 @@ -0,0 +1,24 @@
2527 + * PSP Software Development Kit - http://www.pspdev.org
2528 + * -----------------------------------------------------------------------
2529 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
2531 + * dmac.c - A DMAC function
2533 + * Copyright (c) 2016 173210 <root.3.173210@live.com>
2534 + */
2536 +#include <psptypes.h>
2538 +/**
2539 + * Copy data in memory using DMAC
2541 + * @param dst - The pointer to the destination
2542 + * @param src - The pointer to the source
2543 + * @param n - The size of data
2545 + * @return 0 on success; otherwise an error code
2546 + */
2547 +int sceDmacMemcpy(void *dst, const void *src, SceSize n);
2549 +int sceDmacTryMemcpy(void *dst, const void *src, SceSize n);
2550 diff --git a/newlib/psp/include/pspexception.h b/newlib/psp/include/pspexception.h
2551 new file mode 100644
2552 index 0000000..3779717
2553 --- /dev/null
2554 +++ b/newlib/psp/include/pspexception.h
2555 @@ -0,0 +1,56 @@
2557 + * PSP Software Development Kit - https://github.com/pspdev
2558 + * -----------------------------------------------------------------------
2559 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
2561 + * pspexception.h - Interface to the kernel side of ExceptionMan
2563 + * Copyright (c) 2006 James F.
2565 + */
2567 +#ifndef PSPEXCEPTION_H
2568 +#define PSPEXCEPTION_H
2570 +#include <pspkerneltypes.h>
2572 +#ifdef __cplusplus
2573 +extern "C" {
2574 +#endif
2576 +/**
2577 + * Register a default exception handler.
2579 + * @param func - Pointer to the exception handler function
2580 + * @note The exception handler function must start with a NOP
2582 + * @return 0 on success, < 0 on error
2583 + */
2584 +int sceKernelRegisterDefaultExceptionHandler(void *func);
2586 +/**
2587 + * Register a exception handler
2588 + *
2589 + * @param exno - The exception number
2590 + * @param func - Pointer to the exception handler function
2592 + * @return 0 on success, < 0 on error
2593 + */
2594 +int sceKernelRegisterExceptionHandler(int exno, void *func);
2596 +/**
2597 + * Register a exception handler with a priority
2598 + *
2599 + * @param exno - The exception number
2600 + * @param priority - The priority of the exception
2601 + * @param func - Pointer to the exception handler function
2603 + * @return 0 on success, < 0 on error
2604 + */
2605 +int sceKernelRegisterPriorityExceptionHandler(int exno, int priority, void *func);
2607 +#ifdef __cplusplus
2609 +#endif
2611 +#endif /* PSPEXCEPTION_H */
2612 diff --git a/newlib/psp/include/pspfpu.h b/newlib/psp/include/pspfpu.h
2613 new file mode 100644
2614 index 0000000..f5f4399
2615 --- /dev/null
2616 +++ b/newlib/psp/include/pspfpu.h
2617 @@ -0,0 +1,410 @@
2619 + * PSP Software Development Kit - https://github.com/pspdev
2620 + * -----------------------------------------------------------------------
2621 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
2623 + * pspfpu.h - Prototypes for the FPU library
2625 + * Copyright (c) 2009 JetCube
2626 + * Copyright (c) 2006 TyRaNiD (James F.)
2628 + */
2629 +#ifndef __PSPFPU_H__
2630 +#define __PSPFPU_H__
2632 +#include <stdint.h>
2634 +/* Note the bit settings in here come from an NEC MIPSv4 document,
2635 + * they seem sensible.
2636 + */
2638 +#ifdef __cplusplus
2639 +extern "C" {
2640 +#endif
2642 +/** Enumeration for FPU rounding modes */
2643 +enum PspFpuRoundMode
2645 + /** Round to nearest representable value */
2646 + PSP_FPU_RN = 0,
2647 + /** Round towards zero */
2648 + PSP_FPU_RZ = 1,
2649 + /** Round towards plus infinity */
2650 + PSP_FPU_RP = 2,
2651 + /** Round towards minus infinity */
2652 + PSP_FPU_RM = 3,
2655 +/** Mask value for rounding mode */
2656 +#define PSP_FPU_RM_MASK 0x03
2658 +/** Enumeration for FPU exceptions */
2659 +enum PspFpuExceptions
2661 + /** Inexact operation exception */
2662 + PSP_FPU_EXCEPTION_INEXACT = 0x01,
2663 + /** Underflow exception */
2664 + PSP_FPU_EXCEPTION_UNDERFLOW = 0x02,
2665 + /** Overflow exception */
2666 + PSP_FPU_EXCEPTION_OVERFLOW = 0x04,
2667 + /** Division by zero exception */
2668 + PSP_FPU_EXCEPTION_DIVBYZERO = 0x08,
2669 + /** Invalid operation exception */
2670 + PSP_FPU_EXCEPTION_INVALIDOP = 0x10,
2671 + /** Unimplemented operation exception (only supported in the cause bits) */
2672 + PSP_FPU_EXCEPTION_UNIMPOP = 0x20,
2673 + /** All exceptions */
2674 + PSP_FPU_EXCEPTION_ALL = 0x3F
2677 +/** Bit position of the flag bits */
2678 +#define PSP_FPU_FLAGS_POS 2
2679 +/** Bit position of the enable bits */
2680 +#define PSP_FPU_ENABLE_POS 7
2681 +/** Bit position of the cause bits */
2682 +#define PSP_FPU_CAUSE_POS 12
2683 +/** Bit position of the cc0 bit */
2684 +#define PSP_FPU_CC0_POS 23
2685 +/** Bit position of the fs bit */
2686 +#define PSP_FPU_FS_POS 24
2687 +/** Bit position of the cc1->7 bits */
2688 +#define PSP_FPU_CC17_POS 25
2690 +#define PSP_FPU_FLAGS_MASK (0x1F << PSP_FPU_FLAGS_POS)
2691 +#define PSP_FPU_ENABLE_MASK (0x1F << PSP_FPU_ENABLE_POS)
2692 +#define PSP_FPU_CAUSE_MASK (0x3F << PSP_FPU_CAUSE_POS)
2693 +#define PSP_FPU_CC0_MASK (1 << PSP_FPU_CC0_POS)
2694 +#define PSP_FPU_FS_MASK (1 << PSP_FPU_FS_POS)
2695 +#define PSP_FPU_CC17_MASK (0x7F << PSP_FPU_CC17_POS)
2697 +/**
2698 + * Get the current value of the control/status register
2700 + * @return The value of the control/status register
2701 + */
2702 +uint32_t pspFpuGetFCR31(void);
2704 +/**
2705 + * Set the current value of the control/status register
2707 + * @param var - The value to set.
2708 + */
2709 +void pspFpuSetFCR31(uint32_t var);
2711 +/**
2712 + * Set the current round mode
2714 + * @param mode - The rounding mode to set, one of ::PspFpuRoundMode
2715 + */
2716 +void pspFpuSetRoundmode(enum PspFpuRoundMode mode);
2718 +/**
2719 + * Get the current round mode
2721 + * @return The round mode, one of ::PspFpuRoundMode
2722 + */
2723 +enum PspFpuRoundMode pspFpuGetRoundmode(void);
2725 +/**
2726 + * Get the exception flags (set when an exception occurs but
2727 + * the actual exception bit is not enabled)
2729 + * @return Bitmask of the flags, zero or more of ::PspFpuExceptions
2730 + */
2731 +uint32_t pspFpuGetFlags(void);
2733 +/**
2734 + * Clear the flags bits
2736 + * @param clear - Bitmask of the bits to clear, one or more of ::PspFpuExceptions
2737 + */
2738 +void pspFpuClearFlags(uint32_t clear);
2740 +/**
2741 + * Get the exception enable flags
2743 + * @return Bitmask of the flags, zero or more of ::PspFpuExceptions
2744 + */
2745 +uint32_t pspFpuGetEnable(void);
2747 +/**
2748 + * Set the enable flags bits
2750 + * @param enable - Bitmask of exceptions to enable, zero or more of ::PspFpuExceptions
2751 + */
2752 +void pspFpuSetEnable(uint32_t enable);
2754 +/**
2755 + * Get the cause bits (only useful if you installed your own exception handler)
2757 + * @return Bitmask of flags, zero or more of ::PspFpuExceptions
2758 + */
2759 +uint32_t pspFpuGetCause(void);
2761 +/**
2762 + * Clear the cause bits
2764 + * @param clear - Bitmask of the bits to clear, one or more of ::PspFpuExceptions
2766 + */
2767 +void pspFpuClearCause(uint32_t clear);
2769 +/**
2770 + * Get the current value of the FS bit (if FS is 0 then an exception occurs with
2771 + * denormalized values, if 1 then they are rewritten as 0.
2773 + * @return The current state of the FS bit (0 or 1)
2774 + */
2775 +uint32_t pspFpuGetFS(void);
2777 +/**
2778 + * Set the FS bit
2780 + * @param fs - 0 or 1 to unset or set fs
2781 + */
2782 +void pspFpuSetFS(uint32_t fs);
2784 +/**
2785 + * Get the condition flags (8 bits)
2787 + * @return The current condition flags
2788 + */
2789 +uint32_t pspFpuGetCondbits(void);
2791 +/**
2792 + * Clear the condition bits
2794 + * @param clear - Bitmask of the bits to clear
2795 + */
2796 +void pspFpuClearCondbits(uint32_t clear);
2798 +/**
2799 + * returns absolute value
2800 + */
2801 +float pspFpuAbs(float f);
2803 +/**
2804 + * Round up
2805 + */
2806 +int pspFpuCeil(float f);
2808 +/**
2809 + * Truncate
2810 + */
2811 +int pspFpuFloor(float f);
2813 +/**
2814 + * select maximum value
2815 + */
2816 +float pspFpuMax(float f1, float f2);
2818 +/**
2819 + * select minimum value
2820 + */
2821 +float pspFpuMin(float f1, float f2);
2823 +/**
2824 + * Sign reversal
2825 + */
2826 +float pspFpuNeg(float f);
2828 +/**
2829 + * Round to nearest
2830 + */
2831 +int pspFpuRound(float f);
2834 + * Reciprocal of square root
2835 + */
2836 +float pspFpuRsqrt(float f);
2838 +/**
2839 + * Square root
2840 + */
2841 +float pspFpuSqrt(float f);
2843 +/**
2844 + * Round towards zero
2845 + */
2846 +int pspFpuTrunc(float f);
2848 +/**
2850 + */
2851 +float pspFpuFmod(float fs, float fd);
2853 +/**
2855 + */
2856 +float pspFpuFrac(float f);
2858 +/**
2860 + */
2861 +float pspFpuReinterpretFloat(uint32_t ui);
2863 +/**
2865 + */
2866 +uint32_t pspFpuReinterpretUint(float f);
2868 +/**
2870 + */
2871 +int pspFpuIsEqual(float f1, float f2);
2873 +/**
2875 + */
2876 +float pspFpuSignFloat(float f);
2878 +/**
2880 + */
2881 +int pspFpuSignInt(float f);
2883 +/**
2884 + * Positive zero
2885 + */
2886 +float pspFpuPositiveZero(void);
2888 +/**
2889 + * Negative zero
2890 + */
2891 +float pspFpuNegativeZero(void);
2893 +/**
2894 + * Test for zero value
2895 + */
2896 +int pspFpuIsZero(float f);
2898 +/**
2899 + * Test for positive zero
2900 + */
2901 +int pspFpuIsPositiveZero(float f);
2903 +/**
2904 + * Test for negative zero
2905 + */
2906 +int pspFpuIsNegativeZero(float f);
2908 +/**
2909 + * Test for denormalized number
2910 + */
2911 +int pspFpuIsDenormal(float f);
2913 +/**
2914 + * Test for zero or denormalized number
2915 + */
2916 +int pspFpuIsZeroOrDenormal(float f);
2918 +/**
2919 + * Positive infinity
2920 + */
2921 +float pspFpuPositiveInf(void);
2923 +/**
2924 + * Negative infinity
2925 + */
2926 +float pspFpuNegativeInf(void);
2928 +/**
2929 + * Test for infinity
2930 + */
2931 +int pspFpuIsInf(float f);
2933 +/**
2934 + * NaN (positive SNaN)
2935 + */
2936 +float pspFpuPositiveNaN(void);
2938 +/**
2939 + * NaN (negative SNaN)
2940 + */
2941 +float pspFpuNegativeNaN(void);
2943 +/**
2944 + * Quiet NaN (positive QNaN)
2945 + */
2946 +float pspFpuPositiveQNaN(void);
2948 +/**
2949 + * Quiet NaN (positive QNaN)
2950 + */
2951 +float pspFpuNegativeQNaN(void);
2953 +/**
2954 + * Signaling NaN (positive SNaN)
2955 + */
2956 +float pspFpuPositiveSNaN(unsigned int uiSignal);
2958 +/**
2959 + * Signaling NaN (negative SNaN)
2960 + */
2961 +float pspFpuNegativeSNaN(unsigned int uiSignal);
2963 +/**
2964 + * Test for NaN
2965 + */
2966 +int pspFpuIsNaN(float f);
2968 +/**
2969 + * Test for infinity or NaN
2970 + */
2971 +int pspFpuIsInfOrNaN(float f);
2973 +/**
2975 + */
2976 +float pspFpuNormalizePhase(float f);
2978 +/**
2979 + * Sine
2980 + */
2981 +float pspFpuSin(float x);
2983 +/**
2984 + * Cosine
2985 + */
2986 +float pspFpuCos(float x);
2988 +/**
2989 + * Arc tangent
2990 + */
2991 +float pspFpuAtan(float x);
2993 +/**
2994 + * Natural Logarithm
2995 + */
2996 +float pspFpuLog(float x);
2998 +/**
2999 + * Exponential
3000 + */
3001 +float pspFpuExp(float x);
3003 +/**
3004 + * ArcSin
3005 + */
3006 +float pspFpuAsin(float x);
3008 +/**
3009 + * ArcCos
3010 + */
3011 +float pspFpuAcos(float x);
3013 +/**
3014 + * convert float to double
3015 + */
3016 +double pspFpuFloatToDouble(float a);
3018 +/**
3019 + * convert double to float
3020 + */
3021 +float pspFpuDoubleToFloat(double a);
3023 +#ifdef __cplusplus
3025 +#endif
3027 +#endif /* __PSPFPU_H__ */
3028 diff --git a/newlib/psp/include/pspge.h b/newlib/psp/include/pspge.h
3029 new file mode 100644
3030 index 0000000..2640171
3031 --- /dev/null
3032 +++ b/newlib/psp/include/pspge.h
3033 @@ -0,0 +1,279 @@
3035 + * PSP Software Development Kit - https://github.com/pspdev
3036 + * -----------------------------------------------------------------------
3037 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
3039 + * pspge.h - Prototypes for the sceGe library.
3041 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
3042 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
3043 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
3045 + */
3046 +#ifndef __GE_H__
3047 +#define __GE_H__
3049 +#include <psptypes.h>
3051 +#ifdef __cplusplus
3052 +extern "C" {
3053 +#endif
3055 +/** Stores the state of the GE. */
3056 +typedef struct PspGeContext {
3057 + unsigned int context[512];
3058 +} PspGeContext;
3060 +/** Structure storing a stack (for CALL/RET) */
3061 +typedef struct
3063 + /** The stack buffer */
3064 + unsigned int stack[8];
3065 +} SceGeStack;
3067 +/** Typedef for a GE callback */
3068 +typedef void (*PspGeCallback)(int id, void *arg);
3070 +/** Structure to hold the callback data */
3071 +typedef struct PspGeCallbackData
3073 + /** GE callback for the signal interrupt */
3074 + PspGeCallback signal_func;
3075 + /** GE callback argument for signal interrupt */
3076 + void *signal_arg;
3077 + /** GE callback for the finish interrupt */
3078 + PspGeCallback finish_func;
3079 + /** GE callback argument for finish interrupt */
3080 + void *finish_arg;
3081 +} PspGeCallbackData;
3083 +typedef struct PspGeListArgs
3085 + /** Size of the structure (16) */
3086 + unsigned int size;
3087 + /** Pointer to a context */
3088 + PspGeContext* context;
3089 + /** Number of stacks to use */
3090 + u32 numStacks;
3091 + /** Pointer to the stacks (unused) */
3092 + SceGeStack *stacks;
3093 +} PspGeListArgs;
3095 +/**
3096 + * Drawing queue interruption parameter
3097 + */
3098 +typedef struct PspGeBreakParam {
3099 + unsigned int buf[4];
3100 +} PspGeBreakParam;
3102 +/**
3103 + * Get the size of VRAM.
3105 + * @return The size of VRAM (in bytes).
3106 + */
3107 +unsigned int sceGeEdramGetSize(void);
3109 +/**
3110 + * Get the eDRAM address.
3112 + * @return A pointer to the base of the eDRAM.
3113 + */
3114 +void * sceGeEdramGetAddr(void);
3116 +/**
3117 + * Retrieve the current value of a GE command.
3119 + * @param cmd - The GE command register to retrieve (0 to 0xFF, both included).
3121 + * @return The value of the GE command, < 0 on error.
3122 + */
3123 +unsigned int sceGeGetCmd(int cmd);
3125 +/** GE matrix types. */
3126 +typedef enum PspGeMatrixTypes {
3127 + /** Bone matrices. */
3128 + PSP_GE_MATRIX_BONE0 = 0,
3129 + PSP_GE_MATRIX_BONE1,
3130 + PSP_GE_MATRIX_BONE2,
3131 + PSP_GE_MATRIX_BONE3,
3132 + PSP_GE_MATRIX_BONE4,
3133 + PSP_GE_MATRIX_BONE5,
3134 + PSP_GE_MATRIX_BONE6,
3135 + PSP_GE_MATRIX_BONE7,
3136 + /** World matrix. */
3137 + PSP_GE_MATRIX_WORLD,
3138 + /** View matrix. */
3139 + PSP_GE_MATRIX_VIEW,
3140 + /** Projection matrix. */
3141 + PSP_GE_MATRIX_PROJECTION,
3142 + PSP_GE_MATRIX_TEXGEN
3143 +} PspGeMatrixTypes;
3145 +/**
3146 + * Retrieve a matrix of the given type.
3148 + * @param type - One of ::PspGeMatrixTypes.
3149 + * @param matrix - Pointer to a variable to store the matrix.
3151 + * @return < 0 on error.
3152 + */
3153 +int sceGeGetMtx(int type, void *matrix);
3155 +/** Structure storing a stack (for CALL/RET). */
3156 +typedef struct
3158 + /** The stack buffer. */
3159 + unsigned int stack[8];
3160 +} PspGeStack;
3162 +/**
3163 + * Retrieve the stack of the display list currently being executed.
3165 + * @param stackId - The ID of the stack to retrieve.
3166 + * @param stack - Pointer to a structure to store the stack, or NULL to not store it.
3168 + * @return The number of stacks of the current display list, < 0 on error.
3169 + */
3170 +int sceGeGetStack(int stackId, PspGeStack *stack);
3172 +/**
3173 + * Save the GE's current state.
3175 + * @param context - Pointer to a ::PspGeContext.
3177 + * @return < 0 on error.
3178 + */
3179 +int sceGeSaveContext(PspGeContext *context);
3181 +/**
3182 + * Restore a previously saved GE context.
3184 + * @param context - Pointer to a ::PspGeContext.
3186 + * @return < 0 on error.
3187 + */
3188 +int sceGeRestoreContext(const PspGeContext *context);
3190 +/**
3191 + * Enqueue a display list at the tail of the GE display list queue.
3193 + * @param list - The head of the list to queue.
3194 + * @param stall - The stall address.
3195 + * If NULL then no stall address is set and the list is transferred immediately.
3196 + * @param cbid - ID of the callback set by calling sceGeSetCallback
3197 + * @param arg - Structure containing GE context buffer address
3199 + * @return The ID of the queue, < 0 on error.
3200 + */
3201 +int sceGeListEnQueue(const void *list, void *stall, int cbid, PspGeListArgs *arg);
3203 +/**
3204 + * Enqueue a display list at the head of the GE display list queue.
3206 + * @param list - The head of the list to queue.
3207 + * @param stall - The stall address.
3208 + * If NULL then no stall address is set and the list is transferred immediately.
3209 + * @param cbid - ID of the callback set by calling sceGeSetCallback
3210 + * @param arg - Structure containing GE context buffer address
3212 + * @return The ID of the queue, < 0 on error.
3213 + */
3214 +int sceGeListEnQueueHead(const void *list, void *stall, int cbid, PspGeListArgs *arg);
3216 +/**
3217 + * Cancel a queued or running list.
3219 + * @param qid - The ID of the queue.
3221 + * @return < 0 on error.
3222 + */
3223 +int sceGeListDeQueue(int qid);
3225 +/**
3226 + * Update the stall address for the specified queue.
3228 + * @param qid - The ID of the queue.
3229 + * @param stall - The new stall address.
3231 + * @return < 0 on error
3232 + */
3233 +int sceGeListUpdateStallAddr(int qid, void *stall);
3236 +/** List status for ::sceGeListSync() and ::sceGeDrawSync(). */
3237 +typedef enum PspGeListState {
3238 + PSP_GE_LIST_DONE = 0,
3239 + PSP_GE_LIST_QUEUED,
3240 + PSP_GE_LIST_DRAWING_DONE,
3241 + PSP_GE_LIST_STALL_REACHED,
3242 + PSP_GE_LIST_CANCEL_DONE
3243 +} PspGeListState;
3245 +/**
3246 + * Wait for syncronisation of a list.
3248 + * @param qid - The queue ID of the list to sync.
3249 + * @param syncType - 0 if you want to wait for the list to be completed, or 1 if you just want to peek the actual state.
3251 + * @return The specified queue status, one of ::PspGeListState.
3252 + */
3253 +int sceGeListSync(int qid, int syncType);
3255 +/**
3256 + * Wait for drawing to complete.
3258 + * @param syncType - 0 if you want to wait for the drawing to be completed, or 1 if you just want to peek the state of the display list currently being executed.
3260 + * @return The current queue status, one of ::PspGeListState.
3261 + */
3262 +int sceGeDrawSync(int syncType);
3264 +/**
3265 + * Register callback handlers for the the GE.
3267 + * @param cb - Configured callback data structure.
3269 + * @return The callback ID, < 0 on error.
3270 + */
3271 +int sceGeSetCallback(PspGeCallbackData *cb);
3273 +/**
3274 + * Unregister the callback handlers.
3276 + * @param cbid - The ID of the callbacks, returned by sceGeSetCallback().
3278 + * @return < 0 on error
3279 + */
3280 +int sceGeUnsetCallback(int cbid);
3282 +/**
3283 + * Interrupt drawing queue.
3285 + * @param mode - If set to 1, reset all the queues.
3286 + * @param pParam - Unused (just K1-checked).
3288 + * @return The stopped queue ID if mode isn't set to 0, otherwise 0, and < 0 on error.
3289 + */
3290 +int sceGeBreak(int mode, PspGeBreakParam *pParam);
3292 +/**
3293 + * Restart drawing queue.
3295 + * @return < 0 on error.
3296 + */
3297 +int sceGeContinue(void);
3299 +/**
3300 + * Set the eDRAM address translation mode.
3302 + * @param width - 0 to not set the translation width, otherwise 512, 1024, 2048 or 4096.
3304 + * @return The previous width if it was set, otherwise 0, < 0 on error.
3305 + */
3306 +int sceGeEdramSetAddrTranslation(int width);
3308 +#ifdef __cplusplus
3310 +#endif
3312 +#endif /* __GE_H__ */
3313 diff --git a/newlib/psp/include/pspgu.h b/newlib/psp/include/pspgu.h
3314 new file mode 100644
3315 index 0000000..22bf120
3316 --- /dev/null
3317 +++ b/newlib/psp/include/pspgu.h
3318 @@ -0,0 +1,1487 @@
3320 + * PSP Software Development Kit - https://github.com/pspdev
3321 + * -----------------------------------------------------------------------
3322 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
3324 + * Copyright (c) 2005 Jesper Svennevid
3325 + */
3327 +#ifndef __pspgu_h__
3328 +#define __pspgu_h__
3330 +#include <psptypes.h>
3331 +#include <pspge.h>
3333 +/** @defgroup GU Graphics Utility Library
3335 + */
3337 +#if defined(__cplusplus)
3338 +extern "C" {
3339 +#endif
3341 +/* PI, float-sized */
3342 +#define GU_PI (3.141593f)
3344 +/* Boolean values for convenience */
3345 +#define GU_FALSE (0)
3346 +#define GU_TRUE (1)
3348 +/* Primitive types */
3349 +#define GU_POINTS (0)
3350 +#define GU_LINES (1)
3351 +#define GU_LINE_STRIP (2)
3352 +#define GU_TRIANGLES (3)
3353 +#define GU_TRIANGLE_STRIP (4)
3354 +#define GU_TRIANGLE_FAN (5)
3355 +#define GU_SPRITES (6)
3357 +/* States */
3358 +#define GU_ALPHA_TEST (0)
3359 +#define GU_DEPTH_TEST (1)
3360 +#define GU_SCISSOR_TEST (2)
3361 +#define GU_STENCIL_TEST (3)
3362 +#define GU_BLEND (4)
3363 +#define GU_CULL_FACE (5)
3364 +#define GU_DITHER (6)
3365 +#define GU_FOG (7)
3366 +#define GU_CLIP_PLANES (8)
3367 +#define GU_TEXTURE_2D (9)
3368 +#define GU_LIGHTING (10)
3369 +#define GU_LIGHT0 (11)
3370 +#define GU_LIGHT1 (12)
3371 +#define GU_LIGHT2 (13)
3372 +#define GU_LIGHT3 (14)
3373 +#define GU_LINE_SMOOTH (15)
3374 +#define GU_PATCH_CULL_FACE (16)
3375 +#define GU_COLOR_TEST (17)
3376 +#define GU_COLOR_LOGIC_OP (18)
3377 +#define GU_FACE_NORMAL_REVERSE (19)
3378 +#define GU_PATCH_FACE (20)
3379 +#define GU_FRAGMENT_2X (21)
3381 +/* Matrix modes */
3382 +#define GU_PROJECTION (0)
3383 +#define GU_VIEW (1)
3384 +#define GU_MODEL (2)
3385 +#define GU_TEXTURE (3)
3387 +/* Vertex Declarations Begin */
3388 +#define GU_TEXTURE_SHIFT(n) ((n)<<0)
3389 +#define GU_TEXTURE_8BIT GU_TEXTURE_SHIFT(1)
3390 +#define GU_TEXTURE_16BIT GU_TEXTURE_SHIFT(2)
3391 +#define GU_TEXTURE_32BITF GU_TEXTURE_SHIFT(3)
3392 +#define GU_TEXTURE_BITS GU_TEXTURE_SHIFT(3)
3394 +#define GU_COLOR_SHIFT(n) ((n)<<2)
3395 +#define GU_COLOR_5650 GU_COLOR_SHIFT(4)
3396 +#define GU_COLOR_5551 GU_COLOR_SHIFT(5)
3397 +#define GU_COLOR_4444 GU_COLOR_SHIFT(6)
3398 +#define GU_COLOR_8888 GU_COLOR_SHIFT(7)
3399 +#define GU_COLOR_BITS GU_COLOR_SHIFT(7)
3401 +#define GU_NORMAL_SHIFT(n) ((n)<<5)
3402 +#define GU_NORMAL_8BIT GU_NORMAL_SHIFT(1)
3403 +#define GU_NORMAL_16BIT GU_NORMAL_SHIFT(2)
3404 +#define GU_NORMAL_32BITF GU_NORMAL_SHIFT(3)
3405 +#define GU_NORMAL_BITS GU_NORMAL_SHIFT(3)
3407 +#define GU_VERTEX_SHIFT(n) ((n)<<7)
3408 +#define GU_VERTEX_8BIT GU_VERTEX_SHIFT(1)
3409 +#define GU_VERTEX_16BIT GU_VERTEX_SHIFT(2)
3410 +#define GU_VERTEX_32BITF GU_VERTEX_SHIFT(3)
3411 +#define GU_VERTEX_BITS GU_VERTEX_SHIFT(3)
3413 +#define GU_WEIGHT_SHIFT(n) ((n)<<9)
3414 +#define GU_WEIGHT_8BIT GU_WEIGHT_SHIFT(1)
3415 +#define GU_WEIGHT_16BIT GU_WEIGHT_SHIFT(2)
3416 +#define GU_WEIGHT_32BITF GU_WEIGHT_SHIFT(3)
3417 +#define GU_WEIGHT_BITS GU_WEIGHT_SHIFT(3)
3419 +#define GU_INDEX_SHIFT(n) ((n)<<11)
3420 +#define GU_INDEX_8BIT GU_INDEX_SHIFT(1)
3421 +#define GU_INDEX_16BIT GU_INDEX_SHIFT(2)
3422 +#define GU_INDEX_BITS GU_INDEX_SHIFT(3)
3424 +#define GU_WEIGHTS(n) ((((n)-1)&7)<<14)
3425 +#define GU_WEIGHTS_BITS GU_WEIGHTS(8)
3426 +#define GU_VERTICES(n) ((((n)-1)&7)<<18)
3427 +#define GU_VERTICES_BITS GU_VERTICES(8)
3429 +#define GU_TRANSFORM_SHIFT(n) ((n)<<23)
3430 +#define GU_TRANSFORM_3D GU_TRANSFORM_SHIFT(0)
3431 +#define GU_TRANSFORM_2D GU_TRANSFORM_SHIFT(1)
3432 +#define GU_TRANSFORM_BITS GU_TRANSFORM_SHIFT(1)
3433 +/* Vertex Declarations End */
3435 +/* Pixel Formats */
3436 +#define GU_PSM_5650 (0) /* Display, Texture, Palette */
3437 +#define GU_PSM_5551 (1) /* Display, Texture, Palette */
3438 +#define GU_PSM_4444 (2) /* Display, Texture, Palette */
3439 +#define GU_PSM_8888 (3) /* Display, Texture, Palette */
3440 +#define GU_PSM_T4 (4) /* Texture */
3441 +#define GU_PSM_T8 (5) /* Texture */
3442 +#define GU_PSM_T16 (6) /* Texture */
3443 +#define GU_PSM_T32 (7) /* Texture */
3444 +#define GU_PSM_DXT1 (8) /* Texture */
3445 +#define GU_PSM_DXT3 (9) /* Texture */
3446 +#define GU_PSM_DXT5 (10) /* Texture */
3448 +/* Spline Mode */
3449 +#define GU_FILL_FILL (0)
3450 +#define GU_OPEN_FILL (1)
3451 +#define GU_FILL_OPEN (2)
3452 +#define GU_OPEN_OPEN (3)
3454 +/* Shading Model */
3455 +#define GU_FLAT (0)
3456 +#define GU_SMOOTH (1)
3458 +/* Logical operation */
3459 +#define GU_CLEAR (0)
3460 +#define GU_AND (1)
3461 +#define GU_AND_REVERSE (2)
3462 +#define GU_COPY (3)
3463 +#define GU_AND_INVERTED (4)
3464 +#define GU_NOOP (5)
3465 +#define GU_XOR (6)
3466 +#define GU_OR (7)
3467 +#define GU_NOR (8)
3468 +#define GU_EQUIV (9)
3469 +#define GU_INVERTED (10)
3470 +#define GU_OR_REVERSE (11)
3471 +#define GU_COPY_INVERTED (12)
3472 +#define GU_OR_INVERTED (13)
3473 +#define GU_NAND (14)
3474 +#define GU_SET (15)
3476 +/* Texture Filter */
3477 +#define GU_NEAREST (0)
3478 +#define GU_LINEAR (1)
3479 +#define GU_NEAREST_MIPMAP_NEAREST (4)
3480 +#define GU_LINEAR_MIPMAP_NEAREST (5)
3481 +#define GU_NEAREST_MIPMAP_LINEAR (6)
3482 +#define GU_LINEAR_MIPMAP_LINEAR (7)
3484 +/* Texture Map Mode */
3485 +#define GU_TEXTURE_COORDS (0)
3486 +#define GU_TEXTURE_MATRIX (1)
3487 +#define GU_ENVIRONMENT_MAP (2)
3489 +/* Texture Level Mode */
3490 +#define GU_TEXTURE_AUTO (0)
3491 +#define GU_TEXTURE_CONST (1)
3492 +#define GU_TEXTURE_SLOPE (2)
3494 +/* Texture Projection Map Mode */
3495 +#define GU_POSITION (0)
3496 +#define GU_UV (1)
3497 +#define GU_NORMALIZED_NORMAL (2)
3498 +#define GU_NORMAL (3)
3500 +/* Wrap Mode */
3501 +#define GU_REPEAT (0)
3502 +#define GU_CLAMP (1)
3504 +/* Front Face Direction */
3505 +#define GU_CW (0)
3506 +#define GU_CCW (1)
3508 +/* Test Function */
3509 +#define GU_NEVER (0)
3510 +#define GU_ALWAYS (1)
3511 +#define GU_EQUAL (2)
3512 +#define GU_NOTEQUAL (3)
3513 +#define GU_LESS (4)
3514 +#define GU_LEQUAL (5)
3515 +#define GU_GREATER (6)
3516 +#define GU_GEQUAL (7)
3518 +/* Clear Buffer Mask */
3519 +#define GU_COLOR_BUFFER_BIT (1)
3520 +#define GU_STENCIL_BUFFER_BIT (2)
3521 +#define GU_DEPTH_BUFFER_BIT (4)
3522 +#define GU_FAST_CLEAR_BIT (16)
3524 +/* Texture Effect */
3525 +#define GU_TFX_MODULATE (0)
3526 +#define GU_TFX_DECAL (1)
3527 +#define GU_TFX_BLEND (2)
3528 +#define GU_TFX_REPLACE (3)
3529 +#define GU_TFX_ADD (4)
3531 +/* Texture Color Component */
3532 +#define GU_TCC_RGB (0)
3533 +#define GU_TCC_RGBA (1)
3535 +/* Blending Op */
3536 +#define GU_ADD (0)
3537 +#define GU_SUBTRACT (1)
3538 +#define GU_REVERSE_SUBTRACT (2)
3539 +#define GU_MIN (3)
3540 +#define GU_MAX (4)
3541 +#define GU_ABS (5)
3543 +/* Blending Factor */
3544 +#define GU_SRC_COLOR (0)
3545 +#define GU_ONE_MINUS_SRC_COLOR (1)
3546 +#define GU_SRC_ALPHA (2)
3547 +#define GU_ONE_MINUS_SRC_ALPHA (3)
3548 +#define GU_DST_COLOR (0)
3549 +#define GU_ONE_MINUS_DST_COLOR (1)
3550 +#define GU_DST_ALPHA (4)
3551 +#define GU_ONE_MINUS_DST_ALPHA (5)
3552 +#define GU_FIX (10)
3554 +/* Stencil Operations */
3555 +#define GU_KEEP (0)
3556 +#define GU_ZERO (1)
3557 +#define GU_REPLACE (2)
3558 +#define GU_INVERT (3)
3559 +#define GU_INCR (4)
3560 +#define GU_DECR (5)
3562 +/* Light Components */
3563 +#define GU_AMBIENT (1)
3564 +#define GU_DIFFUSE (2)
3565 +#define GU_SPECULAR (4)
3566 +#define GU_AMBIENT_AND_DIFFUSE (GU_AMBIENT|GU_DIFFUSE)
3567 +#define GU_DIFFUSE_AND_SPECULAR (GU_DIFFUSE|GU_SPECULAR)
3568 +#define GU_UNKNOWN_LIGHT_COMPONENT (8)
3570 +/* Light modes */
3571 +#define GU_SINGLE_COLOR (0)
3572 +#define GU_SEPARATE_SPECULAR_COLOR (1)
3574 +/* Light Type */
3575 +#define GU_DIRECTIONAL (0)
3576 +#define GU_POINTLIGHT (1)
3577 +#define GU_SPOTLIGHT (2)
3579 +/* Contexts */
3580 +#define GU_DIRECT (0)
3581 +#define GU_CALL (1)
3582 +#define GU_SEND (2)
3584 +/* List Queue */
3585 +#define GU_TAIL (0)
3586 +#define GU_HEAD (1)
3588 +/* Sync behavior (mode) */
3589 +#define GU_SYNC_FINISH (0)
3590 +#define GU_SYNC_SIGNAL (1)
3591 +#define GU_SYNC_DONE (2)
3592 +#define GU_SYNC_LIST (3)
3593 +#define GU_SYNC_SEND (4)
3595 +/* behavior (what) */
3596 +#define GU_SYNC_WAIT (0)
3597 +#define GU_SYNC_NOWAIT (1)
3599 +/* Sync behavior (what) [see pspge.h] */
3600 +#define GU_SYNC_WHAT_DONE (0)
3601 +#define GU_SYNC_WHAT_QUEUED (1)
3602 +#define GU_SYNC_WHAT_DRAW (2)
3603 +#define GU_SYNC_WHAT_STALL (3)
3604 +#define GU_SYNC_WHAT_CANCEL (4)
3606 +/* Signals */
3607 +#define GU_CALLBACK_SIGNAL (1)
3608 +#define GU_CALLBACK_FINISH (4)
3610 +/* Signal behavior */
3611 +#define GU_BEHAVIOR_SUSPEND (1)
3612 +#define GU_BEHAVIOR_CONTINUE (2)
3614 +/* Color Macros, maps 8 bit unsigned channels into one 32-bit value */
3615 +#define GU_ABGR(a,b,g,r) (((a) << 24)|((b) << 16)|((g) << 8)|(r))
3616 +#define GU_ARGB(a,r,g,b) GU_ABGR((a),(b),(g),(r))
3617 +#define GU_RGBA(r,g,b,a) GU_ARGB((a),(r),(g),(b))
3619 +/* Color Macro, maps floating point channels (0..1) into one 32-bit value */
3620 +#define GU_COLOR(r,g,b,a) GU_RGBA((u32)((r) * 255.0f),(u32)((g) * 255.0f),(u32)((b) * 255.0f),(u32)((a) * 255.0f))
3622 +typedef void (*GuSwapBuffersCallback)(void** display,void** render);
3624 +/** @addtogroup GU */
3625 +/**@{*/
3627 +/**
3628 + * Set depth buffer parameters
3630 + * @param zbp - VRAM pointer where the depthbuffer should start
3631 + * @param zbw - The width of the depth-buffer (block-aligned)
3633 +**/
3634 +void sceGuDepthBuffer(void* zbp, int zbw);
3636 +/**
3637 + * Set display buffer parameters
3639 + * @par Example: Setup a standard 16-bit display buffer
3640 + * @code
3641 + * sceGuDispBuffer(480,272,(void*)512*272*2,512); // 480*272, skipping the draw buffer located at address 0
3642 + * @endcode
3644 + * @param width - Width of the display buffer in pixels
3645 + * @param height - Width of the display buffer in pixels
3646 + * @param dispbp - VRAM pointer to where the display-buffer starts
3647 + * @param dispbw - Display buffer width (block aligned)
3649 +**/
3650 +void sceGuDispBuffer(int width, int height, void* dispbp, int dispbw);
3652 +/**
3653 + * Set draw buffer parameters (and store in context for buffer-swap)
3655 + * Available pixel formats are:
3656 + * - GU_PSM_5650
3657 + * - GU_PSM_5551
3658 + * - GU_PSM_4444
3659 + * - GU_PSM_8888
3661 + * @par Example: Setup a standard 16-bit draw buffer
3662 + * @code
3663 + * sceGuDrawBuffer(GU_PSM_5551,(void*)0,512);
3664 + * @endcode
3666 + * @param psm - Pixel format to use for rendering (and display)
3667 + * @param fbp - VRAM pointer to where the draw buffer starts
3668 + * @param fbw - Frame buffer width (block aligned)
3669 +**/
3670 +void sceGuDrawBuffer(int psm, void* fbp, int fbw);
3672 +/**
3673 + * Set draw buffer directly, not storing parameters in the context
3675 + * @param psm - Pixel format to use for rendering
3676 + * @param fbp - VRAM pointer to where the draw buffer starts
3677 + * @param fbw - Frame buffer width (block aligned)
3678 +**/
3679 +void sceGuDrawBufferList(int psm, void* fbp, int fbw);
3681 +/**
3682 + * Turn display on or off
3684 + * Available states are:
3685 + * - GU_TRUE (1) - Turns display on
3686 + * - GU_FALSE (0) - Turns display off
3688 + * @param state - Turn display on or off
3689 + * @return State of the display prior to this call
3690 +**/
3691 +int sceGuDisplay(int state);
3693 +/**
3694 + * Select which depth-test function to use
3696 + * Valid choices for the depth-test are:
3697 + * - GU_NEVER - No pixels pass the depth-test
3698 + * - GU_ALWAYS - All pixels pass the depth-test
3699 + * - GU_EQUAL - Pixels that match the depth-test pass
3700 + * - GU_NOTEQUAL - Pixels that doesn't match the depth-test pass
3701 + * - GU_LESS - Pixels that are less in depth passes
3702 + * - GU_LEQUAL - Pixels that are less or equal in depth passes
3703 + * - GU_GREATER - Pixels that are greater in depth passes
3704 + * - GU_GEQUAL - Pixels that are greater or equal passes
3706 + * @param function - Depth test function to use
3707 +**/
3708 +void sceGuDepthFunc(int function);
3710 +/**
3711 + * Mask depth buffer writes
3713 + * @param mask - GU_TRUE(1) to disable Z writes, GU_FALSE(0) to enable
3714 +**/
3715 +void sceGuDepthMask(int mask);
3717 +void sceGuDepthOffset(unsigned int offset);
3719 +/**
3720 + * Set which range to use for depth calculations.
3722 + * @note The depth buffer is inversed, and takes values from 65535 to 0.
3724 + * Example: Use the entire depth-range for calculations:
3725 + * @code
3726 + * sceGuDepthRange(65535,0);
3727 + * @endcode
3729 + * @param near - Value to use for the near plane
3730 + * @param far - Value to use for the far plane
3731 +**/
3732 +void sceGuDepthRange(int near, int far);
3734 +void sceGuFog(float near, float far, unsigned int color);
3736 +/**
3737 + * Initalize the GU system
3739 + * This function MUST be called as the first function, otherwise state is undetermined.
3740 +**/
3741 +void sceGuInit(void);
3743 +/**
3744 + * Shutdown the GU system
3746 + * Called when GU is no longer needed
3747 +**/
3748 +void sceGuTerm(void);
3750 +void sceGuBreak(int a0);
3751 +void sceGuContinue(void);
3753 +/**
3754 + * Setup signal handler
3756 + * Available signals are:
3757 + * - GU_CALLBACK_SIGNAL - Called when sceGuSignal is used
3758 + * - GU_CALLBACK_FINISH - Called when display list is finished
3760 + * @param signal - Signal index to install a handler for
3761 + * @param callback - Callback to call when signal index is triggered
3762 + * @return The old callback handler
3763 +**/
3764 +void* sceGuSetCallback(int signal, void (*callback)(int));
3766 +/**
3767 + * Trigger signal to call code from the command stream
3769 + * Available behaviors are:
3770 + * - GU_BEHAVIOR_SUSPEND - Stops display list execution until callback function finished
3771 + * - GU_BEHAVIOR_CONTINUE - Do not stop display list execution during callback
3773 + * @param signal - Signal to trigger
3774 + * @param behavior - Behavior type
3775 +**/
3776 +void sceGuSignal(int signal, int behavior);
3778 +/**
3779 + * Send raw float-command to the GE
3781 + * The argument is converted into a 24-bit float before transfer.
3783 + * @param cmd - Which command to send
3784 + * @param argument - Argument to pass along
3785 +**/
3786 +void sceGuSendCommandf(int cmd, float argument);
3788 +/**
3789 + * Send raw command to the GE
3791 + * Only the 24 lower bits of the argument is passed along.
3793 + * @param cmd - Which command to send
3794 + * @param argument - Argument to pass along
3795 +**/
3796 +void sceGuSendCommandi(int cmd, int argument);
3798 +/**
3799 + * Allocate memory on the current display list for temporary storage
3801 + * @note This function is NOT for permanent memory allocation, the
3802 + * memory will be invalid as soon as you start filling the same display
3803 + * list again.
3805 + * @param size - How much memory to allocate
3806 + * @return Memory-block ready for use
3807 +**/
3808 +void* sceGuGetMemory(int size);
3810 +/**
3811 + * Start filling a new display-context
3813 + * Contexts available are:
3814 + * - GU_DIRECT - Rendering is performed as list is filled
3815 + * - GU_CALL - List is setup to be called from the main list
3816 + * - GU_SEND - List is buffered for a later call to sceGuSendList()
3818 + * The previous context-type is stored so that it can be restored at sceGuFinish().
3820 + * @param cid - Context Type
3821 + * @param list - Pointer to display-list (16 byte aligned)
3822 +**/
3823 +void sceGuStart(int cid, void* list);
3825 +/**
3826 + * Finish current display list and go back to the parent context
3828 + * If the context is GU_DIRECT, the stall-address is updated so that the entire list will
3829 + * execute. Otherwise, only the terminating action is written to the list, depending on
3830 + * context-type.
3832 + * The finish-callback will get a zero as argument when using this function.
3834 + * This also restores control back to whatever context that was active prior to this call.
3836 + * @return Size of finished display list
3837 +**/
3838 +int sceGuFinish(void);
3840 +/**
3841 + * Finish current display list and go back to the parent context, sending argument id for
3842 + * the finish callback.
3844 + * If the context is GU_DIRECT, the stall-address is updated so that the entire list will
3845 + * execute. Otherwise, only the terminating action is written to the list, depending on
3846 + * context-type.
3848 + * @param id - Finish callback id (16-bit)
3849 + * @return Size of finished display list
3850 +**/
3851 +int sceGuFinishId(unsigned int id);
3853 +/**
3854 + * Call previously generated display-list
3856 + * @param list - Display list to call
3857 +**/
3858 +void sceGuCallList(const void* list);
3860 +/**
3861 + * Set wether to use stack-based calls or signals to handle execution of called lists.
3863 + * @param mode - GU_TRUE(1) to enable signals, GU_FALSE(0) to disable signals and use
3864 + * normal calls instead.
3865 +**/
3866 +void sceGuCallMode(int mode);
3868 +/**
3869 + * Check how large the current display-list is
3871 + * @return The size of the current display list
3872 +**/
3873 +int sceGuCheckList(void);
3875 +/**
3876 + * Send a list to the GE directly
3878 + * Available modes are:
3879 + * - GU_TAIL - Place list last in the queue, so it executes in-order
3880 + * - GU_HEAD - Place list first in queue so that it executes as soon as possible
3882 + * @param mode - Whether to place the list first or last in queue
3883 + * @param list - List to send
3884 + * @param context - Temporary storage for the GE context
3885 +**/
3886 +void sceGuSendList(int mode, const void* list, PspGeContext* context);
3888 +/**
3889 + * Swap display and draw buffer
3891 + * @return Pointer to the new drawbuffer
3892 +**/
3893 +void* sceGuSwapBuffers(void);
3895 +/**
3896 + * Wait until display list has finished executing
3898 + * @par Example: Wait for the currently executing display list
3899 + * @code
3900 + * sceGuSync(0,0);
3901 + * @endcode
3903 + * Available what are:
3904 + * - GU_SYNC_WHAT_DONE
3905 + * - GU_SYNC_WHAT_QUEUED
3906 + * - GU_SYNC_WHAT_DRAW
3907 + * - GU_SYNC_WHAT_STALL
3908 + * - GU_SYNC_WHAT_CANCEL
3910 + * Available mode are:
3911 + * - GU_SYNC_FINISH - Wait until the last sceGuFinish command is reached
3912 + * - GU_SYNC_SIGNAL - Wait until the last (?) signal is executed
3913 + * - GU_SYNC_DONE - Wait until all commands currently in list are executed
3914 + * - GU_SYNC_LIST - Wait for the currently executed display list (GU_DIRECT)
3915 + * - GU_SYNC_SEND - Wait for the last send list
3917 + * @param mode - What to wait for
3918 + * @param what - What to sync to
3919 + * @return Unknown at this time
3920 +**/
3921 +int sceGuSync(int mode, int what);
3923 +/**
3924 + * Draw array of vertices forming primitives
3926 + * Available primitive-types are:
3927 + * - GU_POINTS - Single pixel points (1 vertex per primitive)
3928 + * - GU_LINES - Single pixel lines (2 vertices per primitive)
3929 + * - GU_LINE_STRIP - Single pixel line-strip (2 vertices for the first primitive, 1 for every following)
3930 + * - GU_TRIANGLES - Filled triangles (3 vertices per primitive)
3931 + * - GU_TRIANGLE_STRIP - Filled triangles-strip (3 vertices for the first primitive, 1 for every following)
3932 + * - GU_TRIANGLE_FAN - Filled triangle-fan (3 vertices for the first primitive, 1 for every following)
3933 + * - GU_SPRITES - Filled blocks (2 vertices per primitive)
3935 + * The vertex-type decides how the vertices align and what kind of information they contain.
3936 + * The following flags are ORed together to compose the final vertex format:
3937 + * - GU_TEXTURE_8BIT - 8-bit texture coordinates
3938 + * - GU_TEXTURE_16BIT - 16-bit texture coordinates
3939 + * - GU_TEXTURE_32BITF - 32-bit texture coordinates (float)
3941 + * - GU_COLOR_5650 - 16-bit color (R5G6B5A0)
3942 + * - GU_COLOR_5551 - 16-bit color (R5G5B5A1)
3943 + * - GU_COLOR_4444 - 16-bit color (R4G4B4A4)
3944 + * - GU_COLOR_8888 - 32-bit color (R8G8B8A8)
3946 + * - GU_NORMAL_8BIT - 8-bit normals
3947 + * - GU_NORMAL_16BIT - 16-bit normals
3948 + * - GU_NORMAL_32BITF - 32-bit normals (float)
3950 + * - GU_VERTEX_8BIT - 8-bit vertex position
3951 + * - GU_VERTEX_16BIT - 16-bit vertex position
3952 + * - GU_VERTEX_32BITF - 32-bit vertex position (float)
3954 + * - GU_WEIGHT_8BIT - 8-bit weights
3955 + * - GU_WEIGHT_16BIT - 16-bit weights
3956 + * - GU_WEIGHT_32BITF - 32-bit weights (float)
3958 + * - GU_INDEX_8BIT - 8-bit vertex index
3959 + * - GU_INDEX_16BIT - 16-bit vertex index
3961 + * - GU_WEIGHTS(n) - Number of weights (1-8)
3962 + * - GU_VERTICES(n) - Number of vertices (1-8)
3964 + * - GU_TRANSFORM_2D - Coordinate is passed directly to the rasterizer
3965 + * - GU_TRANSFORM_3D - Coordinate is transformed before passed to rasterizer
3967 + * @note Every vertex must align to 32 bits, which means that you HAVE to pad if it does not add up!
3969 + * Vertex order:
3970 + * [for vertices(1-8)]
3971 + * [weights (0-8)]
3972 + * [texture uv]
3973 + * [color]
3974 + * [normal]
3975 + * [vertex]
3976 + * [/for]
3978 + * @par Example: Render 400 triangles, with floating-point texture coordinates, and floating-point position, no indices
3979 + * @code
3980 + * sceGuDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF,400*3,0,vertices);
3981 + * @endcode
3983 + * @param prim - What kind of primitives to render
3984 + * @param vtype - Vertex type to process
3985 + * @param count - How many vertices to process
3986 + * @param indices - Optional pointer to an index-list
3987 + * @param vertices - Pointer to a vertex-list
3988 +**/
3989 +void sceGuDrawArray(int prim, int vtype, int count, const void* indices, const void* vertices);
3991 +/**
3992 + * Begin conditional rendering of object
3994 + * If no vertices passed into this function are inside the scissor region, it will skip rendering
3995 + * the object. There can be up to 32 levels of conditional testing, and all levels HAVE to
3996 + * be terminated by sceGuEndObject().
3998 + * @par Example: test a boundingbox against the frustum, and if visible, render object
3999 + * @code
4000 + * sceGuBeginObject(GU_VERTEX_32BITF,8,0,boundingBox);
4001 + * sceGuDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF,vertexCount,0,vertices);
4002 + * sceGuEndObject();
4003 + * @endcode
4005 + * @param vtype - Vertex type to process
4006 + * @param count - Number of vertices to test
4007 + * @param indices - Optional list to an index-list
4008 + * @param vertices - Pointer to a vertex-list
4009 +**/
4010 +void sceGuBeginObject(int vtype, int count, const void* indices, const void* vertices);
4012 +/**
4013 + * End conditional rendering of object
4014 +**/
4015 +void sceGuEndObject(void);
4017 +/**
4018 + * Enable or disable GE state
4020 + * Look at sceGuEnable() for a list of states
4022 + * @param state - Which state to change
4023 + * @param status - Wether to enable or disable the state
4024 +**/
4025 +void sceGuSetStatus(int state, int status);
4027 +/**
4028 + * Get if state is currently enabled or disabled
4030 + * Look at sceGuEnable() for a list of states
4032 + * @param state - Which state to query about
4033 + * @return Wether state is enabled or not
4034 +**/
4035 +int sceGuGetStatus(int state);
4037 +/**
4038 + * Set the status on all 22 available states
4040 + * Look at sceGuEnable() for a list of states
4042 + * @param status - Bit-mask (0-21) containing the status of all 22 states
4043 +**/
4044 +void sceGuSetAllStatus(int status);
4046 +/**
4047 + * Query status on all 22 available states
4049 + * Look at sceGuEnable() for a list of states
4051 + * @return Status of all 22 states as a bitmask (0-21)
4052 +**/
4053 +int sceGuGetAllStatus(void);
4055 +/**
4056 + * Enable GE state
4058 + * The currently available states are:
4059 + * - GU_ALPHA_TEST
4060 + * - GU_DEPTH_TEST
4061 + * - GU_SCISSOR_TEST
4062 + * - GU_BLEND
4063 + * - GU_CULL_FACE
4064 + * - GU_DITHER
4065 + * - GU_CLIP_PLANES
4066 + * - GU_TEXTURE_2D
4067 + * - GU_LIGHTING
4068 + * - GU_LIGHT0
4069 + * - GU_LIGHT1
4070 + * - GU_LIGHT2
4071 + * - GU_LIGHT3
4072 + * - GU_COLOR_LOGIC_OP
4074 + * @param state - Which state to enable
4075 +**/
4076 +void sceGuEnable(int state);
4078 +/**
4079 + * Disable GE state
4081 + * Look at sceGuEnable() for a list of states
4083 + * @param state - Which state to disable
4084 +**/
4085 +void sceGuDisable(int state);
4087 +/**
4088 + * Set light parameters
4090 + * Available light types are:
4091 + * - GU_DIRECTIONAL - Directional light
4092 + * - GU_POINTLIGHT - Single point of light
4093 + * - GU_SPOTLIGHT - Point-light with a cone
4095 + * Available light components are:
4096 + * - GU_AMBIENT_AND_DIFFUSE
4097 + * - GU_DIFFUSE_AND_SPECULAR
4098 + * - GU_UNKNOWN_LIGHT_COMPONENT
4100 + * @param light - Light index
4101 + * @param type - Light type
4102 + * @param components - Light components
4103 + * @param position - Light position
4104 +**/
4105 +void sceGuLight(int light, int type, int components, const ScePspFVector3* position);
4107 +/**
4108 + * Set light attenuation
4110 + * @param light - Light index
4111 + * @param atten0 - Constant attenuation factor
4112 + * @param atten1 - Linear attenuation factor
4113 + * @param atten2 - Quadratic attenuation factor
4114 +**/
4115 +void sceGuLightAtt(int light, float atten0, float atten1, float atten2);
4117 +/**
4118 + * Set light color
4120 + * Available light components are:
4121 + * - GU_AMBIENT
4122 + * - GU_DIFFUSE
4123 + * - GU_SPECULAR
4124 + * - GU_AMBIENT_AND_DIFFUSE
4125 + * - GU_DIFFUSE_AND_SPECULAR
4127 + * @param light - Light index
4128 + * @param component - Which component to set
4129 + * @param color - Which color to use
4130 +**/
4131 +void sceGuLightColor(int light, int component, unsigned int color);
4133 +/**
4134 + * Set light mode
4136 + * Available light modes are:
4137 + * - GU_SINGLE_COLOR
4138 + * - GU_SEPARATE_SPECULAR_COLOR
4140 + * Separate specular colors are used to interpolate the specular component
4141 + * independently, so that it can be added to the fragment after the texture color.
4143 + * @param mode - Light mode to use
4144 +**/
4145 +void sceGuLightMode(int mode);
4147 +/**
4148 + * Set spotlight parameters
4150 + * @param light - Light index
4151 + * @param direction - Spotlight direction
4152 + * @param exponent - Spotlight exponent
4153 + * @param cutoff - Spotlight cutoff angle (in radians)
4154 +**/
4155 +void sceGuLightSpot(int light, const ScePspFVector3* direction, float exponent, float cutoff);
4157 +/**
4158 + * Clear current drawbuffer
4160 + * Available clear-flags are (OR them together to get final clear-mode):
4161 + * - GU_COLOR_BUFFER_BIT - Clears the color-buffer
4162 + * - GU_STENCIL_BUFFER_BIT - Clears the stencil-buffer
4163 + * - GU_DEPTH_BUFFER_BIT - Clears the depth-buffer
4165 + * @param flags - Which part of the buffer to clear
4166 +**/
4167 +void sceGuClear(int flags);
4169 +/**
4170 + * Set the current clear-color
4172 + * @param color - Color to clear with
4173 +**/
4174 +void sceGuClearColor(unsigned int color);
4176 +/**
4177 + * Set the current clear-depth
4179 + * @param depth - Set which depth to clear with (0x0000-0xffff)
4180 +**/
4181 +void sceGuClearDepth(unsigned int depth);
4183 +/**
4184 + * Set the current stencil clear value
4186 + * @param stencil - Set which stencil value to clear with (0-255)
4188 +**/
4189 +void sceGuClearStencil(unsigned int stencil);
4191 +/**
4192 + * Set mask for which bits of the pixels to write
4194 + * @param mask - Which bits to filter against writes
4196 +**/
4197 +void sceGuPixelMask(unsigned int mask);
4199 +/**
4200 + * Set current primitive color
4202 + * @param color - Which color to use (overriden by vertex-colors)
4203 +**/
4204 +void sceGuColor(unsigned int color);
4206 +/**
4207 + * Set the color test function
4209 + * The color test is only performed while GU_COLOR_TEST is enabled.
4211 + * Available functions are:
4212 + * - GU_NEVER
4213 + * - GU_ALWAYS
4214 + * - GU_EQUAL
4215 + * - GU_NOTEQUAL
4217 + * @par Example: Reject any pixel that does not have 0 as the blue channel
4218 + * @code
4219 + * sceGuColorFunc(GU_EQUAL,0,0xff0000);
4220 + * @endcode
4222 + * @param func - Color test function
4223 + * @param color - Color to test against
4224 + * @param mask - Mask ANDed against both source and destination when testing
4225 +**/
4226 +void sceGuColorFunc(int func, unsigned int color, unsigned int mask);
4228 +/**
4229 + * Set which color components that the material will receive
4231 + * The components are ORed together from the following values:
4232 + * - GU_AMBIENT
4233 + * - GU_DIFFUSE
4234 + * - GU_SPECULAR
4236 + * @param components - Which components to receive
4237 +**/
4238 +void sceGuColorMaterial(int components);
4240 +/**
4241 + * Set the alpha test parameters
4242 + *
4243 + * Available comparison functions are:
4244 + * - GU_NEVER
4245 + * - GU_ALWAYS
4246 + * - GU_EQUAL
4247 + * - GU_NOTEQUAL
4248 + * - GU_LESS
4249 + * - GU_LEQUAL
4250 + * - GU_GREATER
4251 + * - GU_GEQUAL
4253 + * @param func - Specifies the alpha comparison function.
4254 + * @param value - Specifies the reference value that incoming alpha values are compared to.
4255 + * @param mask - Specifies the mask that both values are ANDed with before comparison.
4256 +**/
4257 +void sceGuAlphaFunc(int func, int value, int mask);
4259 +void sceGuAmbient(unsigned int color);
4260 +void sceGuAmbientColor(unsigned int color);
4262 +/**
4263 + * Set the blending-mode
4265 + * Keys for the blending operations:
4266 + * - Cs - Source color
4267 + * - Cd - Destination color
4268 + * - Bs - Blend function for source fragment
4269 + * - Bd - Blend function for destination fragment
4271 + * Available blending-operations are:
4272 + * - GU_ADD - (Cs*Bs) + (Cd*Bd)
4273 + * - GU_SUBTRACT - (Cs*Bs) - (Cd*Bd)
4274 + * - GU_REVERSE_SUBTRACT - (Cd*Bd) - (Cs*Bs)
4275 + * - GU_MIN - Cs < Cd ? Cs : Cd
4276 + * - GU_MAX - Cs < Cd ? Cd : Cs
4277 + * - GU_ABS - |Cs-Cd|
4279 + * Available blending-functions are:
4280 + * - GU_SRC_COLOR
4281 + * - GU_ONE_MINUS_SRC_COLOR
4282 + * - GU_SRC_ALPHA
4283 + * - GU_ONE_MINUS_SRC_ALPHA
4284 + * - GU_DST_ALPHA
4285 + * - GU_ONE_MINUS_DST_ALPHA
4286 + * - GU_DST_COLOR
4287 + * - GU_ONE_MINUS_DST_COLOR
4288 + * - GU_FIX
4290 + * @param op - Blending Operation
4291 + * @param src - Blending function for source operand
4292 + * @param dest - Blending function for dest operand
4293 + * @param srcfix - Fix value for GU_FIX (source operand)
4294 + * @param destfix - Fix value for GU_FIX (dest operand)
4295 +**/
4296 +void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix);
4298 +void sceGuMaterial(int mode, int color);
4300 +/**
4302 +**/
4303 +void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular);
4305 +/**
4306 + * Set stencil function and reference value for stencil testing
4308 + * Available functions are:
4309 + * - GU_NEVER
4310 + * - GU_ALWAYS
4311 + * - GU_EQUAL
4312 + * - GU_NOTEQUAL
4313 + * - GU_LESS
4314 + * - GU_LEQUAL
4315 + * - GU_GREATER
4316 + * - GU_GEQUAL
4318 + * @param func - Test function
4319 + * @param ref - The reference value for the stencil test
4320 + * @param mask - Mask that is ANDed with both the reference value and stored stencil value when the test is done
4321 +**/
4322 +void sceGuStencilFunc(int func, int ref, int mask);
4324 +/**
4325 + * Set the stencil test actions
4327 + * Available actions are:
4328 + * - GU_KEEP - Keeps the current value
4329 + * - GU_ZERO - Sets the stencil buffer value to zero
4330 + * - GU_REPLACE - Sets the stencil buffer value to ref, as specified by sceGuStencilFunc()
4331 + * - GU_INCR - Increments the current stencil buffer value
4332 + * - GU_DECR - Decrease the current stencil buffer value
4333 + * - GU_INVERT - Bitwise invert the current stencil buffer value
4335 + * As stencil buffer shares memory with framebuffer alpha, resolution of the buffer
4336 + * is directly in relation.
4338 + * @param fail - The action to take when the stencil test fails
4339 + * @param zfail - The action to take when stencil test passes, but the depth test fails
4340 + * @param zpass - The action to take when both stencil test and depth test passes
4341 +**/
4342 +void sceGuStencilOp(int fail, int zfail, int zpass);
4344 +/**
4345 + * Set the specular power for the material
4347 + * @param power - Specular power
4349 +**/
4350 +void sceGuSpecular(float power);
4352 +/**
4353 + * Set the current face-order (for culling)
4355 + * This only has effect when culling is enabled (GU_CULL_FACE)
4357 + * Culling order can be:
4358 + * - GU_CW - Clockwise primitives are not culled
4359 + * - GU_CCW - Counter-clockwise are not culled
4361 + * @param order - Which order to use
4362 +**/
4363 +void sceGuFrontFace(int order);
4365 +/**
4366 + * Set color logical operation
4368 + * Available operations are:
4369 + * - GU_CLEAR
4370 + * - GU_AND
4371 + * - GU_AND_REVERSE
4372 + * - GU_COPY
4373 + * - GU_AND_INVERTED
4374 + * - GU_NOOP
4375 + * - GU_XOR
4376 + * - GU_OR
4377 + * - GU_NOR
4378 + * - GU_EQUIV
4379 + * - GU_INVERTED
4380 + * - GU_OR_REVERSE
4381 + * - GU_COPY_INVERTED
4382 + * - GU_OR_INVERTED
4383 + * - GU_NAND
4384 + * - GU_SET
4386 + * This operation only has effect if GU_COLOR_LOGIC_OP is enabled.
4388 + * @param op - Operation to execute
4389 +**/
4390 +void sceGuLogicalOp(int op);
4392 +/**
4393 + * Set ordered pixel dither matrix
4395 + * This dither matrix is only applied if GU_DITHER is enabled.
4397 + * @param matrix - Dither matrix
4398 +**/
4399 +void sceGuSetDither(const ScePspIMatrix4* matrix);
4401 +/**
4402 + * Set how primitives are shaded
4404 + * The available shading-methods are:
4405 + * - GU_FLAT - Primitives are flatshaded, the last vertex-color takes effet
4406 + * - GU_SMOOTH - Primtives are gouraud-shaded, all vertex-colors take effect
4408 + * @param mode - Which mode to use
4409 +**/
4410 +void sceGuShadeModel(int mode);
4412 +/**
4413 + * Image transfer using the GE
4415 + * @note Data must be aligned to 1 quad word (16 bytes)
4417 + * @par Example: Copy a fullscreen 32-bit image from RAM to VRAM
4418 + * @code
4419 + * sceGuCopyImage(GU_PSM_8888,0,0,480,272,512,pixels,0,0,512,(void*)(((unsigned int)framebuffer)+0x4000000));
4420 + * @endcode
4422 + * @param psm - Pixel format for buffer
4423 + * @param sx - Source X
4424 + * @param sy - Source Y
4425 + * @param width - Image width
4426 + * @param height - Image height
4427 + * @param srcw - Source buffer width (block aligned)
4428 + * @param src - Source pointer
4429 + * @param dx - Destination X
4430 + * @param dy - Destination Y
4431 + * @param destw - Destination buffer width (block aligned)
4432 + * @param dest - Destination pointer
4433 +**/
4434 +void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest);
4436 +/**
4437 + * Specify the texture environment color
4439 + * This is used in the texture function when a constant color is needed.
4441 + * See sceGuTexFunc() for more information.
4443 + * @param color - Constant color (0x00BBGGRR)
4444 +**/
4445 +void sceGuTexEnvColor(unsigned int color);
4447 +/**
4448 + * Set how the texture is filtered
4450 + * Available filters are:
4451 + * - GU_NEAREST
4452 + * - GU_LINEAR
4453 + * - GU_NEAREST_MIPMAP_NEAREST
4454 + * - GU_LINEAR_MIPMAP_NEAREST
4455 + * - GU_NEAREST_MIPMAP_LINEAR
4456 + * - GU_LINEAR_MIPMAP_LINEAR
4458 + * @param min - Minimizing filter
4459 + * @param mag - Magnifying filter
4460 +**/
4461 +void sceGuTexFilter(int min, int mag);
4463 +/**
4464 + * Flush texture page-cache
4466 + * Do this if you have copied/rendered into an area currently in the texture-cache
4468 +**/
4469 +void sceGuTexFlush(void);
4471 +/**
4472 + * Set how textures are applied
4474 + * Key for the apply-modes:
4475 + * - Cv - Color value result
4476 + * - Ct - Texture color
4477 + * - Cf - Fragment color
4478 + * - Cc - Constant color (specified by sceGuTexEnvColor())
4480 + * Available apply-modes are: (TFX)
4481 + * - GU_TFX_MODULATE - Cv=Ct*Cf TCC_RGB: Av=Af TCC_RGBA: Av=At*Af
4482 + * - GU_TFX_DECAL - TCC_RGB: Cv=Ct,Av=Af TCC_RGBA: Cv=Cf*(1-At)+Ct*At Av=Af
4483 + * - GU_TFX_BLEND - Cv=(Cf*(1-Ct))+(Cc*Ct) TCC_RGB: Av=Af TCC_RGBA: Av=At*Af
4484 + * - GU_TFX_REPLACE - Cv=Ct TCC_RGB: Av=Af TCC_RGBA: Av=At
4485 + * - GU_TFX_ADD - Cv=Cf+Ct TCC_RGB: Av=Af TCC_RGBA: Av=At*Af
4487 + * The fields TCC_RGB and TCC_RGBA specify components that differ between
4488 + * the two different component modes.
4490 + * - GU_TFX_MODULATE - The texture is multiplied with the current diffuse fragment
4491 + * - GU_TFX_REPLACE - The texture replaces the fragment
4492 + * - GU_TFX_ADD - The texture is added on-top of the diffuse fragment
4493 + *
4494 + * Available component-modes are: (TCC)
4495 + * - GU_TCC_RGB - The texture alpha does not have any effect
4496 + * - GU_TCC_RGBA - The texture alpha is taken into account
4498 + * @param tfx - Which apply-mode to use
4499 + * @param tcc - Which component-mode to use
4500 +**/
4501 +void sceGuTexFunc(int tfx, int tcc);
4503 +/**
4504 + * Set current texturemap
4506 + * Textures may reside in main RAM, but it has a huge speed-penalty. Swizzle textures
4507 + * to get maximum speed.
4509 + * @note Data must be aligned to 1 quad word (16 bytes)
4511 + * @param mipmap - Mipmap level
4512 + * @param width - Width of texture (must be a power of 2)
4513 + * @param height - Height of texture (must be a power of 2)
4514 + * @param tbw - Texture Buffer Width (block-aligned)
4515 + * @param tbp - Texture buffer pointer (16 byte aligned)
4516 +**/
4517 +void sceGuTexImage(int mipmap, int width, int height, int tbw, const void* tbp);
4519 +/**
4520 + * Set texture-level mode (mipmapping)
4522 + * Available modes are:
4523 + * - GU_TEXTURE_AUTO
4524 + * - GU_TEXTURE_CONST
4525 + * - GU_TEXTURE_SLOPE
4527 + * @param mode - Which mode to use
4528 + * @param bias - Which mipmap bias to use
4529 +**/
4530 +void sceGuTexLevelMode(unsigned int mode, float bias);
4532 +/**
4533 + * Set the texture-mapping mode
4535 + * Available modes are:
4536 + * - GU_TEXTURE_COORDS
4537 + * - GU_TEXTURE_MATRIX
4538 + * - GU_ENVIRONMENT_MAP
4540 + * @param mode - Which mode to use
4541 + * @param a1 - Unknown
4542 + * @param a2 - Unknown
4543 +**/
4544 +void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2);
4546 +/**
4547 + * Set texture-mode parameters
4549 + * Available texture-formats are:
4550 + * - GU_PSM_5650 - Hicolor, 16-bit
4551 + * - GU_PSM_5551 - Hicolor, 16-bit
4552 + * - GU_PSM_4444 - Hicolor, 16-bit
4553 + * - GU_PSM_8888 - Truecolor, 32-bit
4554 + * - GU_PSM_T4 - Indexed, 4-bit (2 pixels per byte)
4555 + * - GU_PSM_T8 - Indexed, 8-bit
4557 + * @param tpsm - Which texture format to use
4558 + * @param maxmips - Number of mipmaps to use (0-8)
4559 + * @param a2 - Unknown, set to 0
4560 + * @param swizzle - GU_TRUE(1) to swizzle texture-reads
4561 +**/
4562 +void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle);
4564 +/**
4565 + * Set texture offset
4567 + * @note Only used by the 3D T&L pipe, renders done with GU_TRANSFORM_2D are
4568 + * not affected by this.
4570 + * @param u - Offset to add to the U coordinate
4571 + * @param v - Offset to add to the V coordinate
4572 +**/
4573 +void sceGuTexOffset(float u, float v);
4575 +/**
4576 + * Set texture projection-map mode
4578 + * Available modes are:
4579 + * - GU_POSITION
4580 + * - GU_UV
4581 + * - GU_NORMALIZED_NORMAL
4582 + * - GU_NORMAL
4584 + * @param mode - Which mode to use
4585 +**/
4586 +void sceGuTexProjMapMode(int mode);
4588 +/**
4589 + * Set texture scale
4591 + * @note Only used by the 3D T&L pipe, renders ton with GU_TRANSFORM_2D are
4592 + * not affected by this.
4594 + * @param u - Scalar to multiply U coordinate with
4595 + * @param v - Scalar to multiply V coordinate with
4596 +**/
4597 +void sceGuTexScale(float u, float v);
4598 +void sceGuTexSlope(float slope);
4600 +/**
4601 + * Synchronize rendering pipeline with image upload.
4603 + * This will stall the rendering pipeline until the current image upload initiated by
4604 + * sceGuCopyImage() has completed.
4605 +**/
4606 +void sceGuTexSync();
4608 +/**
4609 + * Set if the texture should repeat or clamp
4611 + * Available modes are:
4612 + * - GU_REPEAT - The texture repeats after crossing the border
4613 + * - GU_CLAMP - Texture clamps at the border
4615 + * @param u - Wrap-mode for the U direction
4616 + * @param v - Wrap-mode for the V direction
4617 +**/
4618 +void sceGuTexWrap(int u, int v);
4620 +/**
4621 + * Upload CLUT (Color Lookup Table)
4623 + * @note Data must be aligned to 1 quad word (16 bytes)
4625 + * @param num_blocks - How many blocks of 8 entries to upload (32*8 is 256 colors)
4626 + * @param cbp - Pointer to palette (16 byte aligned)
4627 +**/
4628 +void sceGuClutLoad(int num_blocks, const void* cbp);
4630 +/**
4631 + * Set current CLUT mode
4633 + * Available pixel formats for palettes are:
4634 + * - GU_PSM_5650
4635 + * - GU_PSM_5551
4636 + * - GU_PSM_4444
4637 + * - GU_PSM_8888
4639 + * @param cpsm - Which pixel format to use for the palette
4640 + * @param shift - Shifts color index by that many bits to the right
4641 + * @param mask - Masks the color index with this bitmask after the shift (0-0xFF)
4642 + * @param a3 - Unknown, set to 0
4643 +**/
4644 +void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3);
4646 +/**
4647 + * Set virtual coordinate offset
4649 + * The PSP has a virtual coordinate-space of 4096x4096, this controls where rendering is performed
4650 + *
4651 + * @par Example: Center the virtual coordinate range
4652 + * @code
4653 + * sceGuOffset(2048-(480/2),2048-(480/2));
4654 + * @endcode
4656 + * @param x - Offset (0-4095)
4657 + * @param y - Offset (0-4095)
4658 +**/
4659 +void sceGuOffset(unsigned int x, unsigned int y);
4661 +/**
4662 + * Set what to scissor within the current viewport
4664 + * Note that scissoring is only performed if the custom scissoring is enabled (GU_SCISSOR_TEST)
4666 + * @param x - Left of scissor region
4667 + * @param y - Top of scissor region
4668 + * @param w - Width of scissor region
4669 + * @param h - Height of scissor region
4670 +**/
4671 +void sceGuScissor(int x, int y, int w, int h);
4673 +/**
4674 + * Set current viewport
4676 + * @par Example: Setup a viewport of size (480,272) with origo at (2048,2048)
4677 + * @code
4678 + * sceGuViewport(2048,2048,480,272);
4679 + * @endcode
4681 + * @param cx - Center for horizontal viewport
4682 + * @param cy - Center for vertical viewport
4683 + * @param width - Width of viewport
4684 + * @param height - Height of viewport
4685 +**/
4686 +void sceGuViewport(int cx, int cy, int width, int height);
4688 +/**
4689 + * Draw bezier surface
4691 + * @param vtype - Vertex type, look at sceGuDrawArray() for vertex definition
4692 + * @param ucount - Number of vertices used in the U direction
4693 + * @param vcount - Number of vertices used in the V direction
4694 + * @param indices - Pointer to index buffer
4695 + * @param vertices - Pointer to vertex buffer
4696 +**/
4697 +void sceGuDrawBezier(int vtype, int ucount, int vcount, const void* indices, const void* vertices);
4699 +/**
4700 + * Set dividing for patches (beziers and splines)
4702 + * @param ulevel - Number of division on u direction
4703 + * @param vlevel - Number of division on v direction
4704 +**/
4705 +void sceGuPatchDivide(unsigned int ulevel, unsigned int vlevel);
4707 +void sceGuPatchFrontFace(unsigned int a0);
4709 +/**
4710 + * Set primitive for patches (beziers and splines)
4712 + * @param prim - Desired primitive type (GU_POINTS | GU_LINE_STRIP | GU_TRIANGLE_STRIP)
4713 +**/
4714 +void sceGuPatchPrim(int prim);
4716 +void sceGuDrawSpline(int vtype, int ucount, int vcount, int uedge, int vedge, const void* indices, const void* vertices);
4718 +/**
4719 + * Set transform matrices
4721 + * Available matrices are:
4722 + * - GU_PROJECTION - View->Projection matrix
4723 + * - GU_VIEW - World->View matrix
4724 + * - GU_MODEL - Model->World matrix
4725 + * - GU_TEXTURE - Texture matrix
4727 + * @param type - Which matrix-type to set
4728 + * @param matrix - Matrix to load
4729 +**/
4730 +void sceGuSetMatrix(int type, const ScePspFMatrix4* matrix);
4732 +/**
4733 + * Specify skinning matrix entry
4735 + * To enable vertex skinning, pass GU_WEIGHTS(n), where n is between
4736 + * 1-8, and pass available GU_WEIGHT_??? declaration. This will change
4737 + * the amount of weights passed in the vertex araay, and by setting the skinning,
4738 + * matrices, you will multiply each vertex every weight and vertex passed.
4740 + * Please see sceGuDrawArray() for vertex format information.
4742 + * @param index - Skinning matrix index (0-7)
4743 + * @param matrix - Matrix to set
4744 +**/
4745 +void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4* matrix);
4747 +/**
4748 + * Specify morph weight entry
4750 + * To enable vertex morphing, pass GU_VERTICES(n), where n is between
4751 + * 1-8. This will change the amount of vertices passed in the vertex array,
4752 + * and by setting the morph weights for every vertex entry in the array,
4753 + * you can blend between them.
4755 + * Please see sceGuDrawArray() for vertex format information.
4757 + * @param index - Morph weight index (0-7)
4758 + * @param weight - Weight to set
4759 +**/
4760 +void sceGuMorphWeight(int index, float weight);
4762 +void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void* indices, const void* vertices);
4764 +/**
4765 + * Set how the display should be set
4767 + * Available behaviours are:
4768 + * - PSP_DISPLAY_SETBUF_IMMEDIATE - Display is swapped immediately
4769 + * - PSP_DISPLAY_SETBUF_NEXTFRAME - Display is swapped on the next frame
4771 + * Do remember that this swaps the pointers internally, regardless of setting, so be careful to wait until the next
4772 + * vertical blank or use another buffering algorithm (see guSwapBuffersCallback()).
4773 +**/
4774 +void guSwapBuffersBehaviour(int behaviour);
4776 +/**
4777 + * Set a buffer swap callback to allow for more advanced buffer methods without hacking the library.
4779 + * The GuSwapBuffersCallback is defined like this:
4780 + * @code
4781 + * void swapBuffersCallback(void** display, void** render);
4782 + * @endcode
4783 + * and on entry they contain the variables that are to be set. To change the pointers that will be used, just
4784 + * write the new pointers. Example of a triple-buffering algorithm:
4785 + * @code
4786 + * void* doneBuffer;
4787 + * void swapBuffersCallback(void** display, void** render)
4788 + * {
4789 + * void* active = doneBuffer;
4790 + * doneBuffer = *display;
4791 + *display = active;
4792 + * }
4793 + * @endcode
4795 + * @param callback - Callback to access when buffers are swapped. Pass 0 to disable.
4796 +**/
4797 +void guSwapBuffersCallback(GuSwapBuffersCallback callback);
4799 +/**@}*/
4801 +#if defined(__cplusplus)
4803 +#endif
4805 +#endif
4806 diff --git a/newlib/psp/include/pspgum.h b/newlib/psp/include/pspgum.h
4807 new file mode 100644
4808 index 0000000..0baf46a
4809 --- /dev/null
4810 +++ b/newlib/psp/include/pspgum.h
4811 @@ -0,0 +1,236 @@
4813 + * PSP Software Development Kit - https://github.com/pspdev
4814 + * -----------------------------------------------------------------------
4815 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
4817 + * Copyright (c) 2005 Jesper Svennevid
4818 + */
4820 +#ifndef __pspgum_h__
4821 +#define __pspgum_h__
4823 +#include <psptypes.h>
4825 +#if defined(__cplusplus)
4826 +extern "C" {
4827 +#endif
4829 +// stack functions
4831 +void sceGumDrawArray(int prim, int vtype, int count, const void* indices, const void* vertices);
4832 +void sceGumDrawArrayN(int prim, int vtype, int count, int a3, const void* indices, const void* vertices);
4833 +void sceGumDrawBezier(int vtype, int ucount, int vcount, const void* indices, const void* vertices);
4834 +void sceGumDrawSpline(int vtype, int ucount, int vcount, int uedge, int vedge, const void* indices, const void* vertices);
4836 +/**
4837 + * Load identity matrix
4839 + * [1 0 0 0]
4840 + * [0 1 0 0]
4841 + * [0 0 1 0]
4842 + * [0 0 0 1]
4843 +**/
4844 +void sceGumLoadIdentity(void);
4846 +/**
4847 + * Load matrix
4849 + * @param m - Matrix to load into stack
4850 +**/
4851 +void sceGumLoadMatrix(const ScePspFMatrix4* m);
4853 +void sceGumLookAt(ScePspFVector3* eye, ScePspFVector3* center, ScePspFVector3* up);
4855 +/**
4856 + * Select which matrix stack to operate on
4858 + * Available matrix modes are:
4859 + * - GU_PROJECTION
4860 + * - GU_VIEW
4861 + * - GU_MODEL
4862 + * - GU_TEXTURE
4864 + * @param mode - Matrix mode to use
4865 +**/
4866 +void sceGumMatrixMode(int mode);
4868 +/**
4869 + * Multiply current matrix with input
4871 + * @param m - Matrix to multiply stack with
4872 +**/
4873 +void sceGumMultMatrix(const ScePspFMatrix4* m);
4875 +/**
4876 + * Apply ortho projection matrix
4878 + * @note The matrix loses its orthonogal status after executing this function.
4879 +**/
4880 +void sceGumOrtho(float left, float right, float bottom, float top, float near, float far);
4882 +/**
4883 + * Apply perspective projection matrix
4885 + * @note The matrix loses its orthonogal status after executing this function.
4886 +**/
4887 +void sceGumPerspective(float fovy, float aspect, float near, float far);
4889 +/**
4890 + * Pop matrix from stack
4891 +**/
4892 +void sceGumPopMatrix(void);
4894 +/**
4895 + * Push current matrix onto stack
4896 +**/
4897 +void sceGumPushMatrix(void);
4899 +/**
4900 + * Rotate around the X axis
4902 + * @param angle - Angle in radians
4903 +**/
4904 +void sceGumRotateX(float angle);
4906 +/**
4907 + * Rotate around the Y axis
4909 + * @param angle - Angle in radians
4910 +**/
4911 +void sceGumRotateY(float angle);
4913 +/**
4914 + * Rotate around the Z axis
4916 + * @param angle - Angle in radians
4917 +**/
4918 +void sceGumRotateZ(float angle);
4920 +/**
4921 + * Rotate around all 3 axis in order X, Y, Z
4923 + * @param v - Pointer to vector containing angles
4924 +**/
4925 +void sceGumRotateXYZ(const ScePspFVector3* v);
4927 +/**
4928 + * Rotate around all 3 axis in order Z, Y, X
4930 + * @param v - Pointer to vector containing angles
4931 +**/
4932 +void sceGumRotateZYX(const ScePspFVector3* v);
4934 +/**
4935 + * Scale matrix
4937 + * @note The matrix loses its orthonogal status after executing this function.
4938 +**/
4939 +void sceGumScale(const ScePspFVector3* v);
4941 +/**
4942 + * Store current matrix in the stack
4944 + * @param m - Matrix to write result to
4945 +**/
4946 +void sceGumStoreMatrix(ScePspFMatrix4* m);
4948 +/**
4949 + * Translate coordinate system
4951 + * @param v - Translation coordinates
4952 +**/
4953 +void sceGumTranslate(const ScePspFVector3* v);
4955 +/**
4956 + * Explicitly flush dirty matrices to the hardware
4957 +**/
4958 +void sceGumUpdateMatrix(void);
4960 +/**
4961 + * Invert 4x4 matrix
4963 + * This invert algorithm can operate on matrices that are not orthongal (See sceGumFastInverse())
4964 +**/
4965 +void sceGumFullInverse();
4967 +/**
4968 + * Invert orthonogal 4x4 matrix
4970 + * Note that the matrix in the stack has to be orthonogal (that is, all rotational axises must be unit length & orthonogal against the others),
4971 + * otherwise the result of the function cannot be depended on. If you need to invert a matrix that is not orthonogal, use sceGumFullInverse().
4972 +**/
4973 +void sceGumFastInverse();
4975 +/**
4976 + * Stack-aware version of sceGuBeginObject() (look in pspgu.h for description)
4978 + * @note NOT YET IMPLEMENTED
4980 + * @param vtype - Vertex type to process
4981 + * @param count - Number of vertices to test
4982 + * @param indices - Optional index-list
4983 + * @param vertices - Vertex-list
4984 +**/
4985 +void sceGumBeginObject(int vtype, int count, const void* indices, const void* vertices);
4987 +/**
4988 + * Stack-aware version of sceGuEndObject()
4990 + * @note NOT YET IMPLEMENTED
4991 +**/
4992 +void sceGumEndObject();
4994 +// unimplemented functions
4996 +//sceGumLoadContext
4997 +//sceGumSetCurMatrix
4998 +//sceGumSetMatrixStack
4999 +//sceGumStoreContext
5001 +// standalone functions
5003 +void gumInit(void);
5005 +/**
5006 + * Load matrix with identity
5008 + * @param m - Matrix to load with identity
5009 +**/
5010 +void gumLoadIdentity(ScePspFMatrix4* m);
5012 +void gumLoadMatrix(ScePspFMatrix4* r, const ScePspFMatrix4* a);
5013 +void gumLookAt(ScePspFMatrix4* m, ScePspFVector3* eye, ScePspFVector3* center, ScePspFVector3* up);
5014 +void gumMultMatrix(ScePspFMatrix4* result, const ScePspFMatrix4* a, const ScePspFMatrix4* b);
5015 +void gumOrtho(ScePspFMatrix4* m, float left, float right, float bottom, float top, float near, float far);
5016 +void gumPerspective(ScePspFMatrix4* m, float fovy, float aspect, float near, float far);
5017 +void gumRotateX(ScePspFMatrix4* m, float angle);
5018 +void gumRotateXYZ(ScePspFMatrix4* m, const ScePspFVector3* v);
5019 +void gumRotateY(ScePspFMatrix4* m, float angle);
5020 +void gumRotateZ(ScePspFMatrix4* m, float angle);
5021 +void gumRotateZYX(ScePspFMatrix4* m, const ScePspFVector3* v);
5022 +void gumScale(ScePspFMatrix4* m, const ScePspFVector3* v);
5023 +void gumTranslate(ScePspFMatrix4* m, const ScePspFVector3* v);
5024 +void gumFullInverse(ScePspFMatrix4* r, const ScePspFMatrix4* a);
5026 +/**
5027 + * Invert orthonogal 4x4 matrix
5029 + * Note that the matrix in the stack has to be orthonogal (that is, all rotational axises must be unit length & orthonogal against the others),
5030 + * otherwise the result of the function cannot be depended on. If you need to invert a matrix that is not orthonogal, use gumFullInverse().
5032 + * @param r - Matrix receiving result
5033 + * @param a - Orthonogal matrix that is to be inverted
5034 +**/
5035 +void gumFastInverse(ScePspFMatrix4* r, const ScePspFMatrix4* a);
5037 +// vector functions
5039 +void gumCrossProduct(ScePspFVector3* r, const ScePspFVector3* a, const ScePspFVector3* b);
5040 +float gumDotProduct(const ScePspFVector3* a, const ScePspFVector3* b);
5041 +void gumNormalize(ScePspFVector3* v);
5043 +#if defined(__cplusplus)
5045 +#endif
5047 +#endif
5048 diff --git a/newlib/psp/include/psphprm.h b/newlib/psp/include/psphprm.h
5049 new file mode 100644
5050 index 0000000..ac0a930
5051 --- /dev/null
5052 +++ b/newlib/psp/include/psphprm.h
5053 @@ -0,0 +1,94 @@
5055 + * PSP Software Development Kit - https://github.com/pspdev
5056 + * -----------------------------------------------------------------------
5057 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5059 + * pspaudio.h - Prototypes for the sceHprm library.
5061 + * Copyright (c) 2005 Adresd
5063 + */
5064 +#ifndef __HPRM_H__
5065 +#define __HPRM_H__
5067 +#include <psptypes.h>
5069 +#ifdef __cplusplus
5070 +extern "C" {
5071 +#endif
5073 +/** @defgroup Hprm Hprm Remote */
5075 +/** @addtogroup Hprm */
5077 +/**@{*/
5079 +/** Enumeration of the remote keys */
5080 +enum PspHprmKeys
5082 + PSP_HPRM_PLAYPAUSE = 0x1,
5083 + PSP_HPRM_FORWARD = 0x4,
5084 + PSP_HPRM_BACK = 0x8,
5085 + PSP_HPRM_VOL_UP = 0x10,
5086 + PSP_HPRM_VOL_DOWN = 0x20,
5087 + PSP_HPRM_HOLD = 0x80
5090 +/**
5091 + * Peek at the current being pressed on the remote.
5092 + *
5093 + * @param key - Pointer to the u32 to receive the key bitmap, should be one or
5094 + * more of ::PspHprmKeys
5096 + * @return < 0 on error
5097 + */
5098 +int sceHprmPeekCurrentKey(u32 *key);
5100 +/**
5101 + * Peek at the current latch data.
5103 + * @param latch - Pointer a to a 4 dword array to contain the latch data.
5105 + * @return < 0 on error.
5106 + */
5107 +int sceHprmPeekLatch(u32 *latch);
5109 +/**
5110 + * Read the current latch data.
5112 + * @param latch - Pointer a to a 4 dword array to contain the latch data.
5114 + * @return < 0 on error.
5115 + */
5116 +int sceHprmReadLatch(u32 *latch);
5118 +/**
5119 + * Determines whether the headphones are plugged in.
5121 + * @return 1 if the headphones are plugged in, else 0.
5122 + */
5123 +int sceHprmIsHeadphoneExist(void);
5125 +/**
5126 + * Determines whether the remote is plugged in.
5128 + * @return 1 if the remote is plugged in, else 0.
5129 + */
5130 +int sceHprmIsRemoteExist(void);
5132 +/**
5133 + * Determines whether the microphone is plugged in.
5135 + * @return 1 if the microphone is plugged in, else 0.
5136 + */
5137 +int sceHprmIsMicrophoneExist(void);
5141 +/**@}*/
5143 +#ifdef __cplusplus
5145 +#endif
5147 +#endif
5148 diff --git a/newlib/psp/include/psphttp.h b/newlib/psp/include/psphttp.h
5149 new file mode 100644
5150 index 0000000..9667afe
5151 --- /dev/null
5152 +++ b/newlib/psp/include/psphttp.h
5153 @@ -0,0 +1,393 @@
5155 + * PSP Software Development Kit - https://github.com/pspdev
5156 + * -----------------------------------------------------------------------
5157 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5159 + * psphttp.h - Interface to the http library.
5161 + * Copyright (c) 2008 David Perry (InsertWittyName)
5162 + * Copyright (c) 2008 moonlight
5164 + */
5166 +#ifndef __PSPHTTP_H__
5167 +#define __PSPHTTP_H__
5169 +#if defined(__cplusplus)
5170 +extern "C" {
5171 +#endif
5173 +typedef enum
5175 + PSP_HTTP_VERSION_1_0,
5176 + PSP_HTTP_VERSION_1_1
5177 +} PspHttpHttpVersion;
5179 +typedef enum
5181 + PSP_HTTP_METHOD_GET,
5182 + PSP_HTTP_METHOD_POST,
5183 + PSP_HTTP_METHOD_HEAD
5185 +} PspHttpMethod;
5187 +typedef enum
5189 + PSP_HTTP_AUTH_BASIC,
5190 + PSP_HTTP_AUTH_DIGEST
5191 +} PspHttpAuthType;
5194 +typedef enum
5196 + PSP_HTTP_PROXY_AUTO,
5197 + PSP_HTTP_PROXY_MANUAL
5198 +} PspHttpProxyMode;
5200 +typedef enum
5202 + PSP_HTTP_HEADER_OVERWRITE,
5203 + PSP_HTTP_HEADER_ADD
5204 +} PspHttpAddHeaderMode;
5206 +/* Memory function types */
5207 +typedef void *(*PspHttpMallocFunction)(SceSize size);
5208 +typedef void *(*PspHttpReallocFunction)(void *p, SceSize size);
5209 +typedef void (*PspHttpFreeFunction)(void *p);
5211 +typedef int (*PspHttpPasswordCB)(
5212 + int request,
5213 + PspHttpAuthType auth_type,
5214 + const unsigned char *realm,
5215 + unsigned char *username,
5216 + unsigned char *password,
5217 + SceBool need_entity,
5218 + unsigned char **entity_body,
5219 + SceSize *entity_size,
5220 + SceBool *save);
5222 +/**
5223 + * Init the http library.
5225 + * @param unknown1 - Memory pool size? Pass 20000
5226 + * @return 0 on success, < 0 on error.
5227 + */
5228 +int sceHttpInit(unsigned int unknown1);
5230 +/**
5231 + * Terminate the http library.
5233 + * @return 0 on success, < 0 on error.
5234 + */
5235 +int sceHttpEnd(void);
5237 +/**
5238 + * Create a http template.
5240 + * @param agent - User agent
5241 + * @param unknown1 - Pass 1
5242 + * @param unknown2 - Pass 0
5243 + * @return A template ID on success, < 0 on error.
5244 + */
5245 +int sceHttpCreateTemplate(char *agent, int unknown1, int unknown2);
5247 +/**
5248 + * Delete a http template.
5250 + * @param templateid - ID of the template created by sceHttpCreateTemplate
5251 + * @return 0 on success, < 0 on error.
5252 + */
5253 +int sceHttpDeleteTemplate(int templateid);
5255 +/**
5256 + * Create a http connection.
5258 + * @param templateid - ID of the template created by sceHttpCreateTemplate
5259 + * @param host - Host to connect to
5260 + * @param unknown1 - Pass "http"
5261 + * @param port - Port to connect on
5262 + * @param unknown2 - Pass 0
5263 + * @return A connection ID on success, < 0 on error.
5264 + */
5265 +int sceHttpCreateConnection(int templateid, char *host, char *unknown1, unsigned short port, int unknown2);
5267 +/**
5268 + * Create a http connection to a url.
5270 + * @param templateid - ID of the template created by sceHttpCreateTemplate
5271 + * @param url - url to connect to
5272 + * @param unknown1 - Pass 0
5273 + * @return A connection ID on success, < 0 on error.
5274 + */
5275 +int sceHttpCreateConnectionWithURL(int templateid, const char *url, int unknown1);
5277 +/**
5278 + * Delete a http connection.
5280 + * @param connectionid - ID of the connection created by sceHttpCreateConnection or sceHttpCreateConnectionWithURL
5281 + * @return 0 on success, < 0 on error.
5282 + */
5283 +int sceHttpDeleteConnection(int connectionid);
5285 +/**
5286 + * Create a http request.
5288 + * @param connectionid - ID of the connection created by sceHttpCreateConnection or sceHttpCreateConnectionWithURL
5289 + * @param method - One of ::PspHttpMethod
5290 + * @param path - Path to access
5291 + * @param contentlength - Length of the content (POST method only)
5292 + * @return A request ID on success, < 0 on error.
5293 + */
5294 +int sceHttpCreateRequest(int connectionid, PspHttpMethod method, char *path, SceULong64 contentlength);
5296 +/**
5297 + * Create a http request with url.
5299 + * @param connectionid - ID of the connection created by sceHttpCreateConnection or sceHttpCreateConnectionWithURL
5300 + * @param method - One of ::PspHttpMethod
5301 + * @param url - url to access
5302 + * @param contentlength - Length of the content (POST method only)
5303 + * @return A request ID on success, < 0 on error.
5304 + */
5305 +int sceHttpCreateRequestWithURL(int connectionid, PspHttpMethod method, char *url, SceULong64 contentlength);
5307 +/**
5308 + * Delete a http request.
5310 + * @param requestid - ID of the request created by sceHttpCreateRequest or sceHttpCreateRequestWithURL
5311 + * @return 0 on success, < 0 on error.
5312 + */
5313 +int sceHttpDeleteRequest(int requestid);
5315 +/**
5316 + * Send a http request.
5318 + * @param requestid - ID of the request created by sceHttpCreateRequest or sceHttpCreateRequestWithURL
5319 + * @param data - For POST methods specify a pointer to the post data, otherwise pass NULL
5320 + * @param datasize - For POST methods specify the size of the post data, otherwise pass 0
5321 + * @return 0 on success, < 0 on error.
5322 + */
5323 +int sceHttpSendRequest(int requestid, void *data, unsigned int datasize);
5325 +/**
5326 + * Abort a http request.
5328 + * @param requestid - ID of the request created by sceHttpCreateRequest or sceHttpCreateRequestWithURL
5329 + * @return 0 on success, < 0 on error.
5330 + */
5331 +int sceHttpAbortRequest(int requestid);
5333 +/**
5334 + * Read a http request response.
5336 + * @param requestid - ID of the request created by sceHttpCreateRequest or sceHttpCreateRequestWithURL
5337 + * @param data - Buffer for the response data to be stored
5338 + * @param datasize - Size of the buffer
5339 + * @return The size read into the data buffer, 0 if there is no more data, < 0 on error.
5340 + */
5341 +int sceHttpReadData(int requestid, void *data, unsigned int datasize);
5343 +/**
5344 + * Get http request response length.
5346 + * @param requestid - ID of the request created by sceHttpCreateRequest or sceHttpCreateRequestWithURL
5347 + * @param contentlength - The size of the content
5348 + * @return 0 on success, < 0 on error.
5349 + */
5350 +int sceHttpGetContentLength(int requestid, SceULong64 *contentlength);
5352 +/**
5353 + * Get http request status code.
5355 + * @param requestid - ID of the request created by sceHttpCreateRequest or sceHttpCreateRequestWithURL
5356 + * @param statuscode - The status code from the host (200 is ok, 404 is not found etc)
5357 + * @return 0 on success, < 0 on error.
5358 + */
5359 +int sceHttpGetStatusCode(int requestid, int *statuscode);
5361 +/**
5362 + * Set resolver timeout
5364 + * @param id - ID of the template or connection
5365 + * @param timeout - Timeout value in microseconds
5366 + * @return 0 on success, < 0 on error.
5367 + */
5368 +int sceHttpSetResolveTimeOut(int id, unsigned int timeout);
5370 +/**
5371 + * Set resolver retry
5373 + * @param id - ID of the template or connection
5374 + * @param count - Number of retries
5375 + * @return 0 on success, < 0 on error.
5376 + */
5377 +int sceHttpSetResolveRetry(int id, int count);
5379 +/**
5380 + * Set connect timeout
5382 + * @param id - ID of the template, connection or request
5383 + * @param timeout - Timeout value in microseconds
5384 + * @return 0 on success, < 0 on error.
5385 + */
5386 +int sceHttpSetConnectTimeOut(int id, unsigned int timeout);
5388 +/**
5389 + * Set send timeout
5391 + * @param id - ID of the template, connection or request
5392 + * @param timeout - Timeout value in microseconds
5393 + * @return 0 on success, < 0 on error.
5394 + */
5395 +int sceHttpSetSendTimeOut(int id, unsigned int timeout);
5397 +/**
5398 + * Set receive timeout
5400 + * @param id - ID of the template or connection
5401 + * @param timeout - Timeout value in microseconds
5402 + * @return 0 on success, < 0 on error.
5403 + */
5404 +int sceHttpSetRecvTimeOut(int id, unsigned int timeout);
5406 +/**
5407 + * Enable keep alive
5409 + * @param id - ID of the template or connection
5410 + * @return 0 on success, < 0 on error.
5411 + */
5412 +int sceHttpEnableKeepAlive(int id);
5414 +/**
5415 + * Disable keep alive
5417 + * @param id - ID of the template or connection
5418 + * @return 0 on success, < 0 on error.
5419 + */
5420 +int sceHttpDisableKeepAlive(int id);
5422 +/**
5423 + * Enable redirect
5425 + * @param id - ID of the template or connection
5426 + * @return 0 on success, < 0 on error.
5427 + */
5428 +int sceHttpEnableRedirect(int id);
5430 +/**
5431 + * Disable redirect
5433 + * @param id - ID of the template or connection
5434 + * @return 0 on success, < 0 on error.
5435 + */
5436 +int sceHttpDisableRedirect(int id);
5438 +/**
5439 + * Enable cookie
5441 + * @param id - ID of the template or connection
5442 + * @return 0 on success, < 0 on error.
5443 + */
5444 +int sceHttpEnableCookie(int id);
5446 +/**
5447 + * Disable cookie
5449 + * @param id - ID of the template or connection
5450 + * @return 0 on success, < 0 on error.
5451 + */
5452 +int sceHttpDisableCookie(int id);
5454 +/**
5455 + * Save cookie
5457 + * @return 0 on success, < 0 on error.
5458 + */
5459 +int sceHttpSaveSystemCookie(void);
5461 +/**
5462 + * Load cookie
5464 + * @return 0 on success, < 0 on error.
5465 + */
5466 +int sceHttpLoadSystemCookie(void);
5468 +/**
5469 + * Add content header
5471 + * @param id - ID of the template, connection or request
5472 + * @param name - Name of the content
5473 + * @param value - Value of the content
5474 + * @param unknown1 - Pass 0
5475 + * @return 0 on success, < 0 on error.
5476 + */
5477 +int sceHttpAddExtraHeader(int id, char *name, char *value, int unknown1);
5479 +/**
5480 + * Delete content header
5482 + * @param id - ID of the template, connection or request
5483 + * @param name - Name of the content
5484 + * @return 0 on success, < 0 on error.
5485 + */
5486 +int sceHttpDeleteHeader(int id, const char *name);
5488 +/**
5489 + * Init the https library.
5491 + * @param unknown1 - Pass 0
5492 + * @param unknown2 - Pass 0
5493 + * @param unknown3 - Pass 0
5494 + * @param unknown4 - Pass 0
5496 + * @return 0 on success, < 0 on error.
5498 +int sceHttpsInit(int unknown1, int unknown2, int unknown3, int unknown4);
5500 +/**
5501 + * Terminate the https library
5503 + * @return 0 on success, < 0 on error.
5505 +int sceHttpsEnd(void);
5507 +/**
5508 + * Load default certificate
5510 + * @param unknown1 - Pass 0
5511 + * @param unknown2 - Pass 0
5512 + * @return 0 on success, < 0 on error.
5514 +int sceHttpsLoadDefaultCert(int unknown1, int unknown2);
5516 +int sceHttpDisableAuth(int id);
5518 +int sceHttpDisableCache(int id);
5520 +int sceHttpEnableAuth(int id);
5522 +int sceHttpEnableCache(int id);
5524 +int sceHttpEndCache(void);
5526 +int sceHttpGetAllHeader(int request, unsigned char **header, unsigned int *header_size);
5528 +int sceHttpGetNetworkErrno(int request, int *err_num);
5530 +int sceHttpGetProxy(int id, int *activate_flag, int *mode, unsigned char *proxy_host, SceSize len, unsigned short *proxy_port);
5532 +int sceHttpInitCache(SceSize max_size);
5534 +int sceHttpSetAuthInfoCB(int id, PspHttpPasswordCB cbfunc);
5536 +int sceHttpSetProxy(int id, int activate_flag, int mode, const unsigned char *new_proxy_host, unsigned short new_proxy_port);
5538 +int sceHttpSetResHeaderMaxSize(int id, unsigned int header_size);
5540 +int sceHttpSetMallocFunction(PspHttpMallocFunction malloc_func, PspHttpFreeFunction free_func, PspHttpReallocFunction realloc_func);
5542 +#if defined(__cplusplus)
5544 +#endif
5546 +#endif
5547 diff --git a/newlib/psp/include/pspidstorage.h b/newlib/psp/include/pspidstorage.h
5548 new file mode 100644
5549 index 0000000..fe2be01
5550 --- /dev/null
5551 +++ b/newlib/psp/include/pspidstorage.h
5552 @@ -0,0 +1,59 @@
5554 + * PSP Software Development Kit - https://github.com/pspdev
5555 + * -----------------------------------------------------------------------
5556 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5558 + * pspidstorage.h - Interface to sceIdstorage_driver.
5560 + * Copyright (c) 2006 Harley G. <harleyg@0x89.org>
5562 + */
5564 +#ifndef PSPIDSTORAGE_H
5565 +#define PSPIDSTORAGE_H
5567 +#include <psptypes.h>
5569 +/** @defgroup IdStorage Interface to the sceIdStorage_driver library.
5570 + */
5572 +#ifdef __cplusplus
5573 +extern "C" {
5574 +#endif
5576 +/** @addtogroup IdStorage Interface to the sceIdStorage_driver library.*/
5577 +/**@{*/
5579 +/**Retrieves the value associated with a key
5580 + * @param key - idstorage key
5581 + * @param offset - offset within the 512 byte leaf
5582 + * @param buf - buffer with enough storage
5583 + * @param len - amount of data to retrieve (offset + len must be <= 512 bytes)
5584 + */
5585 +int sceIdStorageLookup(u16 key, u32 offset, void *buf, u32 len);
5587 +/** Retrieves the whole 512 byte container for the key
5588 + * @param key - idstorage key
5589 + * @param buf - buffer with at last 512 bytes of storage
5590 + */
5591 +int sceIdStorageReadLeaf(u16 key, void *buf);
5593 +/** sceIdStorageWriteLeaf() - Writes 512-bytes to idstorage key
5594 + * @param key - idstorage key
5595 + * @param buf - buffer with 512-btes of data
5596 + */
5597 +int sceIdStorageWriteLeaf(u16 key, void *buf);
5599 +/** sceIdStorageIsReadOnly() - Checks idstorage for readonly status */
5600 +int sceIdStorageIsReadOnly(void);
5602 +/** sceIdStorageFlush() - Finalizes a write */
5603 +int sceIdStorageFlush(void);
5605 +/**@}*/
5607 +#ifdef __cplusplus
5609 +#endif
5611 +#endif
5612 diff --git a/newlib/psp/include/pspimport.s b/newlib/psp/include/pspimport.s
5613 new file mode 100644
5614 index 0000000..6dffc4b
5615 --- /dev/null
5616 +++ b/newlib/psp/include/pspimport.s
5617 @@ -0,0 +1,68 @@
5619 +.macro IMPORT_START module, flags_ver
5621 + .set push
5622 + .section .rodata.sceResident, "a"
5623 + .word 0
5624 +__stub_modulestr_\module:
5625 + .asciz "\module"
5626 + .align 2
5628 + .section .lib.stub, "a", @progbits
5629 + .global __stub_module_\module
5630 +__stub_module_\module:
5631 + .word __stub_modulestr_\module
5632 + .word \flags_ver
5633 + .word 0x5
5634 + .word __executable_start
5635 + .word __executable_start
5637 + .set pop
5638 +.endm
5640 +.macro IMPORT_FUNC module, funcid, funcname
5642 + .set push
5643 + .set noreorder
5645 + .extern __stub_module_\module
5646 + .section .sceStub.text, "ax", @progbits
5647 + .globl \funcname
5648 + .type \funcname, @function
5649 + .ent \funcname, 0
5650 +\funcname:
5651 + .word __stub_module_\module
5652 + .word \funcid
5653 + .end \funcname
5654 + .size \funcname, .-\funcname
5656 + .section .rodata.sceNid, "a"
5657 + .word \funcid
5659 + .set pop
5660 +.endm
5662 +.macro IMPORT_FUNC_WITH_ALIAS module, funcid, funcname, alias
5664 + .set push
5665 + .set noreorder
5667 + .extern __stub_module_\module
5668 + .section .sceStub.text, "ax", @progbits
5669 + .globl \alias
5670 + .type \alias, @function
5671 +\alias:
5672 + .globl \funcname
5673 + .type \funcname, @function
5674 + .ent \funcname, 0
5675 +\funcname:
5676 + .word __stub_module_\module
5677 + .word \funcid
5678 + .end \funcname
5679 + .size \funcname, .-\funcname
5681 + .section .rodata.sceNid, "a"
5682 + .word \funcid
5684 + .set pop
5685 +.endm
5686 diff --git a/newlib/psp/include/pspimpose_driver.h b/newlib/psp/include/pspimpose_driver.h
5687 new file mode 100644
5688 index 0000000..08c8cad
5689 --- /dev/null
5690 +++ b/newlib/psp/include/pspimpose_driver.h
5691 @@ -0,0 +1,141 @@
5693 + * PSP Software Development Kit - https://github.com/pspdev
5694 + * -----------------------------------------------------------------------
5695 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5697 + * pspimpose_driver.h - Prototypes for the sceImpose_driver library.
5699 + * Copyright (c) 2007 Iaroslav Gaponenko <adrahil@gmail.com>
5701 + */
5703 +#ifndef __IMPOSE_DRIVER_H__
5704 +#define __IMPOSE_DRIVER_H__
5706 +#ifdef __cplusplus
5707 +extern "C" {
5708 +#endif
5710 +typedef int SceImposeParam;
5712 +/**
5713 + * These values have been found in the 3.52 kernel.
5714 + * Therefore, they might not be supported by previous ones.
5715 + */
5717 +#define PSP_IMPOSE_MAIN_VOLUME 0x1
5718 +#define PSP_IMPOSE_BACKLIGHT_BRIGHTNESS 0x2
5719 +#define PSP_IMPOSE_EQUALIZER_MODE 0x4
5720 +#define PSP_IMPOSE_MUTE 0x8
5721 +#define PSP_IMPOSE_AVLS 0x10
5722 +#define PSP_IMPOSE_TIME_FORMAT 0x20
5723 +#define PSP_IMPOSE_DATE_FORMAT 0x40
5724 +#define PSP_IMPOSE_LANGUAGE 0x80
5725 +#define PSP_IMPOSE_BACKLIGHT_OFF_INTERVAL 0x200
5726 +#define PSP_IMPOSE_SOUND_REDUCTION 0x400
5728 +#define PSP_IMPOSE_UMD_POPUP_ENABLED 1
5729 +#define PSP_IMPOSE_UMD_POPUP_DISABLED 0
5731 +/**
5732 + * Fetch the value of an Impose parameter.
5734 + * @return value of the parameter on success, < 0 on error
5735 + */
5736 +int sceImposeGetParam(SceImposeParam param);
5738 +/**
5739 + * Change the value of an Impose parameter.
5741 + * @param param - The parameter to change.
5742 + * @param value - The value to set the parameter to.
5743 + * @return < 0 on error
5745 + */
5746 +int sceImposeSetParam(SceImposeParam param, int value);
5748 +/**
5749 + * Get the value of the backlight timer.
5751 + * @return backlight timer in seconds or < 0 on error
5753 + */
5754 +int sceImposeGetBacklightOffTime(void);
5756 +/**
5757 + * Set the value of the backlight timer.
5759 + * @param value - The backlight timer. (30 to a lot of seconds)
5760 + * @return < 0 on error
5762 + */
5763 +int sceImposeSetBacklightOffTime(int value);
5765 +/**
5766 + * Get the language and button assignment parameters
5768 + * @return < 0 on error
5770 + */
5771 +int sceImposeGetLanguageMode(int* lang, int* button);
5773 +/**
5774 + * Set the language and button assignment parameters
5776 + * /!\ parameter values not known.
5778 + * @param lang - Language
5779 + * @param button - Button assignment
5780 + * @return < 0 on error
5782 + */
5783 +int sceImposeSetLanguageMode(int lang, int button);
5785 +/**
5786 + * Get the value of the UMD popup.
5788 + * @return umd popup state or < 0 on error
5790 + */
5791 +int sceImposeGetUMDPopup(void);
5793 +/**
5794 + * Set the value of the UMD popup.
5796 + * @param value - The popup mode.
5797 + * @return < 0 on error
5799 + */
5800 +int sceImposeSetUMDPopup(int value);
5802 +/**
5803 + * Get the value of the Home popup.
5805 + * @return home popup state or < 0 on error
5807 + */
5808 +int sceImposeGetHomePopup(void);
5810 +/**
5811 + * Set the value of the Home popup.
5813 + * @param value - The popup mode.
5814 + * @return < 0 on error
5816 + */
5817 +int sceImposeSetHomePopup(int value);
5819 +/**
5820 + * Check the video out. (for psp slim?)
5822 + * @param value - video out mode/status(?)
5823 + * @return < 0 on error
5825 + */
5826 +int sceImposeCheckVideoOut(int* value);
5828 +#ifdef __cplusplus
5830 +#endif
5832 +#endif
5833 diff --git a/newlib/psp/include/pspinit.h b/newlib/psp/include/pspinit.h
5834 new file mode 100644
5835 index 0000000..d0715c6
5836 --- /dev/null
5837 +++ b/newlib/psp/include/pspinit.h
5838 @@ -0,0 +1,73 @@
5840 + * PSP Software Development Kit - https://github.com/pspdev
5841 + * -----------------------------------------------------------------------
5842 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5844 + * pspinit.h - Interface to InitForKernel.
5846 + * Copyright (c) 2007 moonlight
5848 + */
5849 +#ifndef __PSPINIT_H__
5850 +#define __PSPINIT_H__
5852 +enum PSPBootFrom
5854 + PSP_BOOT_FLASH = 0, /* ? */
5855 + PSP_BOOT_DISC = 0x20,
5856 + PSP_BOOT_MS = 0x40,
5859 +enum PSPInitApitype
5861 + PSP_INIT_APITYPE_DISC = 0x120,
5862 + PSP_INIT_APITYPE_DISC_UPDATER = 0x121,
5863 + PSP_INIT_APITYPE_MS1 = 0x140,
5864 + PSP_INIT_APITYPE_MS2 = 0x141,
5865 + PSP_INIT_APITYPE_MS3 = 0x142,
5866 + PSP_INIT_APITYPE_MS4 = 0x143,
5867 + PSP_INIT_APITYPE_MS5 = 0x144,
5868 + PSP_INIT_APITYPE_VSH1 = 0x210, /* ExitGame */
5869 + PSP_INIT_APITYPE_VSH2 = 0x220, /* ExitVSH */
5872 +enum PSPKeyConfig
5874 + PSP_INIT_KEYCONFIG_VSH = 0x100,
5875 + PSP_INIT_KEYCONFIG_GAME = 0x200,
5876 + PSP_INIT_KEYCONFIG_POPS = 0x300,
5879 +/**
5880 + * Gets the api type
5882 + * @return the api type in which the system has booted
5884 +int sceKernelInitApitype();
5886 +/**
5887 + * Gets the filename of the executable to be launched after all modules of the api.
5889 + * @return filename of executable or NULL if no executable found.
5891 +char *sceKernelInitFileName();
5893 +/**
5895 + * Gets the device in which the application was launched.
5897 + * @return the device code, one of PSPBootFrom values.
5899 +int sceKernelBootFrom();
5901 +/**
5902 + * Get the key configuration in which the system has booted.
5904 + * @return the key configuration code, one of PSPKeyConfig values
5906 +int InitForKernel_7233B5BC();
5908 +#define sceKernelInitKeyConfig InitForKernel_7233B5BC
5910 +#endif
5912 diff --git a/newlib/psp/include/pspintrman.h b/newlib/psp/include/pspintrman.h
5913 new file mode 100644
5914 index 0000000..de7179a
5915 --- /dev/null
5916 +++ b/newlib/psp/include/pspintrman.h
5917 @@ -0,0 +1,177 @@
5919 + * PSP Software Development Kit - https://github.com/pspdev
5920 + * -----------------------------------------------------------------------
5921 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5923 + * pspintrman.h - Interface to the system interrupt manager.
5925 + * Copyright (c) 2005 James F. (tyranid@gmail.com)
5926 + * Copyright (c) 2005 Florin Sasu (...)
5928 + */
5930 +#ifndef PSPINTRMAN_H
5931 +#define PSPINTRMAN_H
5933 +#include <pspkerneltypes.h>
5935 +/** @defgroup IntrMan Interrupt Manager
5936 + * This module contains routines to manage interrupts.
5937 + */
5939 +/** @addtogroup IntrMan Interrupt Manager */
5940 +/**@{*/
5942 +#ifdef __cplusplus
5943 +extern "C" {
5944 +#endif
5946 +extern const char* PspInterruptNames[67];
5948 +enum PspInterrupts
5950 + PSP_GPIO_INT = 4,
5951 + PSP_ATA_INT = 5,
5952 + PSP_UMD_INT = 6,
5953 + PSP_MSCM0_INT = 7,
5954 + PSP_WLAN_INT = 8,
5955 + PSP_AUDIO_INT = 10,
5956 + PSP_I2C_INT = 12,
5957 + PSP_SIRCS_INT = 14,
5958 + PSP_SYSTIMER0_INT = 15,
5959 + PSP_SYSTIMER1_INT = 16,
5960 + PSP_SYSTIMER2_INT = 17,
5961 + PSP_SYSTIMER3_INT = 18,
5962 + PSP_THREAD0_INT = 19,
5963 + PSP_NAND_INT = 20,
5964 + PSP_DMACPLUS_INT = 21,
5965 + PSP_DMA0_INT = 22,
5966 + PSP_DMA1_INT = 23,
5967 + PSP_MEMLMD_INT = 24,
5968 + PSP_GE_INT = 25,
5969 + PSP_VBLANK_INT = 30,
5970 + PSP_MECODEC_INT = 31,
5971 + PSP_HPREMOTE_INT = 36,
5972 + PSP_MSCM1_INT = 60,
5973 + PSP_MSCM2_INT = 61,
5974 + PSP_THREAD1_INT = 65,
5975 + PSP_INTERRUPT_INT = 66
5978 +enum PspSubInterrupts
5980 + PSP_GPIO_SUBINT = PSP_GPIO_INT,
5981 + PSP_ATA_SUBINT = PSP_ATA_INT,
5982 + PSP_UMD_SUBINT = PSP_UMD_INT,
5983 + PSP_DMACPLUS_SUBINT = PSP_DMACPLUS_INT,
5984 + PSP_GE_SUBINT = PSP_GE_INT,
5985 + PSP_DISPLAY_SUBINT = PSP_VBLANK_INT
5988 +/**
5989 + * Suspend all interrupts.
5991 + * @return The current state of the interrupt controller, to be used with ::sceKernelCpuResumeIntr().
5992 + */
5993 +unsigned int sceKernelCpuSuspendIntr(void);
5995 +/**
5996 + * Resume all interrupts.
5998 + * @param flags - The value returned from ::sceKernelCpuSuspendIntr().
5999 + */
6000 +void sceKernelCpuResumeIntr(unsigned int flags);
6002 +/**
6003 + * Resume all interrupts (using sync instructions).
6005 + * @param flags - The value returned from ::sceKernelCpuSuspendIntr()
6006 + */
6007 +void sceKernelCpuResumeIntrWithSync(unsigned int flags);
6009 +/**
6010 + * Determine if interrupts are suspended or active, based on the given flags.
6012 + * @param flags - The value returned from ::sceKernelCpuSuspendIntr().
6014 + * @return 1 if flags indicate that interrupts were not suspended, 0 otherwise.
6015 + */
6016 +int sceKernelIsCpuIntrSuspended(unsigned int flags);
6018 +/**
6019 + * Determine if interrupts are enabled or disabled.
6021 + * @return 1 if interrupts are currently enabled.
6022 + */
6023 +int sceKernelIsCpuIntrEnable(void);
6025 +/**
6026 + * Register a sub interrupt handler.
6027 + *
6028 + * @param intno - The interrupt number to register.
6029 + * @param no - The sub interrupt handler number (user controlled)
6030 + * @param handler - The interrupt handler
6031 + * @param arg - An argument passed to the interrupt handler
6033 + * @return < 0 on error.
6034 + */
6035 +int sceKernelRegisterSubIntrHandler(int intno, int no, void *handler, void *arg);
6037 +/**
6038 + * Release a sub interrupt handler.
6039 + *
6040 + * @param intno - The interrupt number to register.
6041 + * @param no - The sub interrupt handler number
6043 + * @return < 0 on error.
6044 + */
6045 +int sceKernelReleaseSubIntrHandler(int intno, int no);
6047 +/**
6048 + * Enable a sub interrupt.
6049 + *
6050 + * @param intno - The sub interrupt to enable.
6051 + * @param no - The sub interrupt handler number
6052 + *
6053 + * @return < 0 on error.
6054 + */
6055 +int sceKernelEnableSubIntr(int intno, int no);
6057 +/**
6058 + * Disable a sub interrupt handler.
6060 + * @param intno - The sub interrupt to disable.
6061 + * @param no - The sub interrupt handler number
6062 + *
6063 + * @return < 0 on error.
6064 + */
6065 +int sceKernelDisableSubIntr(int intno, int no);
6067 +typedef struct tag_IntrHandlerOptionParam{
6068 + int size; //+00
6069 + u32 entry; //+04
6070 + u32 common; //+08
6071 + u32 gp; //+0C
6072 + u16 intr_code; //+10
6073 + u16 sub_count; //+12
6074 + u16 intr_level; //+14
6075 + u16 enabled; //+16
6076 + u32 calls; //+18
6077 + u32 field_1C; //+1C
6078 + u32 total_clock_lo; //+20
6079 + u32 total_clock_hi; //+24
6080 + u32 min_clock_lo; //+28
6081 + u32 min_clock_hi; //+2C
6082 + u32 max_clock_lo; //+30
6083 + u32 max_clock_hi; //+34
6084 +} PspIntrHandlerOptionParam; //=38
6086 +int QueryIntrHandlerInfo(SceUID intr_code, SceUID sub_intr_code, PspIntrHandlerOptionParam *data);
6088 +#ifdef __cplusplus
6090 +#endif
6092 +/**@}*/
6094 +#endif /* PSPINTRMAN_H */
6095 diff --git a/newlib/psp/include/pspintrman_kernel.h b/newlib/psp/include/pspintrman_kernel.h
6096 new file mode 100644
6097 index 0000000..5eacc32
6098 --- /dev/null
6099 +++ b/newlib/psp/include/pspintrman_kernel.h
6100 @@ -0,0 +1,81 @@
6102 + * PSP Software Development Kit - https://github.com/pspdev
6103 + * -----------------------------------------------------------------------
6104 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
6106 + * pspintrman_kernel.h - Interface to the system interrupt manager.
6108 + * Copyright (c) 2005 James F. (tyranid@gmail.com)
6110 + */
6112 +#ifndef PSPINTRMAN_KERNEL_H
6113 +#define PSPINTRMAN_KERNEL_H
6115 +#include <pspkerneltypes.h>
6117 +/** @defgroup IntrManKern Interrupt Manager Kernel
6118 + * This module contains routines to manage interrupts.
6119 + */
6121 +/** @addtogroup IntrManKern Interrupt Manager Kernel */
6122 +/**@{*/
6124 +#ifdef __cplusplus
6125 +extern "C" {
6126 +#endif
6128 +/**
6129 + * Register an interrupt handler.
6130 + *
6131 + * @param intno - The interrupt number to register.
6132 + * @param no - The queue number.
6133 + * @param handler - Pointer to the handler.
6134 + * @param arg1 - Unknown (probably a set of flags)
6135 + * @param arg2 - Unknown (probably a common pointer)
6137 + * @return 0 on success.
6138 + */
6139 +int sceKernelRegisterIntrHandler(int intno, int no, void *handler, void *arg1, void *arg2);
6141 +/**
6142 + * Release an interrupt handler
6144 + * @param intno - The interrupt number to release
6146 + * @return 0 on success
6147 + */
6148 +int sceKernelReleaseIntrHandler(int intno);
6150 +/**
6151 + * Enable an interrupt.
6152 + *
6153 + * @param intno - Interrupt to enable.
6155 + * @return 0 on success.
6156 + */
6157 +int sceKernelEnableIntr(int intno);
6159 +/**
6160 + * Disable an interrupt.
6161 + *
6162 + * @param intno - Interrupt to disable.
6164 + * @return 0 on success.
6165 + */
6166 +int sceKernelDisableIntr(int intno);
6168 +/**
6169 + * Check if we are in an interrupt context or not
6171 + * @return 1 if we are in an interrupt context, else 0
6172 + */
6173 +int sceKernelIsIntrContext(void);
6175 +#ifdef __cplusplus
6177 +#endif
6179 +/**@}*/
6181 +#endif /* PSPINTRMAN_KERNEL_H */
6182 diff --git a/newlib/psp/include/pspiofilemgr.h b/newlib/psp/include/pspiofilemgr.h
6183 new file mode 100644
6184 index 0000000..95b1a37
6185 --- /dev/null
6186 +++ b/newlib/psp/include/pspiofilemgr.h
6187 @@ -0,0 +1,476 @@
6189 + * PSP Software Development Kit - https://github.com/pspdev
6190 + * -----------------------------------------------------------------------
6191 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
6193 + * pspiofilemgr.h - Prototypes for the sceIo library.
6195 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
6196 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
6197 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
6199 + */
6200 +#ifndef __FILEIO_H__
6201 +#define __FILEIO_H__
6203 +#include <pspkerneltypes.h>
6204 +#include <pspiofilemgr_fcntl.h>
6205 +#include <pspiofilemgr_stat.h>
6206 +#include <pspiofilemgr_dirent.h>
6208 +/** @defgroup FileIO File IO Library
6209 + * This module contains the imports for the kernel's IO routines.
6210 + */
6212 +#ifdef __cplusplus
6213 +extern "C" {
6214 +#endif
6216 +/** @addtogroup FileIO File IO Library */
6217 +/**@{*/
6219 +/** Permission value for the sceIoAssign function */
6220 +enum IoAssignPerms
6222 + /** Assign the device read/write */
6223 + IOASSIGN_RDWR = 0,
6224 + /** Assign the device read only */
6225 + IOASSIGN_RDONLY = 1
6228 +/**
6229 + * Open or create a file for reading or writing
6231 + * @par Example1: Open a file for reading
6232 + * @code
6233 + * if(!(fd = sceIoOpen("device:/path/to/file", O_RDONLY, 0777)) {
6234 + * // error
6235 + * }
6236 + * @endcode
6237 + * @par Example2: Open a file for writing, creating it if it doesnt exist
6238 + * @code
6239 + * if(!(fd = sceIoOpen("device:/path/to/file", O_WRONLY|O_CREAT, 0777)) {
6240 + * // error
6241 + * }
6242 + * @endcode
6244 + * @param file - Pointer to a string holding the name of the file to open
6245 + * @param flags - Libc styled flags that are or'ed together
6246 + * @param mode - File access mode.
6247 + * @return A non-negative integer is a valid fd, anything else an error
6248 + */
6249 +SceUID sceIoOpen(const char *file, int flags, SceMode mode);
6251 +/**
6252 + * Open or create a file for reading or writing (asynchronous)
6254 + * @param file - Pointer to a string holding the name of the file to open
6255 + * @param flags - Libc styled flags that are or'ed together
6256 + * @param mode - File access mode.
6257 + * @return A non-negative integer is a valid fd, anything else an error
6258 + */
6259 +SceUID sceIoOpenAsync(const char *file, int flags, SceMode mode);
6261 +/**
6262 + * Delete a descriptor
6264 + * @code
6265 + * sceIoClose(fd);
6266 + * @endcode
6268 + * @param fd - File descriptor to close
6269 + * @return < 0 on error
6270 + */
6271 +int sceIoClose(SceUID fd);
6273 +/**
6274 + * Delete a descriptor (asynchronous)
6276 + * @param fd - File descriptor to close
6277 + * @return < 0 on error
6278 + */
6279 +int sceIoCloseAsync(SceUID fd);
6281 +/**
6282 + * Read input
6284 + * @par Example:
6285 + * @code
6286 + * bytes_read = sceIoRead(fd, data, 100);
6287 + * @endcode
6289 + * @param fd - Opened file descriptor to read from
6290 + * @param data - Pointer to the buffer where the read data will be placed
6291 + * @param size - Size of the read in bytes
6292 + *
6293 + * @return The number of bytes read
6294 + */
6295 +int sceIoRead(SceUID fd, void *data, SceSize size);
6297 +/**
6298 + * Read input (asynchronous)
6300 + * @par Example:
6301 + * @code
6302 + * bytes_read = sceIoRead(fd, data, 100);
6303 + * @endcode
6305 + * @param fd - Opened file descriptor to read from
6306 + * @param data - Pointer to the buffer where the read data will be placed
6307 + * @param size - Size of the read in bytes
6308 + *
6309 + * @return < 0 on error.
6310 + */
6311 +int sceIoReadAsync(SceUID fd, void *data, SceSize size);
6313 +/**
6314 + * Write output
6316 + * @par Example:
6317 + * @code
6318 + * bytes_written = sceIoWrite(fd, data, 100);
6319 + * @endcode
6321 + * @param fd - Opened file descriptor to write to
6322 + * @param data - Pointer to the data to write
6323 + * @param size - Size of data to write
6325 + * @return The number of bytes written
6326 + */
6327 +int sceIoWrite(SceUID fd, const void *data, SceSize size);
6329 +/**
6330 + * Write output (asynchronous)
6332 + * @param fd - Opened file descriptor to write to
6333 + * @param data - Pointer to the data to write
6334 + * @param size - Size of data to write
6336 + * @return < 0 on error.
6337 + */
6338 +int sceIoWriteAsync(SceUID fd, const void *data, SceSize size);
6340 +/**
6341 + * Reposition read/write file descriptor offset
6343 + * @par Example:
6344 + * @code
6345 + * pos = sceIoLseek(fd, -10, SEEK_END);
6346 + * @endcode
6348 + * @param fd - Opened file descriptor with which to seek
6349 + * @param offset - Relative offset from the start position given by whence
6350 + * @param whence - Set to SEEK_SET to seek from the start of the file, SEEK_CUR
6351 + * seek from the current position and SEEK_END to seek from the end.
6353 + * @return The position in the file after the seek.
6354 + */
6355 +SceOff sceIoLseek(SceUID fd, SceOff offset, int whence);
6357 +/**
6358 + * Reposition read/write file descriptor offset (asynchronous)
6360 + * @param fd - Opened file descriptor with which to seek
6361 + * @param offset - Relative offset from the start position given by whence
6362 + * @param whence - Set to SEEK_SET to seek from the start of the file, SEEK_CUR
6363 + * seek from the current position and SEEK_END to seek from the end.
6365 + * @return < 0 on error. Actual value should be passed returned by the ::sceIoWaitAsync call.
6366 + */
6367 +int sceIoLseekAsync(SceUID fd, SceOff offset, int whence);
6369 +/**
6370 + * Reposition read/write file descriptor offset (32bit mode)
6372 + * @par Example:
6373 + * @code
6374 + * pos = sceIoLseek32(fd, -10, SEEK_END);
6375 + * @endcode
6377 + * @param fd - Opened file descriptor with which to seek
6378 + * @param offset - Relative offset from the start position given by whence
6379 + * @param whence - Set to SEEK_SET to seek from the start of the file, SEEK_CUR
6380 + * seek from the current position and SEEK_END to seek from the end.
6382 + * @return The position in the file after the seek.
6383 + */
6384 +int sceIoLseek32(SceUID fd, int offset, int whence);
6386 +/**
6387 + * Reposition read/write file descriptor offset (32bit mode, asynchronous)
6389 + * @param fd - Opened file descriptor with which to seek
6390 + * @param offset - Relative offset from the start position given by whence
6391 + * @param whence - Set to SEEK_SET to seek from the start of the file, SEEK_CUR
6392 + * seek from the current position and SEEK_END to seek from the end.
6394 + * @return < 0 on error.
6395 + */
6396 +int sceIoLseek32Async(SceUID fd, int offset, int whence);
6398 +/**
6399 + * Remove directory entry
6401 + * @param file - Path to the file to remove
6402 + * @return < 0 on error
6403 + */
6404 +int sceIoRemove(const char *file);
6406 +/**
6407 + * Make a directory file
6409 + * @param dir
6410 + * @param mode - Access mode.
6411 + * @return Returns the value 0 if its succesful otherwise -1
6412 + */
6413 +int sceIoMkdir(const char *dir, SceMode mode);
6415 +/**
6416 + * Remove a directory file
6418 + * @param path - Removes a directory file pointed by the string path
6419 + * @return Returns the value 0 if its succesful otherwise -1
6420 + */
6421 +int sceIoRmdir(const char *path);
6423 +/**
6424 + * Change the current directory.
6426 + * @param path - The path to change to.
6427 + * @return < 0 on error.
6428 + */
6429 +int sceIoChdir(const char *path);
6431 +/**
6432 + * Change the name of a file
6434 + * @param oldname - The old filename
6435 + * @param newname - The new filename
6436 + * @return < 0 on error.
6437 + */
6438 +int sceIoRename(const char *oldname, const char *newname);
6440 +/**
6441 + * Open a directory
6442 + *
6443 + * @par Example:
6444 + * @code
6445 + * int dfd;
6446 + * dfd = sceIoDopen("device:/");
6447 + * if(dfd >= 0)
6448 + * { Do something with the file descriptor }
6449 + * @endcode
6450 + * @param dirname - The directory to open for reading.
6451 + * @return If >= 0 then a valid file descriptor, otherwise a Sony error code.
6452 + */
6453 +SceUID sceIoDopen(const char *dirname);
6455 +/**
6456 + * Reads an entry from an opened file descriptor.
6458 + * @param fd - Already opened file descriptor (using sceIoDopen)
6459 + * @param dir - Pointer to an io_dirent_t structure to hold the file information
6461 + * @return Read status
6462 + * - 0 - No more directory entries left
6463 + * - > 0 - More directory entired to go
6464 + * - < 0 - Error
6465 + */
6466 +int sceIoDread(SceUID fd, SceIoDirent *dir);
6468 +/**
6469 + * Close an opened directory file descriptor
6471 + * @param fd - Already opened file descriptor (using sceIoDopen)
6472 + * @return < 0 on error
6473 + */
6474 +int sceIoDclose(SceUID fd);
6476 +/**
6477 + * Send a devctl command to a device.
6479 + * @par Example: Sending a simple command to a device (not a real devctl)
6480 + * @code
6481 + * sceIoDevctl("ms0:", 0x200000, indata, 4, NULL, NULL);
6482 + * @endcode
6484 + * @param dev - String for the device to send the devctl to (e.g. "ms0:")
6485 + * @param cmd - The command to send to the device
6486 + * @param indata - A data block to send to the device, if NULL sends no data
6487 + * @param inlen - Length of indata, if 0 sends no data
6488 + * @param outdata - A data block to receive the result of a command, if NULL receives no data
6489 + * @param outlen - Length of outdata, if 0 receives no data
6490 + * @return 0 on success, < 0 on error
6491 + */
6492 +int sceIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
6494 +/**
6495 + * Assigns one IO device to another (I guess)
6496 + * @param dev1 - The device name to assign.
6497 + * @param dev2 - The block device to assign from.
6498 + * @param dev3 - The filesystem device to mape the block device to dev1
6499 + * @param mode - Read/Write mode. One of IoAssignPerms.
6500 + * @param unk1 - Unknown, set to NULL.
6501 + * @param unk2 - Unknown, set to 0.
6502 + * @return < 0 on error.
6504 + * @par Example: Reassign flash0 in read/write mode.
6505 + * @code
6506 + * sceIoUnassign("flash0");
6507 + * sceIoAssign("flash0", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
6508 + * @endcode
6509 + *
6510 + */
6511 +int sceIoAssign(const char *dev1, const char *dev2, const char *dev3, int mode, void* unk1, long unk2);
6513 +/**
6514 + * Unassign an IO device.
6515 + * @param dev - The device to unassign.
6516 + * @return < 0 on error
6518 + * @par Example: See ::sceIoAssign
6519 + */
6520 +int sceIoUnassign(const char *dev);
6522 +/**
6523 + * Get the status of a file.
6524 + *
6525 + * @param file - The path to the file.
6526 + * @param stat - A pointer to an io_stat_t structure.
6527 + *
6528 + * @return < 0 on error.
6529 + */
6530 +int sceIoGetstat(const char *file, SceIoStat *stat);
6532 +/**
6533 + * Change the status of a file.
6535 + * @param file - The path to the file.
6536 + * @param stat - A pointer to an io_stat_t structure.
6537 + * @param bits - Bitmask defining which bits to change.
6539 + * @return < 0 on error.
6540 + */
6541 +int sceIoChstat(const char *file, SceIoStat *stat, int bits);
6543 +/**
6544 + * Perform an ioctl on a device.
6546 + * @param fd - Opened file descriptor to ioctl to
6547 + * @param cmd - The command to send to the device
6548 + * @param indata - A data block to send to the device, if NULL sends no data
6549 + * @param inlen - Length of indata, if 0 sends no data
6550 + * @param outdata - A data block to receive the result of a command, if NULL receives no data
6551 + * @param outlen - Length of outdata, if 0 receives no data
6552 + * @return 0 on success, < 0 on error
6553 + */
6554 +int sceIoIoctl(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
6556 +/**
6557 + * Perform an ioctl on a device. (asynchronous)
6559 + * @param fd - Opened file descriptor to ioctl to
6560 + * @param cmd - The command to send to the device
6561 + * @param indata - A data block to send to the device, if NULL sends no data
6562 + * @param inlen - Length of indata, if 0 sends no data
6563 + * @param outdata - A data block to receive the result of a command, if NULL receives no data
6564 + * @param outlen - Length of outdata, if 0 receives no data
6565 + * @return 0 on success, < 0 on error
6566 + */
6567 +int sceIoIoctlAsync(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
6569 +/**
6570 + * Synchronise the file data on the device.
6572 + * @param device - The device to synchronise (e.g. msfat0:)
6573 + * @param unk - Unknown
6574 + */
6575 +int sceIoSync(const char *device, unsigned int unk);
6577 +/**
6578 + * Wait for asyncronous completion.
6579 + *
6580 + * @param fd - The file descriptor which is current performing an asynchronous action.
6581 + * @param res - The result of the async action.
6583 + * @return < 0 on error.
6584 + */
6585 +int sceIoWaitAsync(SceUID fd, SceInt64 *res);
6587 +/**
6588 + * Wait for asyncronous completion (with callbacks).
6589 + *
6590 + * @param fd - The file descriptor which is current performing an asynchronous action.
6591 + * @param res - The result of the async action.
6593 + * @return < 0 on error.
6594 + */
6595 +int sceIoWaitAsyncCB(SceUID fd, SceInt64 *res);
6597 +/**
6598 + * Poll for asyncronous completion.
6599 + *
6600 + * @param fd - The file descriptor which is current performing an asynchronous action.
6601 + * @param res - The result of the async action.
6603 + * @return < 0 on error.
6604 + */
6605 +int sceIoPollAsync(SceUID fd, SceInt64 *res);
6607 +/**
6608 + * Get the asyncronous completion status.
6609 + *
6610 + * @param fd - The file descriptor which is current performing an asynchronous action.
6611 + * @param poll - If 0 then waits for the status, otherwise it polls the fd.
6612 + * @param res - The result of the async action.
6614 + * @return < 0 on error.
6615 + */
6616 +int sceIoGetAsyncStat(SceUID fd, int poll, SceInt64 *res);
6618 +/**
6619 + * Cancel an asynchronous operation on a file descriptor.
6621 + * @param fd - The file descriptor to perform cancel on.
6623 + * @return < 0 on error.
6624 + */
6625 +int sceIoCancel(SceUID fd);
6627 +/**
6628 + * Get the device type of the currently opened file descriptor.
6630 + * @param fd - The opened file descriptor.
6632 + * @return < 0 on error. Otherwise the device type?
6633 + */
6634 +int sceIoGetDevType(SceUID fd);
6636 +/**
6637 + * Change the priority of the asynchronous thread.
6639 + * @param fd - The opened fd on which the priority should be changed.
6640 + * @param pri - The priority of the thread.
6642 + * @return < 0 on error.
6643 + */
6644 +int sceIoChangeAsyncPriority(SceUID fd, int pri);
6646 +/**
6647 + * Sets a callback for the asynchronous action.
6649 + * @param fd - The filedescriptor currently performing an asynchronous action.
6650 + * @param cb - The UID of the callback created with ::sceKernelCreateCallback
6651 + * @param argp - Pointer to an argument to pass to the callback.
6653 + * @return < 0 on error.
6654 + */
6655 +int sceIoSetAsyncCallback(SceUID fd, SceUID cb, void *argp);
6657 +/**@}*/
6659 +#ifdef __cplusplus
6661 +#endif
6663 +#endif
6664 diff --git a/newlib/psp/include/pspiofilemgr_dirent.h b/newlib/psp/include/pspiofilemgr_dirent.h
6665 new file mode 100644
6666 index 0000000..f1f9339
6667 --- /dev/null
6668 +++ b/newlib/psp/include/pspiofilemgr_dirent.h
6669 @@ -0,0 +1,34 @@
6671 + * PSP Software Development Kit - https://github.com/pspdev
6672 + * -----------------------------------------------------------------------
6673 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
6675 + * pspiofilemgr_dirent.h - File attributes and directory entries.
6677 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
6678 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
6679 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
6681 + */
6683 +/* Note: Some of the structures, types, and definitions in this file were
6684 + extrapolated from symbolic debugging information found in the Japanese
6685 + version of Puzzle Bobble. */
6687 +#ifndef PSPIOFILEMGR_DIRENT_H
6688 +#define PSPIOFILEMGR_DIRENT_H
6690 +#include <pspiofilemgr_stat.h>
6692 +/** Describes a single directory entry */
6693 +typedef struct SceIoDirent {
6694 + /** File status. */
6695 + SceIoStat d_stat;
6696 + /** File name. */
6697 + char d_name[256];
6698 + /** Device-specific data. */
6699 + void * d_private;
6700 + int dummy;
6701 +} SceIoDirent;
6703 +#endif /* PSPIOFILEMGR_DIRENT_H */
6704 diff --git a/newlib/psp/include/pspiofilemgr_fcntl.h b/newlib/psp/include/pspiofilemgr_fcntl.h
6705 new file mode 100644
6706 index 0000000..f729f37
6707 --- /dev/null
6708 +++ b/newlib/psp/include/pspiofilemgr_fcntl.h
6709 @@ -0,0 +1,33 @@
6711 + * PSP Software Development Kit - https://github.com/pspdev
6712 + * -----------------------------------------------------------------------
6713 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
6715 + * pspiofilemgr_fcntl.h - File control definitions.
6717 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
6718 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
6719 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
6721 + */
6722 +#ifndef PSPIOFILEMGR_FCNTL_H
6723 +#define PSPIOFILEMGR_FCNTL_H
6725 +/* Note: Not all of these sceIoOpen() flags are not compatible with the
6726 + open() flags found in sys/unistd.h. */
6727 +#define PSP_O_RDONLY 0x0001
6728 +#define PSP_O_WRONLY 0x0002
6729 +#define PSP_O_RDWR (PSP_O_RDONLY | PSP_O_WRONLY)
6730 +#define PSP_O_NBLOCK 0x0004
6731 +#define PSP_O_DIR 0x0008
6732 +#define PSP_O_APPEND 0x0100
6733 +#define PSP_O_CREAT 0x0200
6734 +#define PSP_O_TRUNC 0x0400
6735 +#define PSP_O_EXCL 0x0800
6736 +#define PSP_O_NOWAIT 0x8000
6738 +#define PSP_SEEK_SET 0
6739 +#define PSP_SEEK_CUR 1
6740 +#define PSP_SEEK_END 2
6742 +#endif /* PSPIOFILEMGR_FCNTL_H */
6743 diff --git a/newlib/psp/include/pspiofilemgr_kernel.h b/newlib/psp/include/pspiofilemgr_kernel.h
6744 new file mode 100644
6745 index 0000000..f7e564c
6746 --- /dev/null
6747 +++ b/newlib/psp/include/pspiofilemgr_kernel.h
6748 @@ -0,0 +1,165 @@
6750 + * PSP Software Development Kit - https://github.com/pspdev
6751 + * -----------------------------------------------------------------------
6752 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
6754 + * pspiofilemgr_kernel.h - Interface to the kernel mode library for IoFileMgr.
6756 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
6757 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
6758 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
6760 + */
6762 +#ifndef PSPIOFILEMGR_KERNEL_H
6763 +#define PSPIOFILEMGR_KERNEL_H
6765 +#include <psptypes.h>
6766 +#include <pspkerneltypes.h>
6767 +#include <pspiofilemgr.h>
6769 +/** @defgroup IoFileMgr_Kernel Driver interface to IoFileMgr
6770 + * This module contains the imports for the kernel's IO routines.
6771 + */
6773 +#ifdef __cplusplus
6774 +extern "C" {
6775 +#endif
6777 +/** @addtogroup IoFileMgr_Kernel Driver interface to IoFileMgr */
6778 +/**@{*/
6780 +struct PspIoDrv;
6782 +/** Structure passed to the init and exit functions of the io driver system */
6783 +typedef struct PspIoDrvArg
6785 + /** Pointer to the original driver which was added */
6786 + struct PspIoDrv *drv;
6787 + /** Pointer to a user defined argument (if written by the driver will preseve across calls */
6788 + void *arg;
6789 +} PspIoDrvArg;
6791 +/** Structure passed to the file functions of the io driver system */
6792 +typedef struct PspIoDrvFileArg
6794 + /** Unknown */
6795 + u32 unk1;
6796 + /** The file system number, e.g. if a file is opened as host5:/myfile.txt this field will be 5 */
6797 + u32 fs_num;
6798 + /** Pointer to the driver structure */
6799 + PspIoDrvArg *drv;
6800 + /** Unknown, again */
6801 + u32 unk2;
6802 + /** Pointer to a user defined argument, this is preserved on a per file basis */
6803 + void *arg;
6804 +} PspIoDrvFileArg;
6806 +/** Structure to maintain the file driver pointers */
6807 +typedef struct PspIoDrvFuncs
6809 + int (*IoInit)(PspIoDrvArg* arg);
6810 + int (*IoExit)(PspIoDrvArg* arg);
6811 + int (*IoOpen)(PspIoDrvFileArg *arg, char *file, int flags, SceMode mode);
6812 + int (*IoClose)(PspIoDrvFileArg *arg);
6813 + int (*IoRead)(PspIoDrvFileArg *arg, char *data, int len);
6814 + int (*IoWrite)(PspIoDrvFileArg *arg, const char *data, int len);
6815 + SceOff (*IoLseek)(PspIoDrvFileArg *arg, SceOff ofs, int whence);
6816 + int (*IoIoctl)(PspIoDrvFileArg *arg, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
6817 + int (*IoRemove)(PspIoDrvFileArg *arg, const char *name);
6818 + int (*IoMkdir)(PspIoDrvFileArg *arg, const char *name, SceMode mode);
6819 + int (*IoRmdir)(PspIoDrvFileArg *arg, const char *name);
6820 + int (*IoDopen)(PspIoDrvFileArg *arg, const char *dirname);
6821 + int (*IoDclose)(PspIoDrvFileArg *arg);
6822 + int (*IoDread)(PspIoDrvFileArg *arg, SceIoDirent *dir);
6823 + int (*IoGetstat)(PspIoDrvFileArg *arg, const char *file, SceIoStat *stat);
6824 + int (*IoChstat)(PspIoDrvFileArg *arg, const char *file, SceIoStat *stat, int bits);
6825 + int (*IoRename)(PspIoDrvFileArg *arg, const char *oldname, const char *newname);
6826 + int (*IoChdir)(PspIoDrvFileArg *arg, const char *dir);
6827 + int (*IoMount)(PspIoDrvFileArg *arg);
6828 + int (*IoUmount)(PspIoDrvFileArg *arg);
6829 + int (*IoDevctl)(PspIoDrvFileArg *arg, const char *devname, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
6830 + int (*IoUnk21)(PspIoDrvFileArg *arg);
6831 +} PspIoDrvFuncs;
6833 +typedef struct PspIoDrv
6835 + /** The name of the device to add */
6836 + const char *name;
6837 + /** Device type, this 0x10 is for a filesystem driver */
6838 + u32 dev_type;
6839 + /** Unknown, set to 0x800 */
6840 + u32 unk2;
6841 + /** This seems to be the same as name but capitalised :/ */
6842 + const char *name2;
6843 + /** Pointer to a filled out functions table */
6844 + PspIoDrvFuncs *funcs;
6845 +} PspIoDrv;
6847 +/**
6848 + * Adds a new IO driver to the system.
6849 + * @note This is only exported in the kernel version of IoFileMgr
6850 + *
6851 + * @param drv - Pointer to a filled out driver structure
6852 + * @return < 0 on error.
6854 + * @par Example:
6855 + * @code
6856 + * PspIoDrvFuncs host_funcs = { ... };
6857 + * PspIoDrv host_driver = { "host", 0x10, 0x800, "HOST", &host_funcs };
6858 + * sceIoDelDrv("host");
6859 + * sceIoAddDrv(&host_driver);
6860 + * @endcode
6861 + */
6862 +int sceIoAddDrv(PspIoDrv *drv);
6864 +/**
6865 + * Deletes a IO driver from the system.
6866 + * @note This is only exported in the kernel version of IoFileMgr
6868 + * @param drv_name - Name of the driver to delete.
6869 + * @return < 0 on error
6870 + */
6871 +int sceIoDelDrv(const char *drv_name);
6873 +/**
6874 + * Reopens an existing file descriptor.
6876 + * @param file - The new file to open.
6877 + * @param flags - The open flags.
6878 + * @param mode - The open mode.
6879 + * @param fd - The old filedescriptor to reopen
6881 + * @return < 0 on error, otherwise the reopened fd.
6882 + */
6883 +int sceIoReopen(const char *file, int flags, SceMode mode, SceUID fd);
6885 +/**
6886 + * Get the current working directory for a thread.
6888 + * @param uid - The UID of the thread
6889 + * @param dir - A character buffer in which to store the cwd
6890 + * @param len - The length of the buffer
6892 + * @return Number of characters written to buf, if no cwd then 0 is
6893 + * returned.
6894 + */
6895 +int sceIoGetThreadCwd(SceUID uid, char *dir, int len);
6897 +/**
6898 + * Set the current working directory for a thread
6900 + * @param uid - The UID of the thread
6901 + * @param dir - The directory to set
6903 + * @return 0 on success, < 0 on error
6904 + */
6905 +int sceIoChangeThreadCwd(SceUID uid, char *dir);
6907 +/**@}*/
6909 +#ifdef __cplusplus
6911 +#endif
6913 +#endif /* PSPIOFILEMGR_KERNEL_H */
6914 diff --git a/newlib/psp/include/pspiofilemgr_stat.h b/newlib/psp/include/pspiofilemgr_stat.h
6915 new file mode 100644
6916 index 0000000..738917a
6917 --- /dev/null
6918 +++ b/newlib/psp/include/pspiofilemgr_stat.h
6919 @@ -0,0 +1,117 @@
6921 + * PSP Software Development Kit - https://github.com/pspdev
6922 + * -----------------------------------------------------------------------
6923 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
6925 + * pspiofilemgr_dirent.h - File attributes and directory entries.
6927 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
6928 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
6929 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
6931 + */
6933 +/* Note: Some of the structures, types, and definitions in this file were
6934 + extrapolated from symbolic debugging information found in the Japanese
6935 + version of Puzzle Bobble. */
6937 +#ifndef PSPIOFILEMGR_STAT_H
6938 +#define PSPIOFILEMGR_STAT_H
6940 +#include <psptypes.h>
6941 +#include <pspkerneltypes.h>
6943 +/** Access modes for st_mode in SceIoStat (confirm?). */
6944 +enum IOAccessModes
6946 + /** Format bits mask */
6947 + FIO_S_IFMT = 0xF000,
6948 + /** Symbolic link */
6949 + FIO_S_IFLNK = 0x4000,
6950 + /** Directory */
6951 + FIO_S_IFDIR = 0x1000,
6952 + /** Regular file */
6953 + FIO_S_IFREG = 0x2000,
6955 + /** Set UID */
6956 + FIO_S_ISUID = 0x0800,
6957 + /** Set GID */
6958 + FIO_S_ISGID = 0x0400,
6959 + /** Sticky */
6960 + FIO_S_ISVTX = 0x0200,
6962 + /** User access rights mask */
6963 + FIO_S_IRWXU = 0x01C0,
6964 + /** Read user permission */
6965 + FIO_S_IRUSR = 0x0100,
6966 + /** Write user permission */
6967 + FIO_S_IWUSR = 0x0080,
6968 + /** Execute user permission */
6969 + FIO_S_IXUSR = 0x0040,
6971 + /** Group access rights mask */
6972 + FIO_S_IRWXG = 0x0038,
6973 + /** Group read permission */
6974 + FIO_S_IRGRP = 0x0020,
6975 + /** Group write permission */
6976 + FIO_S_IWGRP = 0x0010,
6977 + /** Group execute permission */
6978 + FIO_S_IXGRP = 0x0008,
6980 + /** Others access rights mask */
6981 + FIO_S_IRWXO = 0x0007,
6982 + /** Others read permission */
6983 + FIO_S_IROTH = 0x0004,
6984 + /** Others write permission */
6985 + FIO_S_IWOTH = 0x0002,
6986 + /** Others execute permission */
6987 + FIO_S_IXOTH = 0x0001,
6990 +// File mode checking macros
6991 +#define FIO_S_ISLNK(m) (((m) & FIO_S_IFMT) == FIO_S_IFLNK)
6992 +#define FIO_S_ISREG(m) (((m) & FIO_S_IFMT) == FIO_S_IFREG)
6993 +#define FIO_S_ISDIR(m) (((m) & FIO_S_IFMT) == FIO_S_IFDIR)
6995 +/** File modes, used for the st_attr parameter in SceIoStat (confirm?). */
6996 +enum IOFileModes
6998 + /** Format mask */
6999 + FIO_SO_IFMT = 0x0038, // Format mask
7000 + /** Symlink */
7001 + FIO_SO_IFLNK = 0x0008, // Symbolic link
7002 + /** Directory */
7003 + FIO_SO_IFDIR = 0x0010, // Directory
7004 + /** Regular file */
7005 + FIO_SO_IFREG = 0x0020, // Regular file
7007 + /** Hidden read permission */
7008 + FIO_SO_IROTH = 0x0004, // read
7009 + /** Hidden write permission */
7010 + FIO_SO_IWOTH = 0x0002, // write
7011 + /** Hidden execute permission */
7012 + FIO_SO_IXOTH = 0x0001, // execute
7015 +// File mode checking macros
7016 +#define FIO_SO_ISLNK(m) (((m) & FIO_SO_IFMT) == FIO_SO_IFLNK)
7017 +#define FIO_SO_ISREG(m) (((m) & FIO_SO_IFMT) == FIO_SO_IFREG)
7018 +#define FIO_SO_ISDIR(m) (((m) & FIO_SO_IFMT) == FIO_SO_IFDIR)
7020 +/** Structure to hold the status information about a file */
7021 +typedef struct SceIoStat {
7022 + SceMode st_mode;
7023 + unsigned int st_attr;
7024 + /** Size of the file in bytes. */
7025 + SceOff st_size;
7026 + /** Creation time. */
7027 + ScePspDateTime sce_st_ctime;
7028 + /** Access time. */
7029 + ScePspDateTime sce_st_atime;
7030 + /** Modification time. */
7031 + ScePspDateTime sce_st_mtime;
7032 + /** Device-specific data. */
7033 + unsigned int st_private[6];
7034 +} SceIoStat;
7036 +#endif /* PSPIOFILEMGR_STAT_H */
7037 diff --git a/newlib/psp/include/pspjpeg.h b/newlib/psp/include/pspjpeg.h
7038 new file mode 100644
7039 index 0000000..614add4
7040 --- /dev/null
7041 +++ b/newlib/psp/include/pspjpeg.h
7042 @@ -0,0 +1,68 @@
7044 + * PSP Software Development Kit - https://github.com/pspdev
7045 + * -----------------------------------------------------------------------
7046 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7048 + * pspjpeg.h - Prototypes for the sceJpeg library
7050 + * Copyright (c) 2007 dot_blank
7052 + */
7053 +#ifndef __PSPJPEG_H__
7054 +#define __PSPJPEG_H__
7056 +#ifdef __cplusplus
7057 +extern "C" {
7058 +#endif
7060 +#include <psptypes.h>
7062 +/**
7063 + * Inits the MJpeg library
7065 + * @return 0 on success, < 0 on error
7067 +int sceJpegInitMJpeg(void);
7069 +/**
7070 + * Finishes the MJpeg library
7072 + * @return 0 on success, < 0 on error
7074 +int sceJpegFinishMJpeg(void);
7076 +/**
7077 + * Creates the decoder context.
7079 + * @param width - The width of the frame
7080 + * @param height - The height of the frame
7082 + * @return 0 on success, < 0 on error
7084 +int sceJpegCreateMJpeg(int width, int height);
7086 +/**
7087 + * Deletes the current decoder context.
7089 + * @return 0 on success, < 0 on error
7091 +int sceJpegDeleteMJpeg(void);
7093 +/**
7094 + * Decodes a mjpeg frame.
7096 + * @param jpegbuf - the buffer with the mjpeg frame
7097 + * @param size - size of the buffer pointed by jpegbuf
7098 + * @param rgba - buffer where the decoded data in RGBA format will be stored.
7099 + * It should have a size of (width * height * 4).
7100 + * @param unk - Unknown, pass 0
7102 + * @return (width * 65536) + height on success, < 0 on error
7104 +int sceJpegDecodeMJpeg(u8 *jpegbuf, SceSize size, void *rgba, u32 unk);
7106 +#ifdef __cplusplus
7108 +#endif
7110 +#endif
7111 diff --git a/newlib/psp/include/pspkdebug.h b/newlib/psp/include/pspkdebug.h
7112 new file mode 100644
7113 index 0000000..af97e03
7114 --- /dev/null
7115 +++ b/newlib/psp/include/pspkdebug.h
7116 @@ -0,0 +1,58 @@
7118 + * PSP Software Development Kit - https://github.com/pspdev
7119 + * -----------------------------------------------------------------------
7120 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7122 + * pspkdebug.h - Interface to KDebugForKernel.
7124 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7126 + */
7128 +#ifndef PSPKDEBUG_H
7129 +#define PSPKDEBUG_H
7131 +#include <pspkerneltypes.h>
7133 +/** @defgroup Kdebug Interface to the KDebugForKernel library.
7134 + */
7136 +#ifdef __cplusplus
7137 +extern "C" {
7138 +#endif
7140 +/** @addtogroup Kdebug Interface to the KDebugForKernel library. */
7141 +/**@{*/
7143 +/** Typedef for the debug putcharacter handler */
7144 +typedef void (*PspDebugPutChar)(unsigned short* args, unsigned int ch);
7146 +/**
7147 + * Register a debug put character handler
7149 + * @param func - The put character function to register.
7150 + */
7151 +void sceKernelRegisterDebugPutchar(PspDebugPutChar func);
7153 +/**
7154 + * Get the debug put character handler
7156 + * @return The current debug putchar handler
7157 + */
7158 +PspDebugPutChar sceKernelGetDebugPutchar(void);
7160 +/**
7161 + * Kernel printf function.
7163 + * @param format - The format string.
7164 + * @param ... - Arguments for the format string.
7165 + */
7166 +void Kprintf(const char *format, ...) __attribute__((format(printf, 1, 2)));
7168 +/**@}*/
7170 +#ifdef __cplusplus
7172 +#endif
7174 +#endif
7175 diff --git a/newlib/psp/include/pspkernel.h b/newlib/psp/include/pspkernel.h
7176 new file mode 100644
7177 index 0000000..3db1c54
7178 --- /dev/null
7179 +++ b/newlib/psp/include/pspkernel.h
7180 @@ -0,0 +1,71 @@
7182 + * PSP Software Development Kit - https://github.com/pspdev
7183 + * -----------------------------------------------------------------------
7184 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7186 + * pspkernel.h - Main include file that includes all major kernel headers.
7188 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7189 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7190 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7192 + */
7194 +#ifndef PSPKERNEL_H
7195 +#define PSPKERNEL_H
7197 +#include <pspuser.h>
7198 +#include <pspiofilemgr_kernel.h>
7199 +#include <psploadcore.h>
7200 +#include <pspstdio_kernel.h>
7201 +#include <pspsysreg.h>
7202 +#include <pspkdebug.h>
7203 +#include <pspintrman_kernel.h>
7204 +#include <pspmodulemgr_kernel.h>
7206 +#ifdef __cplusplus
7207 +extern "C" {
7208 +#endif
7210 +/**
7211 + * Set the $pc register to a kernel memory address.
7213 + * When the PSP's kernel library stubs are called, they expect to be accessed
7214 + * from the kernel's address space. Use this function to set $pc to the kernel
7215 + * address space, before calling a kernel library stub.
7216 + */
7217 +#define pspKernelSetKernelPC() \
7218 +{ \
7219 + __asm__ volatile ( \
7220 + "la $8, 1f\n\t" \
7221 + "lui $9, 0x8000\n\t" \
7222 + "or $8, $9\n\t" \
7223 + "jr $8\n\t" \
7224 + " nop\n\t" \
7225 + "1:\n\t" \
7226 + : : : "$8", "$9"); \
7227 + sceKernelIcacheClearAll(); \
7230 +/**
7231 + * Set the $pc register to a user memory address.
7233 + */
7234 +#define pspKernelSetUserPC() \
7235 +{ \
7236 + __asm__ volatile ( \
7237 + "la $8, 1f\n\t" \
7238 + "li $9, 0x7FFFFFFF\n\t" \
7239 + "and $8, $9\n\t" \
7240 + "jr $8\n\t" \
7241 + " nop\n\t" \
7242 + "1:\n\t" \
7243 + : : : "$8", "$9"); \
7244 + sceKernelIcacheClearAll(); \
7247 +#ifdef __cplusplus
7249 +#endif
7251 +#endif /* PSPKERNEL_H */
7252 diff --git a/newlib/psp/include/pspkerneltypes.h b/newlib/psp/include/pspkerneltypes.h
7253 new file mode 100644
7254 index 0000000..16516ba
7255 --- /dev/null
7256 +++ b/newlib/psp/include/pspkerneltypes.h
7257 @@ -0,0 +1,38 @@
7259 + * PSP Software Development Kit - https://github.com/pspdev
7260 + * -----------------------------------------------------------------------
7261 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7263 + * pspkerneltypes.h - PSP kernel types and definitions.
7265 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7266 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7267 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7269 + */
7271 +/* Note: Some of the structures, types, and definitions in this file were
7272 + extrapolated from symbolic debugging information found in the Japanese
7273 + version of Puzzle Bobble. */
7275 +#ifndef PSPKERNELTYPES_H
7276 +#define PSPKERNELTYPES_H
7278 +#include <psptypes.h>
7280 +/** UIDs are used to describe many different kernel objects. */
7281 +typedef int SceUID;
7283 +/* Misc. kernel types. */
7284 +typedef unsigned int SceSize;
7285 +typedef int SceSSize;
7287 +typedef unsigned char SceUChar;
7288 +typedef unsigned int SceUInt;
7290 +/* File I/O types. */
7291 +typedef int SceMode;
7292 +typedef SceInt64 SceOff;
7293 +typedef SceInt64 SceIores;
7295 +#endif /* PSPKERNELTYPES_H */
7296 diff --git a/newlib/psp/include/pspkerror.h b/newlib/psp/include/pspkerror.h
7297 new file mode 100644
7298 index 0000000..ec43e45
7299 --- /dev/null
7300 +++ b/newlib/psp/include/pspkerror.h
7301 @@ -0,0 +1,220 @@
7303 + * PSP Software Development Kit - https://github.com/pspdev
7304 + * -----------------------------------------------------------------------
7305 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7307 + * pspkerror.h - Definitions for the kernel error codes
7309 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7310 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7311 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7313 + */
7314 +#ifndef PSPKERROR_H
7315 +#define PSPKERROR_H
7317 +/* Note: The error code enumerations in this file were extrapolated from
7318 + symbolic debugging information found in the Japanese version of Puzzle Bobble. */
7320 +enum PspKernelErrorCodes
7322 + SCE_KERNEL_ERROR_OK = 0,
7323 + SCE_KERNEL_ERROR_ERROR = 0x80020001,
7324 + SCE_KERNEL_ERROR_NOTIMP = 0x80020002,
7325 + SCE_KERNEL_ERROR_ILLEGAL_EXPCODE = 0x80020032,
7326 + SCE_KERNEL_ERROR_EXPHANDLER_NOUSE = 0x80020033,
7327 + SCE_KERNEL_ERROR_EXPHANDLER_USED = 0x80020034,
7328 + SCE_KERNEL_ERROR_SYCALLTABLE_NOUSED = 0x80020035,
7329 + SCE_KERNEL_ERROR_SYCALLTABLE_USED = 0x80020036,
7330 + SCE_KERNEL_ERROR_ILLEGAL_SYSCALLTABLE = 0x80020037,
7331 + SCE_KERNEL_ERROR_ILLEGAL_PRIMARY_SYSCALL_NUMBER = 0x80020038,
7332 + SCE_KERNEL_ERROR_PRIMARY_SYSCALL_NUMBER_INUSE = 0x80020039,
7333 + SCE_KERNEL_ERROR_ILLEGAL_CONTEXT = 0x80020064,
7334 + SCE_KERNEL_ERROR_ILLEGAL_INTRCODE = 0x80020065,
7335 + SCE_KERNEL_ERROR_CPUDI = 0x80020066,
7336 + SCE_KERNEL_ERROR_FOUND_HANDLER = 0x80020067,
7337 + SCE_KERNEL_ERROR_NOTFOUND_HANDLER = 0x80020068,
7338 + SCE_KERNEL_ERROR_ILLEGAL_INTRLEVEL = 0x80020069,
7339 + SCE_KERNEL_ERROR_ILLEGAL_ADDRESS = 0x8002006a,
7340 + SCE_KERNEL_ERROR_ILLEGAL_INTRPARAM = 0x8002006b,
7341 + SCE_KERNEL_ERROR_ILLEGAL_STACK_ADDRESS = 0x8002006c,
7342 + SCE_KERNEL_ERROR_ALREADY_STACK_SET = 0x8002006d,
7343 + SCE_KERNEL_ERROR_NO_TIMER = 0x80020096,
7344 + SCE_KERNEL_ERROR_ILLEGAL_TIMERID = 0x80020097,
7345 + SCE_KERNEL_ERROR_ILLEGAL_SOURCE = 0x80020098,
7346 + SCE_KERNEL_ERROR_ILLEGAL_PRESCALE = 0x80020099,
7347 + SCE_KERNEL_ERROR_TIMER_BUSY = 0x8002009a,
7348 + SCE_KERNEL_ERROR_TIMER_NOT_SETUP = 0x8002009b,
7349 + SCE_KERNEL_ERROR_TIMER_NOT_INUSE = 0x8002009c,
7350 + SCE_KERNEL_ERROR_UNIT_USED = 0x800200a0,
7351 + SCE_KERNEL_ERROR_UNIT_NOUSE = 0x800200a1,
7352 + SCE_KERNEL_ERROR_NO_ROMDIR = 0x800200a2,
7353 + SCE_KERNEL_ERROR_IDTYPE_EXIST = 0x800200c8,
7354 + SCE_KERNEL_ERROR_IDTYPE_NOT_EXIST = 0x800200c9,
7355 + SCE_KERNEL_ERROR_IDTYPE_NOT_EMPTY = 0x800200ca,
7356 + SCE_KERNEL_ERROR_UNKNOWN_UID = 0x800200cb,
7357 + SCE_KERNEL_ERROR_UNMATCH_UID_TYPE = 0x800200cc,
7358 + SCE_KERNEL_ERROR_ID_NOT_EXIST = 0x800200cd,
7359 + SCE_KERNEL_ERROR_NOT_FOUND_UIDFUNC = 0x800200ce,
7360 + SCE_KERNEL_ERROR_UID_ALREADY_HOLDER = 0x800200cf,
7361 + SCE_KERNEL_ERROR_UID_NOT_HOLDER = 0x800200d0,
7362 + SCE_KERNEL_ERROR_ILLEGAL_PERM = 0x800200d1,
7363 + SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT = 0x800200d2,
7364 + SCE_KERNEL_ERROR_ILLEGAL_ADDR = 0x800200d3,
7365 + SCE_KERNEL_ERROR_OUT_OF_RANGE = 0x800200d4,
7366 + SCE_KERNEL_ERROR_MEM_RANGE_OVERLAP = 0x800200d5,
7367 + SCE_KERNEL_ERROR_ILLEGAL_PARTITION = 0x800200d6,
7368 + SCE_KERNEL_ERROR_PARTITION_INUSE = 0x800200d7,
7369 + SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE = 0x800200d8,
7370 + SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED = 0x800200d9,
7371 + SCE_KERNEL_ERROR_MEMBLOCK_RESIZE_LOCKED = 0x800200da,
7372 + SCE_KERNEL_ERROR_MEMBLOCK_RESIZE_FAILED = 0x800200db,
7373 + SCE_KERNEL_ERROR_HEAPBLOCK_ALLOC_FAILED = 0x800200dc,
7374 + SCE_KERNEL_ERROR_HEAP_ALLOC_FAILED = 0x800200dd,
7375 + SCE_KERNEL_ERROR_ILLEGAL_CHUNK_ID = 0x800200de,
7376 + SCE_KERNEL_ERROR_NOCHUNK = 0x800200df,
7377 + SCE_KERNEL_ERROR_NO_FREECHUNK = 0x800200e0,
7378 + SCE_KERNEL_ERROR_LINKERR = 0x8002012c,
7379 + SCE_KERNEL_ERROR_ILLEGAL_OBJECT = 0x8002012d,
7380 + SCE_KERNEL_ERROR_UNKNOWN_MODULE = 0x8002012e,
7381 + SCE_KERNEL_ERROR_NOFILE = 0x8002012f,
7382 + SCE_KERNEL_ERROR_FILEERR = 0x80020130,
7383 + SCE_KERNEL_ERROR_MEMINUSE = 0x80020131,
7384 + SCE_KERNEL_ERROR_PARTITION_MISMATCH = 0x80020132,
7385 + SCE_KERNEL_ERROR_ALREADY_STARTED = 0x80020133,
7386 + SCE_KERNEL_ERROR_NOT_STARTED = 0x80020134,
7387 + SCE_KERNEL_ERROR_ALREADY_STOPPED = 0x80020135,
7388 + SCE_KERNEL_ERROR_CAN_NOT_STOP = 0x80020136,
7389 + SCE_KERNEL_ERROR_NOT_STOPPED = 0x80020137,
7390 + SCE_KERNEL_ERROR_NOT_REMOVABLE = 0x80020138,
7391 + SCE_KERNEL_ERROR_EXCLUSIVE_LOAD = 0x80020139,
7392 + SCE_KERNEL_ERROR_LIBRARY_NOT_YET_LINKED = 0x8002013a,
7393 + SCE_KERNEL_ERROR_LIBRARY_FOUND = 0x8002013b,
7394 + SCE_KERNEL_ERROR_LIBRARY_NOTFOUND = 0x8002013c,
7395 + SCE_KERNEL_ERROR_ILLEGAL_LIBRARY = 0x8002013d,
7396 + SCE_KERNEL_ERROR_LIBRARY_INUSE = 0x8002013e,
7397 + SCE_KERNEL_ERROR_ALREADY_STOPPING = 0x8002013f,
7398 + SCE_KERNEL_ERROR_ILLEGAL_OFFSET = 0x80020140,
7399 + SCE_KERNEL_ERROR_ILLEGAL_POSITION = 0x80020141,
7400 + SCE_KERNEL_ERROR_ILLEGAL_ACCESS = 0x80020142,
7401 + SCE_KERNEL_ERROR_MODULE_MGR_BUSY = 0x80020143,
7402 + SCE_KERNEL_ERROR_ILLEGAL_FLAG = 0x80020144,
7403 + SCE_KERNEL_ERROR_CANNOT_GET_MODULELIST = 0x80020145,
7404 + SCE_KERNEL_ERROR_PROHIBIT_LOADMODULE_DEVICE = 0x80020146,
7405 + SCE_KERNEL_ERROR_PROHIBIT_LOADEXEC_DEVICE = 0x80020147,
7406 + SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE = 0x80020148,
7407 + SCE_KERNEL_ERROR_ILLEGAL_PERM_CALL = 0x80020149,
7408 + SCE_KERNEL_ERROR_CANNOT_GET_MODULE_INFORMATION = 0x8002014a,
7409 + SCE_KERNEL_ERROR_ILLEGAL_LOADEXEC_BUFFER = 0x8002014b,
7410 + SCE_KERNEL_ERROR_ILLEGAL_LOADEXEC_FILENAME = 0x8002014c,
7411 + SCE_KERNEL_ERROR_NO_EXIT_CALLBACK = 0x8002014d,
7412 + SCE_KERNEL_ERROR_NO_MEMORY = 0x80020190,
7413 + SCE_KERNEL_ERROR_ILLEGAL_ATTR = 0x80020191,
7414 + SCE_KERNEL_ERROR_ILLEGAL_ENTRY = 0x80020192,
7415 + SCE_KERNEL_ERROR_ILLEGAL_PRIORITY = 0x80020193,
7416 + SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE = 0x80020194,
7417 + SCE_KERNEL_ERROR_ILLEGAL_MODE = 0x80020195,
7418 + SCE_KERNEL_ERROR_ILLEGAL_MASK = 0x80020196,
7419 + SCE_KERNEL_ERROR_ILLEGAL_THID = 0x80020197,
7420 + SCE_KERNEL_ERROR_UNKNOWN_THID = 0x80020198,
7421 + SCE_KERNEL_ERROR_UNKNOWN_SEMID = 0x80020199,
7422 + SCE_KERNEL_ERROR_UNKNOWN_EVFID = 0x8002019a,
7423 + SCE_KERNEL_ERROR_UNKNOWN_MBXID = 0x8002019b,
7424 + SCE_KERNEL_ERROR_UNKNOWN_VPLID = 0x8002019c,
7425 + SCE_KERNEL_ERROR_UNKNOWN_FPLID = 0x8002019d,
7426 + SCE_KERNEL_ERROR_UNKNOWN_MPPID = 0x8002019e,
7427 + SCE_KERNEL_ERROR_UNKNOWN_ALMID = 0x8002019f,
7428 + SCE_KERNEL_ERROR_UNKNOWN_TEID = 0x800201a0,
7429 + SCE_KERNEL_ERROR_UNKNOWN_CBID = 0x800201a1,
7430 + SCE_KERNEL_ERROR_DORMANT = 0x800201a2,
7431 + SCE_KERNEL_ERROR_SUSPEND = 0x800201a3,
7432 + SCE_KERNEL_ERROR_NOT_DORMANT = 0x800201a4,
7433 + SCE_KERNEL_ERROR_NOT_SUSPEND = 0x800201a5,
7434 + SCE_KERNEL_ERROR_NOT_WAIT = 0x800201a6,
7435 + SCE_KERNEL_ERROR_CAN_NOT_WAIT = 0x800201a7,
7436 + SCE_KERNEL_ERROR_WAIT_TIMEOUT = 0x800201a8,
7437 + SCE_KERNEL_ERROR_WAIT_CANCEL = 0x800201a9,
7438 + SCE_KERNEL_ERROR_RELEASE_WAIT = 0x800201aa,
7439 + SCE_KERNEL_ERROR_NOTIFY_CALLBACK = 0x800201ab,
7440 + SCE_KERNEL_ERROR_THREAD_TERMINATED = 0x800201ac,
7441 + SCE_KERNEL_ERROR_SEMA_ZERO = 0x800201ad,
7442 + SCE_KERNEL_ERROR_SEMA_OVF = 0x800201ae,
7443 + SCE_KERNEL_ERROR_EVF_COND = 0x800201af,
7444 + SCE_KERNEL_ERROR_EVF_MULTI = 0x800201b0,
7445 + SCE_KERNEL_ERROR_EVF_ILPAT = 0x800201b1,
7446 + SCE_KERNEL_ERROR_MBOX_NOMSG = 0x800201b2,
7447 + SCE_KERNEL_ERROR_MPP_FULL = 0x800201b3,
7448 + SCE_KERNEL_ERROR_MPP_EMPTY = 0x800201b4,
7449 + SCE_KERNEL_ERROR_WAIT_DELETE = 0x800201b5,
7450 + SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCK = 0x800201b6,
7451 + SCE_KERNEL_ERROR_ILLEGAL_MEMSIZE = 0x800201b7,
7452 + SCE_KERNEL_ERROR_ILLEGAL_SPADADDR = 0x800201b8,
7453 + SCE_KERNEL_ERROR_SPAD_INUSE = 0x800201b9,
7454 + SCE_KERNEL_ERROR_SPAD_NOT_INUSE = 0x800201ba,
7455 + SCE_KERNEL_ERROR_ILLEGAL_TYPE = 0x800201bb,
7456 + SCE_KERNEL_ERROR_ILLEGAL_SIZE = 0x800201bc,
7457 + SCE_KERNEL_ERROR_ILLEGAL_COUNT = 0x800201bd,
7458 + SCE_KERNEL_ERROR_UNKNOWN_VTID = 0x800201be,
7459 + SCE_KERNEL_ERROR_ILLEGAL_VTID = 0x800201bf,
7460 + SCE_KERNEL_ERROR_ILLEGAL_KTLSID = 0x800201c0,
7461 + SCE_KERNEL_ERROR_KTLS_FULL = 0x800201c1,
7462 + SCE_KERNEL_ERROR_KTLS_BUSY = 0x800201c2,
7463 + SCE_KERNEL_ERROR_PM_INVALID_PRIORITY = 0x80020258,
7464 + SCE_KERNEL_ERROR_PM_INVALID_DEVNAME = 0x80020259,
7465 + SCE_KERNEL_ERROR_PM_UNKNOWN_DEVNAME = 0x8002025a,
7466 + SCE_KERNEL_ERROR_PM_PMINFO_REGISTERED = 0x8002025b,
7467 + SCE_KERNEL_ERROR_PM_PMINFO_UNREGISTERED = 0x8002025c,
7468 + SCE_KERNEL_ERROR_PM_INVALID_MAJOR_STATE = 0x8002025d,
7469 + SCE_KERNEL_ERROR_PM_INVALID_REQUEST = 0x8002025e,
7470 + SCE_KERNEL_ERROR_PM_UNKNOWN_REQUEST = 0x8002025f,
7471 + SCE_KERNEL_ERROR_PM_INVALID_UNIT = 0x80020260,
7472 + SCE_KERNEL_ERROR_PM_CANNOT_CANCEL = 0x80020261,
7473 + SCE_KERNEL_ERROR_PM_INVALID_PMINFO = 0x80020262,
7474 + SCE_KERNEL_ERROR_PM_INVALID_ARGUMENT = 0x80020263,
7475 + SCE_KERNEL_ERROR_PM_ALREADY_TARGET_PWRSTATE = 0x80020264,
7476 + SCE_KERNEL_ERROR_PM_CHANGE_PWRSTATE_FAILED = 0x80020265,
7477 + SCE_KERNEL_ERROR_PM_CANNOT_CHANGE_DEVPWR_STATE = 0x80020266,
7478 + SCE_KERNEL_ERROR_PM_NO_SUPPORT_DEVPWR_STATE = 0x80020267,
7479 + SCE_KERNEL_ERROR_DMAC_REQUEST_FAILED = 0x800202bc,
7480 + SCE_KERNEL_ERROR_DMAC_REQUEST_DENIED = 0x800202bd,
7481 + SCE_KERNEL_ERROR_DMAC_OP_QUEUED = 0x800202be,
7482 + SCE_KERNEL_ERROR_DMAC_OP_NOT_QUEUED = 0x800202bf,
7483 + SCE_KERNEL_ERROR_DMAC_OP_RUNNING = 0x800202c0,
7484 + SCE_KERNEL_ERROR_DMAC_OP_NOT_ASSIGNED = 0x800202c1,
7485 + SCE_KERNEL_ERROR_DMAC_OP_TIMEOUT = 0x800202c2,
7486 + SCE_KERNEL_ERROR_DMAC_OP_FREED = 0x800202c3,
7487 + SCE_KERNEL_ERROR_DMAC_OP_USED = 0x800202c4,
7488 + SCE_KERNEL_ERROR_DMAC_OP_EMPTY = 0x800202c5,
7489 + SCE_KERNEL_ERROR_DMAC_OP_ABORTED = 0x800202c6,
7490 + SCE_KERNEL_ERROR_DMAC_OP_ERROR = 0x800202c7,
7491 + SCE_KERNEL_ERROR_DMAC_CHANNEL_RESERVED = 0x800202c8,
7492 + SCE_KERNEL_ERROR_DMAC_CHANNEL_EXCLUDED = 0x800202c9,
7493 + SCE_KERNEL_ERROR_DMAC_PRIVILEGE_ADDRESS = 0x800202ca,
7494 + SCE_KERNEL_ERROR_DMAC_NO_ENOUGHSPACE = 0x800202cb,
7495 + SCE_KERNEL_ERROR_DMAC_CHANNEL_NOT_ASSIGNED = 0x800202cc,
7496 + SCE_KERNEL_ERROR_DMAC_CHILD_OPERATION = 0x800202cd,
7497 + SCE_KERNEL_ERROR_DMAC_TOO_MUCH_SIZE = 0x800202ce,
7498 + SCE_KERNEL_ERROR_DMAC_INVALID_ARGUMENT = 0x800202cf,
7499 + SCE_KERNEL_ERROR_MFILE = 0x80020320,
7500 + SCE_KERNEL_ERROR_NODEV = 0x80020321,
7501 + SCE_KERNEL_ERROR_XDEV = 0x80020322,
7502 + SCE_KERNEL_ERROR_BADF = 0x80020323,
7503 + SCE_KERNEL_ERROR_INVAL = 0x80020324,
7504 + SCE_KERNEL_ERROR_UNSUP = 0x80020325,
7505 + SCE_KERNEL_ERROR_ALIAS_USED = 0x80020326,
7506 + SCE_KERNEL_ERROR_CANNOT_MOUNT = 0x80020327,
7507 + SCE_KERNEL_ERROR_DRIVER_DELETED = 0x80020328,
7508 + SCE_KERNEL_ERROR_ASYNC_BUSY = 0x80020329,
7509 + SCE_KERNEL_ERROR_NOASYNC = 0x8002032a,
7510 + SCE_KERNEL_ERROR_REGDEV = 0x8002032b,
7511 + SCE_KERNEL_ERROR_NOCWD = 0x8002032c,
7512 + SCE_KERNEL_ERROR_NAMETOOLONG = 0x8002032d,
7513 + SCE_KERNEL_ERROR_NXIO = 0x800203e8,
7514 + SCE_KERNEL_ERROR_IO = 0x800203e9,
7515 + SCE_KERNEL_ERROR_NOMEM = 0x800203ea,
7516 + SCE_KERNEL_ERROR_STDIO_NOT_OPENED = 0x800203eb,
7517 + SCE_KERNEL_ERROR_CACHE_ALIGNMENT = 0x8002044c,
7518 + SCE_KERNEL_ERROR_ERRORMAX = 0x8002044d,
7521 +#endif /* PSPKERROR_H */
7522 diff --git a/newlib/psp/include/psploadcore.h b/newlib/psp/include/psploadcore.h
7523 new file mode 100644
7524 index 0000000..69ab392
7525 --- /dev/null
7526 +++ b/newlib/psp/include/psploadcore.h
7527 @@ -0,0 +1,145 @@
7529 + * PSP Software Development Kit - https://github.com/pspdev
7530 + * -----------------------------------------------------------------------
7531 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7533 + * psploadcore.h - Interface to LoadCoreForKernel.
7535 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7536 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7537 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7539 + */
7541 +#ifndef PSPLOADCORE_H
7542 +#define PSPLOADCORE_H
7544 +#include <pspkerneltypes.h>
7546 +/** @defgroup LoadCore Interface to the LoadCoreForKernel library.
7547 + */
7549 +#ifdef __cplusplus
7550 +extern "C" {
7551 +#endif
7553 +/** @addtogroup LoadCore Interface to the LoadCoreForKernel library. */
7554 +/**@{*/
7556 +/** Describes a module. This structure could change in future firmware revisions. */
7557 +typedef struct SceModule {
7558 + struct SceModule *next;
7559 + unsigned short attribute;
7560 + unsigned char version[2];
7561 + char modname[27];
7562 + char terminal;
7563 + unsigned int unknown1;
7564 + unsigned int unknown2;
7565 + SceUID modid;
7566 + unsigned int unknown3[4];
7567 + void * ent_top;
7568 + unsigned int ent_size;
7569 + void * stub_top;
7570 + unsigned int stub_size;
7571 + unsigned int unknown4[4];
7572 + unsigned int entry_addr;
7573 + unsigned int gp_value;
7574 + unsigned int text_addr;
7575 + unsigned int text_size;
7576 + unsigned int data_size;
7577 + unsigned int bss_size;
7578 + unsigned int nsegment;
7579 + unsigned int segmentaddr[4];
7580 + unsigned int segmentsize[4];
7581 +} __attribute__((packed)) SceModule;
7583 +/** Defines a library and its exported functions and variables. Use the len
7584 + member to determine the real size of the table (size = len * 4). */
7585 +typedef struct SceLibraryEntryTable {
7586 + /**The library's name. */
7587 + const char * libname;
7588 + /** Library version. */
7589 + unsigned char version[2];
7590 + /** Library attributes. */
7591 + unsigned short attribute;
7592 + /** Length of this entry table in 32-bit WORDs. */
7593 + unsigned char len;
7594 + /** The number of variables exported by the library. */
7595 + unsigned char vstubcount;
7596 + /** The number of functions exported by the library. */
7597 + unsigned short stubcount;
7598 + /** Pointer to the entry table; an array of NIDs followed by
7599 + pointers to functions and variables. */
7600 + void * entrytable;
7601 +} SceLibraryEntryTable;
7603 +/** Specifies a library and a set of imports from that library. Use the len
7604 + member to determine the real size of the table (size = len * 4). */
7605 +typedef struct SceLibraryStubTable {
7606 + /* The name of the library we're importing from. */
7607 + const char * libname;
7608 + /** Minimum required version of the library we want to import. */
7609 + unsigned char version[2];
7610 + /* Import attributes. */
7611 + unsigned short attribute;
7612 + /** Length of this stub table in 32-bit WORDs. */
7613 + unsigned char len;
7614 + /** The number of variables imported from the library. */
7615 + unsigned char vstubcount;
7616 + /** The number of functions imported from the library. */
7617 + unsigned short stubcount;
7618 + /** Pointer to an array of NIDs. */
7619 + unsigned int * nidtable;
7620 + /** Pointer to the imported function stubs. */
7621 + void * stubtable;
7622 + /** Pointer to the imported variable stubs. */
7623 + void * vstubtable;
7624 +} SceLibraryStubTable;
7627 +/**
7628 + * Find a module by it's name.
7630 + * @param modname - The name of the module.
7632 + * @return Pointer to the ::SceModule structure if found, otherwise NULL.
7633 + */
7634 +SceModule * sceKernelFindModuleByName(const char *modname);
7636 +/**
7637 + * Find a module from an address.
7639 + * @param addr - Address somewhere within the module.
7641 + * @return Pointer to the ::SceModule structure if found, otherwise NULL.
7642 + */
7643 +SceModule * sceKernelFindModuleByAddress(unsigned int addr);
7645 +/**
7646 + * Find a module by it's UID.
7648 + * @param modid - The UID of the module.
7650 + * @return Pointer to the ::SceModule structure if found, otherwise NULL.
7651 + */
7652 +SceModule * sceKernelFindModuleByUID(SceUID modid);
7654 +/**
7655 + * Return the count of loaded modules.
7657 + * @return The count of loaded modules.
7658 + */
7659 +int sceKernelModuleCount(void);
7661 +/**
7662 + * Invalidate the CPU's instruction cache.
7663 + */
7664 +void sceKernelIcacheClearAll(void);
7666 +/**@}*/
7668 +#ifdef __cplusplus
7670 +#endif
7672 +#endif /* PSPLOADCORE_H */
7673 diff --git a/newlib/psp/include/psploadexec.h b/newlib/psp/include/psploadexec.h
7674 new file mode 100644
7675 index 0000000..8113ac1
7676 --- /dev/null
7677 +++ b/newlib/psp/include/psploadexec.h
7678 @@ -0,0 +1,87 @@
7680 + * PSP Software Development Kit - https://github.com/pspdev
7681 + * -----------------------------------------------------------------------
7682 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7684 + * psploadexec.h - Process load and exit related functions.
7686 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7687 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7688 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7690 + */
7692 +/* Note: Some of the structures, types, and definitions in this file were
7693 + extrapolated from symbolic debugging information found in the Japanese
7694 + version of Puzzle Bobble. */
7696 +#ifndef __LOADEXEC_H__
7697 +#define __LOADEXEC_H__
7699 +/** @defgroup LoadExec LoadExec Library */
7701 +#ifdef __cplusplus
7702 +extern "C" {
7703 +#endif
7705 +/** @addtogroup LoadExec */
7707 +/**@{*/
7709 +/**
7710 + * Register callback
7712 + * @note By installing the exit callback the home button becomes active. However if sceKernelExitGame
7713 + * is not called in the callback it is likely that the psp will just crash.
7715 + * @par Example:
7716 + * @code
7717 + * int exit_callback(void) { sceKernelExitGame(); }
7719 + * cbid = sceKernelCreateCallback("ExitCallback", exit_callback, NULL);
7720 + * sceKernelRegisterExitCallback(cbid);
7721 + * @endcode
7723 + * @param cbid Callback id
7724 + * @return < 0 on error
7725 + */
7726 +int sceKernelRegisterExitCallback(int cbid);
7728 +/**
7729 + * Exit game and go back to the PSP browser.
7731 + * @note You need to be in a thread in order for this function to work
7733 + */
7734 +void sceKernelExitGame(void);
7736 +/** Structure to pass to loadexec */
7737 +struct SceKernelLoadExecParam {
7738 + /** Size of the structure */
7739 + SceSize size;
7740 + /** Size of the arg string */
7741 + SceSize args;
7742 + /** Pointer to the arg string */
7743 + void * argp;
7744 + /** Encryption key ? */
7745 + const char * key;
7748 +/**
7749 + * Execute a new game executable, limited when not running in kernel mode.
7750 + *
7751 + * @param file - The file to execute.
7752 + * @param param - Pointer to a ::SceKernelLoadExecParam structure, or NULL.
7754 + * @return < 0 on error, probably.
7756 + */
7757 +int sceKernelLoadExec(const char *file, struct SceKernelLoadExecParam *param);
7759 +#ifdef __cplusplus
7761 +#endif
7763 +/**@}*/
7765 +#endif
7766 diff --git a/newlib/psp/include/psploadexec_kernel.h b/newlib/psp/include/psploadexec_kernel.h
7767 new file mode 100644
7768 index 0000000..dedaae3
7769 --- /dev/null
7770 +++ b/newlib/psp/include/psploadexec_kernel.h
7771 @@ -0,0 +1,164 @@
7773 + * PSP Software Development Kit - https://github.com/pspdev
7774 + * -----------------------------------------------------------------------
7775 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7777 + * psploadexec_kernel.h - Interface to LoadExecForKernel.
7779 + * Copyright (c) 2007 - DA (Taken from the 303oe SDK)
7781 + */
7783 +#ifndef PSPLOADEXEC_KERNEL_H
7784 +#define PSPLOADEXEC_KERNEL_H
7786 +#include <pspkerneltypes.h>
7787 +#include <psploadexec.h>
7789 +/** @defgroup LoadExecKernel Interface to the LoadExecForKernel library.
7790 + */
7792 +#ifdef __cplusplus
7793 +extern "C" {
7794 +#endif
7796 +/** @addtogroup LoadExecKernel Interface to the LoadExecForKernel library. */
7797 +/**@{*/
7799 +/** Structure for LoadExecVSH* functions */
7800 +struct SceKernelLoadExecVSHParam {
7801 +/** Size of the structure in bytes */
7802 + SceSize size;
7803 +/** Size of the arguments string */
7804 + SceSize args;
7805 +/** Pointer to the arguments strings */
7806 + void * argp;
7807 +/** The key, usually "game", "updater" or "vsh" */
7808 + const char * key;
7809 +/** The size of the vshmain arguments */
7810 + u32 vshmain_args_size;
7811 +/** vshmain arguments that will be passed to vshmain after the program has exited */
7812 + void *vshmain_args;
7813 +/** "/kd/pspbtcnf_game.txt" or "/kd/pspbtcnf.txt" if not supplied (max. 256 chars) */
7814 + char *configfile;
7815 +/** An unknown string (max. 256 chars) probably used in 2nd stage of loadexec */
7816 + u32 unk4;
7817 +/** unknown flag default value = 0x10000 */
7818 + u32 unk5;
7819 +};
7821 +#if _PSP_FW_VERSION < 200
7822 +/**
7823 + * Executes a new executable from a buffer.
7825 + * @param bufsize - Size in bytes of the buffer pointed by buf.
7826 + * @param buf - Pointer to a buffer containing the module to execute.
7827 + * @param param - Pointer to a ::SceKernelLoadExecParam structure, or NULL.
7829 + * @return < 0 on some errors.
7831 +int sceKernelLoadExecBufferPlain(SceSize bufsize, void *buf, struct SceKernelLoadExecParam *param);
7832 +#endif
7834 +/**
7835 + * Restart the vsh.
7837 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL
7839 + * @return < 0 on some errors.
7841 + * @note - when called in game mode it will have the same effect that sceKernelExitGame
7844 +int sceKernelExitVSHVSH(struct SceKernelLoadExecVSHParam *param);
7846 +#if _PSP_FW_VERSION >= 200
7847 +/**
7848 + * Restart the vsh (to be used by a kernel module)
7850 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL
7852 + * @return < 0 on some errors.
7854 + * @note - when called in game mode it will have the same effect that sceKernelExitGame
7855 + * @note2: available since firmware 2.00.
7857 +int sceKernelExitVSHKernel(struct SceKernelLoadExecVSHParam *param);
7858 +#endif
7860 +/**
7861 + * Executes a new executable from a disc.
7862 + * It is the function used by the firmware to execute the EBOOT.BIN from a disc.
7864 + * @param file - The file to execute.
7865 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
7867 + * @return < 0 on some errors.
7869 +int sceKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param);
7871 +/**
7872 + * Executes a new executable from a disc.
7873 + * It is the function used by the firmware to execute an updater from a disc.
7875 + * @param file - The file to execute.
7876 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
7878 + * @return < 0 on some errors.
7880 +int sceKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param);
7882 +/**
7883 + * Executes a new executable from a memory stick.
7884 + * It is the function used by the firmware to execute an updater from a memory stick.
7886 + * @param file - The file to execute.
7887 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
7889 + * @return < 0 on some errors.
7891 +int sceKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param);
7893 +/**
7894 + * Executes a new executable from a memory stick.
7895 + * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick.
7897 + * @param file - The file to execute.
7898 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
7900 + * @return < 0 on some errors.
7902 +int sceKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param);
7904 +/**
7905 + * Executes a new executable from a memory stick.
7906 + * It is the function used by the firmware to execute ... ?
7908 + * @param file - The file to execute.
7909 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
7911 + * @return < 0 on some errors.
7913 +int sceKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param);
7915 +#if _PSP_FW_VERSION >= 300
7916 +/***
7917 + * Executes a new executable from a memory stick.
7918 + * It is the function used by the firmware to execute psx games
7920 + * @param file - The file to execute.
7921 + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL.
7923 + * @return < 0 on some errors.
7924 + * @note - Available since firmware 3.00
7926 +int sceKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param);
7927 +#endif
7929 +/**@}*/
7931 +#ifdef __cplusplus
7933 +#endif
7935 +#endif
7936 diff --git a/newlib/psp/include/pspmoduleexport.h b/newlib/psp/include/pspmoduleexport.h
7937 new file mode 100644
7938 index 0000000..b597831
7939 --- /dev/null
7940 +++ b/newlib/psp/include/pspmoduleexport.h
7941 @@ -0,0 +1,28 @@
7943 + * PSP Software Development Kit - https://github.com/pspdev
7944 + * -----------------------------------------------------------------------
7945 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7947 + * pspmoduleexport.h - Definitions for the .rodata.sceResident section.
7949 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7950 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7951 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7953 + */
7955 +#ifndef PSP_MODEXPORT_H_
7956 +#define PSP_MODEXPORT_H_
7958 +/** Structure to hold a single export entry */
7959 +struct _PspLibraryEntry {
7960 + const char * name;
7961 + unsigned short version;
7962 + unsigned short attribute;
7963 + unsigned char entLen;
7964 + unsigned char varCount;
7965 + unsigned short funcCount;
7966 + void * entrytable;
7967 +};
7969 +#endif
7970 diff --git a/newlib/psp/include/pspmoduleinfo.h b/newlib/psp/include/pspmoduleinfo.h
7971 new file mode 100644
7972 index 0000000..a7a83ff
7973 --- /dev/null
7974 +++ b/newlib/psp/include/pspmoduleinfo.h
7975 @@ -0,0 +1,110 @@
7977 + * PSP Software Development Kit - https://github.com/pspdev
7978 + * -----------------------------------------------------------------------
7979 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
7981 + * pspmoduleinfo.h - Definitions for the .rodata.sceModuleInfo ELF section.
7983 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
7984 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
7985 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
7987 + */
7988 +#ifndef PSPMODULEINFO_H
7989 +#define PSPMODULEINFO_H
7991 +/* Note: Some of the structures and definitions in this file were extrapolated from
7992 + symbolic debugging information found in the Japanese version of Puzzle Bobble. */
7994 +/* Module info structure. Used to declare a module (library or executable). This structure
7995 + is required in all PSP executables. */
7996 +typedef struct _scemoduleinfo {
7997 + unsigned short modattribute;
7998 + unsigned char modversion[2];
7999 + char modname[27];
8000 + char terminal;
8001 + void * gp_value;
8002 + void * ent_top;
8003 + void * ent_end;
8004 + void * stub_top;
8005 + void * stub_end;
8006 +} _sceModuleInfo;
8008 +typedef const _sceModuleInfo SceModuleInfo;
8010 +extern char _gp[];
8012 +enum PspModuleInfoAttr
8014 + PSP_MODULE_USER = 0,
8015 + PSP_MODULE_NO_STOP = 0x0001,
8016 + PSP_MODULE_SINGLE_LOAD = 0x0002,
8017 + PSP_MODULE_SINGLE_START = 0x0004,
8018 + PSP_MODULE_KERNEL = 0x1000,
8021 +#ifdef __cplusplus
8023 +/* Declare a module. This must be specified in the source of a library or executable. */
8024 +#define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
8025 + extern char __lib_ent_top[], __lib_ent_bottom[]; \
8026 + extern char __lib_stub_top[], __lib_stub_bottom[]; \
8027 + extern SceModuleInfo module_info \
8028 + __attribute__((section(".rodata.sceModuleInfo"), \
8029 + aligned(16), unused)) = { \
8030 + attributes, { minor_version, major_version }, #name, 0, _gp, \
8031 + __lib_ent_top, __lib_ent_bottom, \
8032 + __lib_stub_top, __lib_stub_bottom \
8034 +#else
8035 +/* Declare a module. This must be specified in the source of a library or executable. */
8036 +#define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
8037 + extern char __lib_ent_top[], __lib_ent_bottom[]; \
8038 + extern char __lib_stub_top[], __lib_stub_bottom[]; \
8039 + SceModuleInfo module_info \
8040 + __attribute__((section(".rodata.sceModuleInfo"), \
8041 + aligned(16), unused)) = { \
8042 + attributes, { minor_version, major_version }, name, 0, _gp, \
8043 + __lib_ent_top, __lib_ent_bottom, \
8044 + __lib_stub_top, __lib_stub_bottom \
8046 +#endif
8048 +/* Define the main thread's initial priority. */
8049 +#define PSP_MAIN_THREAD_PRIORITY(priority) \
8050 + unsigned int sce_newlib_priority = (priority)
8051 +/* Define the main thread's stack size (in KB). */
8052 +#define PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb) \
8053 + unsigned int sce_newlib_stack_kb_size = (size_kb)
8054 +/* Define the main thread's attributes. */
8055 +#define PSP_MAIN_THREAD_ATTR(attr) \
8056 + unsigned int sce_newlib_attribute = (attr)
8057 +#define PSP_MAIN_THREAD_ATTRIBUTE PSP_MAIN_THREAD_ATTR
8059 +/* Define all main thread parameters. */
8060 +#define PSP_MAIN_THREAD_PARAMS(priority, size_kb, attribute) \
8061 + PSP_MAIN_THREAD_PRIORITY(priority); \
8062 + PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb); \
8063 + PSP_MAIN_THREAD_ATTR(attribute)
8065 +/* If declared, the runtime code won't create a main thread for the program. */
8066 +#define PSP_NO_CREATE_MAIN_THREAD() \
8067 + int sce_newlib_nocreate_thread_in_start = 1
8069 +/* Declare the size of the heap (in KB) that the program wants to allocate from. */
8070 +#define PSP_HEAP_SIZE_KB(size_kb) \
8071 + int sce_newlib_heap_kb_size = (size_kb)
8073 +/* Declare the threshold of the heap (in KB) that the program wants to keep for external allocation. */
8074 +#define PSP_HEAP_THRESHOLD_SIZE_KB(size_kb) \
8075 + int sce_newlib_heap_threshold_kb_size = (size_kb)
8077 +/* Declare the name of the main thread */
8078 +#define PSP_MAIN_THREAD_NAME(s) const char* sce_newlib_main_thread_name = (s)
8080 +/* Disable the use of newlib, getting a minimal binary. */
8081 +#define PSP_DISABLE_NEWLIB() \
8082 + void __libcglue_init(int argc, char *argv[]) {} \
8083 + void __libcglue_deinit() {}
8085 +#endif /* PSPMODULEINFO_H */
8086 diff --git a/newlib/psp/include/pspmodulemgr.h b/newlib/psp/include/pspmodulemgr.h
8087 new file mode 100644
8088 index 0000000..527b7ef
8089 --- /dev/null
8090 +++ b/newlib/psp/include/pspmodulemgr.h
8091 @@ -0,0 +1,226 @@
8093 + * PSP Software Development Kit - https://github.com/pspdev
8094 + * -----------------------------------------------------------------------
8095 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
8097 + * pspmodulemgr.h - Prototypes to manage modules.
8099 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
8100 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
8101 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
8103 + */
8105 +/* Note: Some of the structures, types, and definitions in this file were
8106 + extrapolated from symbolic debugging information found in the Japanese
8107 + version of Puzzle Bobble. */
8109 +#ifndef __MODLOAD_H__
8110 +#define __MODLOAD_H__
8112 +#include <pspkerneltypes.h>
8114 +/** @defgroup ModuleMgr Module Manager Library
8115 + * This module contains the imports for the kernel's module management routines.
8116 + */
8118 +#ifdef __cplusplus
8119 +extern "C" {
8120 +#endif
8122 +/** @addtogroup ModuleMgr Module Manager Library */
8123 +/**@{*/
8125 +#define PSP_MEMORY_PARTITION_KERNEL 1
8126 +#define PSP_MEMORY_PARTITION_USER 2
8128 +typedef struct SceKernelLMOption {
8129 + SceSize size;
8130 + SceUID mpidtext;
8131 + SceUID mpiddata;
8132 + unsigned int flags;
8133 + char position;
8134 + char access;
8135 + char creserved[2];
8136 +} SceKernelLMOption;
8138 +typedef struct SceKernelSMOption {
8139 + SceSize size;
8140 + SceUID mpidstack;
8141 + SceSize stacksize;
8142 + int priority;
8143 + unsigned int attribute;
8144 +} SceKernelSMOption;
8147 +/**
8148 + * Load a module.
8149 + * @note This function restricts where it can load from (such as from flash0)
8150 + * unless you call it in kernel mode. It also must be called from a thread.
8151 + *
8152 + * @param path - The path to the module to load.
8153 + * @param flags - Unused, always 0 .
8154 + * @param option - Pointer to a mod_param_t structure. Can be NULL.
8156 + * @return The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
8157 + */
8158 +SceUID sceKernelLoadModule(const char *path, int flags, SceKernelLMOption *option);
8160 +/**
8161 + * Load a module from MS.
8162 + * @note This function restricts what it can load, e.g. it wont load plain executables.
8163 + *
8164 + * @param path - The path to the module to load.
8165 + * @param flags - Unused, set to 0.
8166 + * @param option - Pointer to a mod_param_t structure. Can be NULL.
8168 + * @return The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
8169 + */
8170 +SceUID sceKernelLoadModuleMs(const char *path, int flags, SceKernelLMOption *option);
8172 +/**
8173 + * Load a module from the given file UID.
8175 + * @param fid - The module's file UID.
8176 + * @param flags - Unused, always 0.
8177 + * @param option - Pointer to an optional ::SceKernelLMOption structure.
8179 + * @return The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
8180 + */
8181 +SceUID sceKernelLoadModuleByID(SceUID fid, int flags, SceKernelLMOption *option);
8183 +/**
8184 + * Load a module from a buffer using the USB/WLAN API.
8186 + * Can only be called from kernel mode, or from a thread that has attributes of 0xa0000000.
8188 + * @param bufsize - Size (in bytes) of the buffer pointed to by buf.
8189 + * @param buf - Pointer to a buffer containing the module to load. The buffer must reside at an
8190 + * address that is a multiple to 64 bytes.
8191 + * @param flags - Unused, always 0.
8192 + * @param option - Pointer to an optional ::SceKernelLMOption structure.
8194 + * @return The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
8195 + */
8196 +SceUID sceKernelLoadModuleBufferUsbWlan(SceSize bufsize, void *buf, int flags, SceKernelLMOption *option);
8198 +/**
8199 + * Start a loaded module.
8201 + * @param modid - The ID of the module returned from LoadModule.
8202 + * @param argsize - Length of the args.
8203 + * @param argp - A pointer to the arguments to the module.
8204 + * @param status - Returns the status of the start.
8205 + * @param option - Pointer to an optional ::SceKernelSMOption structure.
8207 + * @return ??? on success, otherwise one of ::PspKernelErrorCodes.
8208 + */
8209 +int sceKernelStartModule(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option);
8211 +/**
8212 + * Stop a running module.
8214 + * @param modid - The UID of the module to stop.
8215 + * @param argsize - The length of the arguments pointed to by argp.
8216 + * @param argp - Pointer to arguments to pass to the module's module_stop() routine.
8217 + * @param status - Return value of the module's module_stop() routine.
8218 + * @param option - Pointer to an optional ::SceKernelSMOption structure.
8220 + * @return ??? on success, otherwise one of ::PspKernelErrorCodes.
8221 + */
8222 +int sceKernelStopModule(SceUID modid, SceSize argsize, void *argp, int *status, SceKernelSMOption *option);
8224 +/**
8225 + * Unload a stopped module.
8227 + * @param modid - The UID of the module to unload.
8229 + * @return ??? on success, otherwise one of ::PspKernelErrorCodes.
8230 + */
8231 +int sceKernelUnloadModule(SceUID modid);
8233 +/**
8234 + * Stop and unload the current module.
8236 + * @param unknown - Unknown (I've seen 1 passed).
8237 + * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop().
8238 + * @param argp - Pointer to arguments that will be passed to module_stop().
8240 + * @return ??? on success, otherwise one of ::PspKernelErrorCodes.
8241 + */
8242 +int sceKernelSelfStopUnloadModule(int unknown, SceSize argsize, void *argp);
8244 +/**
8245 + * Stop and unload the current module.
8247 + * @param argsize - Size (in bytes) of the arguments that will be passed to module_stop().
8248 + * @param argp - Poitner to arguments that will be passed to module_stop().
8249 + * @param status - Return value from module_stop().
8250 + * @param option - Pointer to an optional ::SceKernelSMOption structure.
8252 + * @return ??? on success, otherwise one of ::PspKernelErrorCodes.
8253 + */
8254 +int sceKernelStopUnloadSelfModule(SceSize argsize, void *argp, int *status, SceKernelSMOption *option);
8257 +typedef struct SceKernelModuleInfo {
8258 + SceSize size;
8259 + char nsegment;
8260 + char reserved[3];
8261 + int segmentaddr[4];
8262 + int segmentsize[4];
8263 + unsigned int entry_addr;
8264 + unsigned int gp_value;
8265 + unsigned int text_addr;
8266 + unsigned int text_size;
8267 + unsigned int data_size;
8268 + unsigned int bss_size;
8269 + /* The following is only available in the v1.5 firmware and above,
8270 + but as sceKernelQueryModuleInfo is broken in v1.0 is doesn't matter ;) */
8271 + unsigned short attribute;
8272 + unsigned char version[2];
8273 + char name[28];
8274 +} SceKernelModuleInfo;
8276 +/**
8277 + * Query the information about a loaded module from its UID.
8278 + * @note This fails on v1.0 firmware (and even it worked has a limited structure)
8279 + * so if you want to be compatible with both 1.5 and 1.0 (and you are running in
8280 + * kernel mode) then call this function first then ::pspSdkQueryModuleInfoV1
8281 + * if it fails, or make separate v1 and v1.5+ builds.
8283 + * @param modid - The UID of the loaded module.
8284 + * @param info - Pointer to a ::SceKernelModuleInfo structure.
8285 + *
8286 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes.
8287 + */
8288 +int sceKernelQueryModuleInfo(SceUID modid, SceKernelModuleInfo *info);
8290 +/**
8291 + * Get a list of module IDs. NOTE: This is only available on 1.5 firmware
8292 + * and above. For V1 use ::pspSdkGetModuleIdList.
8294 + * @param readbuf - Buffer to store the module list.
8295 + * @param readbufsize - Number of elements in the readbuffer.
8296 + * @param idcount - Returns the number of module ids
8298 + * @return >= 0 on success
8299 + */
8300 +int sceKernelGetModuleIdList(SceUID *readbuf, int readbufsize, int *idcount);
8302 +/**
8303 + * Get the ID of the module occupying the address
8305 + * @param moduleAddr - A pointer to the module
8307 + * @return >= 0 on success, otherwise one of ::PspKernelErrorCodes
8308 + */
8309 +int sceKernelGetModuleIdByAddress(const void *moduleAddr);
8311 +/**@}*/
8313 +#ifdef __cplusplus
8315 +#endif
8317 +#endif
8318 diff --git a/newlib/psp/include/pspmodulemgr_kernel.h b/newlib/psp/include/pspmodulemgr_kernel.h
8319 new file mode 100644
8320 index 0000000..14f496f
8321 --- /dev/null
8322 +++ b/newlib/psp/include/pspmodulemgr_kernel.h
8323 @@ -0,0 +1,67 @@
8325 + * PSP Software Development Kit - https://github.com/pspdev
8326 + * -----------------------------------------------------------------------
8327 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
8329 + * pspmodulemgr_kernel.h - Prototypes to manage modules.
8331 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
8332 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
8333 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
8335 + */
8337 +#ifndef __MODMGRKERNEL_H__
8338 +#define __MODMGRKERNEL_H__
8340 +#include <pspkerneltypes.h>
8341 +#include <pspmodulemgr.h>
8343 +/** @defgroup ModuleMgrKern Kernel Module Manager Library
8344 + * This module contains the imports for the kernel's module management routines.
8345 + */
8347 +#ifdef __cplusplus
8348 +extern "C" {
8349 +#endif
8351 +/** @addtogroup ModuleMgrKern Kernel Module Manager Library */
8352 +/**@{*/
8354 +/**
8355 + * Gets the current module list.
8356 + *
8357 + * @param readbufsize - The size of the read buffer.
8358 + * @param readbuf - Pointer to a buffer to store the IDs
8360 + * @return < 0 on error.
8361 + */
8362 +int sceKernelGetModuleList(int readbufsize, SceUID *readbuf);
8364 +/**
8365 + * Get the number of loaded modules.
8367 + * @return The number of loaded modules.
8368 + */
8369 +int sceKernelModuleCount(void);
8371 +/**
8372 + * Load a module from a buffer
8374 + * @param buf - Pointer to a buffer containing the module to load. The buffer must reside at an
8375 + * address that is a multiple to 64 bytes.
8376 + * @param bufsize - Size (in bytes) of the buffer pointed to by buf.
8377 + * @param flags - Unused, always 0.
8378 + * @param option - Pointer to an optional ::SceKernelLMOption structure.
8380 + * @return The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes.
8381 + */
8382 +SceUID sceKernelLoadModuleBuffer(void *buf, SceSize bufsize, int flags, SceKernelLMOption *option);
8384 +/**@}*/
8386 +#ifdef __cplusplus
8388 +#endif
8390 +#endif
8391 diff --git a/newlib/psp/include/pspmp3.h b/newlib/psp/include/pspmp3.h
8392 new file mode 100644
8393 index 0000000..20a87ed
8394 --- /dev/null
8395 +++ b/newlib/psp/include/pspmp3.h
8396 @@ -0,0 +1,201 @@
8398 + * PSP Software Development Kit - https://github.com/pspdev
8399 + * -----------------------------------------------------------------------
8400 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
8402 + * pspmp3.h - Prototypes for the sceMp3 library
8404 + * Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
8405 + * Copyright (c) 2008 Alexander Berl <raphael@fx-world.org>
8407 + */
8409 +#ifndef __SCELIBMP3_H__
8410 +#define __SCELIBMP3_H__
8412 +#include <psptypes.h>
8414 +#ifdef __cplusplus
8415 +extern "C" {
8416 +#endif
8418 +typedef struct SceMp3InitArg {
8419 + /** Stream start position */
8420 + SceUInt32 mp3StreamStart;
8421 + /** Unknown - set to 0 */
8422 + SceUInt32 unk1;
8423 + /** Stream end position */
8424 + SceUInt32 mp3StreamEnd;
8425 + /** Unknown - set to 0 */
8426 + SceUInt32 unk2;
8427 + /** Pointer to a buffer to contain raw mp3 stream data (+1472 bytes workspace) */
8428 + SceVoid* mp3Buf;
8429 + /** Size of mp3Buf buffer (must be >= 8192) */
8430 + SceInt32 mp3BufSize;
8431 + /** Pointer to decoded pcm samples buffer */
8432 + SceVoid* pcmBuf;
8433 + /** Size of pcmBuf buffer (must be >= 9216) */
8434 + SceInt32 pcmBufSize;
8435 +} SceMp3InitArg;
8437 +/**
8438 + * sceMp3ReserveMp3Handle
8440 + * @param args - Pointer to SceMp3InitArg structure
8442 + * @return sceMp3 handle on success, < 0 on error.
8443 + */
8444 +SceInt32 sceMp3ReserveMp3Handle(SceMp3InitArg* args);
8446 +/**
8447 + * sceMp3ReleaseMp3Handle
8449 + * @param handle - sceMp3 handle
8451 + * @return 0 if success, < 0 on error.
8452 + */
8453 +SceInt32 sceMp3ReleaseMp3Handle(SceInt32 handle);
8455 +/**
8456 + * sceMp3InitResource
8458 + * @return 0 if success, < 0 on error.
8459 + */
8460 +SceInt32 sceMp3InitResource();
8462 +/**
8463 + * sceMp3TermResource
8465 + * @return 0 if success, < 0 on error.
8466 + */
8467 +SceInt32 sceMp3TermResource();
8469 +/**
8470 + * sceMp3Init
8472 + * @param handle - sceMp3 handle
8474 + * @return 0 if success, < 0 on error.
8475 + */
8476 +SceInt32 sceMp3Init(SceInt32 handle);
8478 +/**
8479 + * sceMp3Decode
8481 + * @param handle - sceMp3 handle
8482 + * @param dst - Pointer to destination pcm samples buffer
8484 + * @return number of bytes in decoded pcm buffer, < 0 on error.
8485 + */
8486 +SceInt32 sceMp3Decode(SceInt32 handle, SceShort16** dst);
8488 +/**
8489 + * sceMp3GetInfoToAddStreamData
8491 + * @param handle - sceMp3 handle
8492 + * @param dst - Pointer to stream data buffer
8493 + * @param towrite - Space remaining in stream data buffer
8494 + * @param srcpos - Position in source stream to start reading from
8496 + * @return 0 if success, < 0 on error.
8497 + */
8498 +SceInt32 sceMp3GetInfoToAddStreamData(SceInt32 handle, SceUChar8** dst, SceInt32* towrite, SceInt32* srcpos);
8500 +/**
8501 + * sceMp3NotifyAddStreamData
8503 + * @param handle - sceMp3 handle
8504 + * @param size - number of bytes added to the stream data buffer
8506 + * @return 0 if success, < 0 on error.
8507 + */
8508 +SceInt32 sceMp3NotifyAddStreamData(SceInt32 handle, SceInt32 size);
8510 +/**
8511 + * sceMp3CheckStreamDataNeeded
8513 + * @param handle - sceMp3 handle
8515 + * @return 1 if more stream data is needed, < 0 on error.
8516 + */
8517 +SceInt32 sceMp3CheckStreamDataNeeded(SceInt32 handle);
8519 +/**
8520 + * sceMp3SetLoopNum
8522 + * @param handle - sceMp3 handle
8523 + * @param loop - Number of loops
8525 + * @return 0 if success, < 0 on error.
8526 + */
8527 +SceInt32 sceMp3SetLoopNum(SceInt32 handle, SceInt32 loop);
8529 +/**
8530 + * sceMp3GetLoopNum
8532 + * @param handle - sceMp3 handle
8534 + * @return Number of loops
8535 + */
8536 +SceInt32 sceMp3GetLoopNum(SceInt32 handle);
8538 +/**
8539 + * sceMp3GetSumDecodedSample
8541 + * @param handle - sceMp3 handle
8543 + * @return Number of decoded samples
8544 + */
8545 +SceInt32 sceMp3GetSumDecodedSample(SceInt32 handle);
8547 +/**
8548 + * sceMp3GetMaxOutputSample
8550 + * @param handle - sceMp3 handle
8552 + * @return Number of max samples to output
8553 + */
8554 +SceInt32 sceMp3GetMaxOutputSample(SceInt32 handle);
8556 +/**
8557 + * sceMp3GetSamplingRate
8559 + * @param handle - sceMp3 handle
8561 + * @return Sampling rate of the mp3
8562 + */
8563 +SceInt32 sceMp3GetSamplingRate(SceInt32 handle);
8565 +/**
8566 + * sceMp3GetBitRate
8568 + * @param handle - sceMp3 handle
8570 + * @return Bitrate of the mp3
8571 + */
8572 +SceInt32 sceMp3GetBitRate(SceInt32 handle);
8574 +/**
8575 + * sceMp3GetMp3ChannelNum
8577 + * @param handle - sceMp3 handle
8579 + * @return Number of channels of the mp3
8580 + */
8581 +SceInt32 sceMp3GetMp3ChannelNum(SceInt32 handle);
8583 +/**
8584 + * sceMp3ResetPlayPosition
8586 + * @param handle - sceMp3 handle
8588 + * @return < 0 on error
8589 + */
8590 +SceInt32 sceMp3ResetPlayPosition(SceInt32 handle);
8593 +#ifdef __cplusplus
8595 +#endif
8597 +#endif
8598 diff --git a/newlib/psp/include/pspmpeg.h b/newlib/psp/include/pspmpeg.h
8599 new file mode 100644
8600 index 0000000..4a1d2f7
8601 --- /dev/null
8602 +++ b/newlib/psp/include/pspmpeg.h
8603 @@ -0,0 +1,343 @@
8605 + * PSP Software Development Kit - https://github.com/pspdev
8606 + * -----------------------------------------------------------------------
8607 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
8609 + * pspmpeg.h - Prototypes for the sceMpeg library
8611 + * Copyright (c) 2006 Sorin P. C. <magik@hypermagik.com>
8612 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
8614 + */
8616 +#ifndef __SCELIBMPEG_H__
8617 +#define __SCELIBMPEG_H__
8619 +#include <psptypes.h>
8621 +#ifdef __cplusplus
8622 +extern "C" {
8623 +#endif
8625 +/** points to "LIBMPEG" */
8626 +typedef ScePVoid SceMpeg;
8628 +/** some structure */
8629 +typedef SceVoid SceMpegStream;
8631 +/** Ringbuffer callback */
8632 +typedef SceInt32 (*sceMpegRingbufferCB)(ScePVoid pData, SceInt32 iNumPackets, ScePVoid pParam);
8634 +typedef struct SceMpegRingbuffer
8636 + /** packets */
8637 + SceInt32 iPackets;
8639 + /** unknown */
8640 + SceUInt32 iUnk0;
8641 + /** unknown */
8642 + SceUInt32 iUnk1;
8643 + /** unknown */
8644 + SceUInt32 iUnk2;
8645 + /** unknown */
8646 + SceUInt32 iUnk3;
8648 + /** pointer to data */
8649 + ScePVoid pData;
8651 + /** ringbuffer callback */
8652 + sceMpegRingbufferCB Callback;
8653 + /** callback param */
8654 + ScePVoid pCBparam;
8656 + /** unknown */
8657 + SceUInt32 iUnk4;
8658 + /** unknown */
8659 + SceUInt32 iUnk5;
8660 + /** mpeg id */
8661 + SceMpeg pSceMpeg;
8663 +} SceMpegRingbuffer;
8665 +typedef struct SceMpegAu
8667 + /** presentation timestamp MSB */
8668 + SceUInt32 iPtsMSB;
8669 + /** presentation timestamp LSB */
8670 + SceUInt32 iPts;
8671 + /** decode timestamp MSB */
8672 + SceUInt32 iDtsMSB;
8673 + /** decode timestamp LSB */
8674 + SceUInt32 iDts;
8675 + /** Es buffer handle */
8676 + SceUInt32 iEsBuffer;
8677 + /** Au size */
8678 + SceUInt32 iAuSize;
8680 +} SceMpegAu;
8682 +#define SCE_MPEG_AVC_FORMAT_DEFAULT -1
8683 +#define SCE_MPEG_AVC_FORMAT_5650 0
8684 +#define SCE_MPEG_AVC_FORMAT_5551 1
8685 +#define SCE_MPEG_AVC_FORMAT_4444 2
8686 +#define SCE_MPEG_AVC_FORMAT_8888 3
8688 +typedef struct SceMpegAvcMode
8690 + /** unknown, set to -1 */
8691 + SceInt32 iUnk0;
8692 + /** Decode pixelformat */
8693 + SceInt32 iPixelFormat;
8695 +} SceMpegAvcMode;
8697 +/**
8698 + * sceMpegInit
8700 + * @return 0 if success.
8701 + */
8702 +SceInt32 sceMpegInit();
8704 +/**
8705 + * sceMpegFinish
8706 + */
8707 +SceVoid sceMpegFinish();
8709 +/**
8710 + * sceMpegRingbufferQueryMemSize
8712 + * @param iPackets - number of packets in the ringbuffer
8714 + * @return < 0 if error else ringbuffer data size.
8715 + */
8716 +SceInt32 sceMpegRingbufferQueryMemSize(SceInt32 iPackets);
8718 +/**
8719 + * sceMpegRingbufferConstruct
8721 + * @param Ringbuffer - pointer to a sceMpegRingbuffer struct
8722 + * @param iPackets - number of packets in the ringbuffer
8723 + * @param pData - pointer to allocated memory
8724 + * @param iSize - size of allocated memory, shoud be sceMpegRingbufferQueryMemSize(iPackets)
8725 + * @param Callback - ringbuffer callback
8726 + * @param pCBparam - param passed to callback
8728 + * @return 0 if success.
8729 + */
8730 +SceInt32 sceMpegRingbufferConstruct(SceMpegRingbuffer* Ringbuffer, SceInt32 iPackets, ScePVoid pData, SceInt32 iSize, sceMpegRingbufferCB Callback, ScePVoid pCBparam);
8732 +/**
8733 + * sceMpegRingbufferDestruct
8735 + * @param Ringbuffer - pointer to a sceMpegRingbuffer struct
8736 + */
8737 +SceVoid sceMpegRingbufferDestruct(SceMpegRingbuffer* Ringbuffer);
8739 +/**
8740 + * sceMpegQueryMemSize
8742 + * @param Ringbuffer - pointer to a sceMpegRingbuffer struct
8744 + * @return < 0 if error else number of free packets in the ringbuffer.
8745 + */
8746 +SceInt32 sceMpegRingbufferAvailableSize(SceMpegRingbuffer* Ringbuffer);
8748 +/**
8749 + * sceMpegRingbufferPut
8751 + * @param Ringbuffer - pointer to a sceMpegRingbuffer struct
8752 + * @param iNumPackets - num packets to put into the ringbuffer
8753 + * @param iAvailable - free packets in the ringbuffer, should be sceMpegRingbufferAvailableSize()
8755 + * @return < 0 if error else number of packets.
8756 + */
8757 +SceInt32 sceMpegRingbufferPut(SceMpegRingbuffer* Ringbuffer, SceInt32 iNumPackets, SceInt32 iAvailable);
8759 +/**
8760 + * sceMpegQueryMemSize
8762 + * @param iUnk - Unknown, set to 0
8764 + * @return < 0 if error else decoder data size.
8765 + */
8766 +SceInt32 sceMpegQueryMemSize(int iUnk);
8768 +/**
8769 + * sceMpegCreate
8771 + * @param Mpeg - will be filled
8772 + * @param pData - pointer to allocated memory of size = sceMpegQueryMemSize()
8773 + * @param iSize - size of data, should be = sceMpegQueryMemSize()
8774 + * @param Ringbuffer - a ringbuffer
8775 + * @param iFrameWidth - display buffer width, set to 512 if writing to framebuffer
8776 + * @param iUnk1 - unknown, set to 0
8777 + * @param iUnk2 - unknown, set to 0
8779 + * @return 0 if success.
8780 + */
8781 +SceInt32 sceMpegCreate(SceMpeg* Mpeg, ScePVoid pData, SceInt32 iSize, SceMpegRingbuffer* Ringbuffer, SceInt32 iFrameWidth, SceInt32 iUnk1, SceInt32 iUnk2);
8783 +/**
8784 + * sceMpegDelete
8786 + * @param Mpeg - SceMpeg handle
8787 + */
8788 +SceVoid sceMpegDelete(SceMpeg* Mpeg);
8790 +/**
8791 + * sceMpegQueryStreamOffset
8793 + * @param Mpeg - SceMpeg handle
8794 + * @param pBuffer - pointer to file header
8795 + * @param iOffset - will contain stream offset in bytes, usually 2048
8797 + * @return 0 if success.
8798 + */
8799 +SceInt32 sceMpegQueryStreamOffset(SceMpeg* Mpeg, ScePVoid pBuffer, SceInt32* iOffset);
8801 +/**
8802 + * sceMpegQueryStreamSize
8804 + * @param pBuffer - pointer to file header
8805 + * @param iSize - will contain stream size in bytes
8807 + * @return 0 if success.
8808 + */
8809 +SceInt32 sceMpegQueryStreamSize(ScePVoid pBuffer, SceInt32* iSize);
8811 +/**
8812 + * sceMpegRegistStream
8814 + * @param Mpeg - SceMpeg handle
8815 + * @param iStreamID - stream id, 0 for video, 1 for audio
8816 + * @param iUnk - unknown, set to 0
8818 + * @return 0 if error.
8819 + */
8820 +SceMpegStream* sceMpegRegistStream(SceMpeg* Mpeg, SceInt32 iStreamID, SceInt32 iUnk);
8822 +/**
8823 + * sceMpegUnRegistStream
8825 + * @param Mpeg - SceMpeg handle
8826 + * @param pStream - pointer to stream
8827 + */
8828 +SceVoid sceMpegUnRegistStream(SceMpeg Mpeg, SceMpegStream* pStream);
8830 +/**
8831 + * sceMpegFlushAllStreams
8833 + * @return 0 if success.
8834 + */
8835 +SceInt32 sceMpegFlushAllStream(SceMpeg* Mpeg);
8837 +/**
8838 + * sceMpegMallocAvcEsBuf
8840 + * @return 0 if error else pointer to buffer.
8841 + */
8842 +ScePVoid sceMpegMallocAvcEsBuf(SceMpeg* Mpeg);
8844 +/**
8845 + * sceMpegFreeAvcEsBuf
8847 + */
8848 +SceVoid sceMpegFreeAvcEsBuf(SceMpeg* Mpeg, ScePVoid pBuf);
8850 +/**
8851 + * sceMpegQueryAtracEsSize
8853 + * @param Mpeg - SceMpeg handle
8854 + * @param iEsSize - will contain size of Es
8855 + * @param iOutSize - will contain size of decoded data
8857 + * @return 0 if success.
8858 + */
8859 +SceInt32 sceMpegQueryAtracEsSize(SceMpeg* Mpeg, SceInt32* iEsSize, SceInt32* iOutSize);
8861 +/**
8862 + * sceMpegInitAu
8864 + * @param Mpeg - SceMpeg handle
8865 + * @param pEsBuffer - prevously allocated Es buffer
8866 + * @param pAu - will contain pointer to Au
8868 + * @return 0 if success.
8869 + */
8870 +SceInt32 sceMpegInitAu(SceMpeg* Mpeg, ScePVoid pEsBuffer, SceMpegAu* pAu);
8872 +/**
8873 + * sceMpegGetAvcAu
8875 + * @param Mpeg - SceMpeg handle
8876 + * @param pStream - associated stream
8877 + * @param pAu - will contain pointer to Au
8878 + * @param iUnk - unknown
8880 + * @return 0 if success.
8881 + */
8882 +SceInt32 sceMpegGetAvcAu(SceMpeg* Mpeg, SceMpegStream* pStream, SceMpegAu* pAu, SceInt32* iUnk);
8884 +/**
8885 + * sceMpegAvcDecodeMode
8887 + * @param Mpeg - SceMpeg handle
8888 + * @param pMode - pointer to SceMpegAvcMode struct defining the decode mode (pixelformat)
8889 + * @return 0 if success.
8890 + */
8891 +SceInt32 sceMpegAvcDecodeMode(SceMpeg* Mpeg, SceMpegAvcMode* pMode);
8893 +/**
8894 + * sceMpegAvcDecode
8896 + * @param Mpeg - SceMpeg handle
8897 + * @param pAu - video Au
8898 + * @param iFrameWidth - output buffer width, set to 512 if writing to framebuffer
8899 + * @param pBuffer - buffer that will contain the decoded frame
8900 + * @param iInit - will be set to 0 on first call, then 1
8902 + * @return 0 if success.
8903 + */
8904 +SceInt32 sceMpegAvcDecode(SceMpeg* Mpeg, SceMpegAu* pAu, SceInt32 iFrameWidth, ScePVoid pBuffer, SceInt32* iInit);
8906 +/**
8907 + * sceMpegAvcDecodeStop
8909 + * @param Mpeg - SceMpeg handle
8910 + * @param iFrameWidth - output buffer width, set to 512 if writing to framebuffer
8911 + * @param pBuffer - buffer that will contain the decoded frame
8912 + * @param iStatus - frame number
8914 + * @return 0 if success.
8915 + */
8916 +SceInt32 sceMpegAvcDecodeStop(SceMpeg* Mpeg, SceInt32 iFrameWidth, ScePVoid pBuffer, SceInt32* iStatus);
8918 +/**
8919 + * sceMpegGetAtracAu
8921 + * @param Mpeg - SceMpeg handle
8922 + * @param pStream - associated stream
8923 + * @param pAu - will contain pointer to Au
8924 + * @param pUnk - unknown
8926 + * @return 0 if success.
8927 + */
8928 +SceInt32 sceMpegGetAtracAu(SceMpeg* Mpeg, SceMpegStream* pStream, SceMpegAu* pAu, ScePVoid pUnk);
8930 +/**
8931 + * sceMpegAtracDecode
8933 + * @param Mpeg - SceMpeg handle
8934 + * @param pAu - video Au
8935 + * @param pBuffer - buffer that will contain the decoded frame
8936 + * @param iInit - set this to 1 on first call
8938 + * @return 0 if success.
8939 + */
8940 +SceInt32 sceMpegAtracDecode(SceMpeg* Mpeg, SceMpegAu* pAu, ScePVoid pBuffer, SceInt32 iInit);
8942 +#ifdef __cplusplus
8944 +#endif
8946 +#endif
8947 diff --git a/newlib/psp/include/pspmpegbase.h b/newlib/psp/include/pspmpegbase.h
8948 new file mode 100644
8949 index 0000000..e7bc3b6
8950 --- /dev/null
8951 +++ b/newlib/psp/include/pspmpegbase.h
8952 @@ -0,0 +1,65 @@
8954 + * PSP Software Development Kit - https://github.com/pspdev
8955 + * -----------------------------------------------------------------------
8956 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
8958 + * pspmpegbase.h - Prototypes for the sceMpegbase library
8960 + * Copyright (c) 2006 Sorin P. C. <magik@hypermagik.com>
8961 + * Copyright (c) 2007 cooleyes
8962 + * Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
8964 + */
8966 +#ifndef __SCELIBMPEGBASE_H__
8967 +#define __SCELIBMPEGBASE_H__
8970 +#include <psptypes.h>
8973 +#ifdef __cplusplus
8974 +extern "C" {
8975 +#endif
8978 +typedef struct SceMpegLLI
8980 + ScePVoid pSrc;
8981 + ScePVoid pDst;
8982 + ScePVoid Next;
8983 + SceInt32 iSize;
8984 +} __attribute__((aligned(64))) SceMpegLLI;
8988 +typedef struct SceMpegYCrCbBuffer
8990 + SceInt32 iFrameBufferHeight16;
8991 + SceInt32 iFrameBufferWidth16;
8992 + SceInt32 iUnknown; // Set to 0
8993 + SceInt32 iUnknown2; // Set to 1
8994 + ScePVoid pYBuffer; // pointer to YBuffer (in VME EDRAM?)
8995 + ScePVoid pYBuffer2; // pointer to YBuffer + framebufferwidth*(frameheight/32)
8996 + ScePVoid pCrBuffer; // pointer to CrBuffer (in VME EDRAM?)
8997 + ScePVoid pCbBuffer; // pointer to CbBuffer (in VME EDRAM?)
8998 + ScePVoid pCrBuffer2; // pointer to CrBuffer + (framebufferwidth/2)*(frameheight/64)
8999 + ScePVoid pCbBuffer2; // pointer to CbBuffer + (framebufferwidth/2)*(frameheight/64)
9000 + SceInt32 iFrameHeight;
9001 + SceInt32 iFrameWidth;
9002 + SceInt32 iFrameBufferWidth;
9003 + SceInt32 iUnknown3[11];
9004 +} __attribute__((aligned(64))) SceMpegYCrCbBuffer;
9007 +SceInt32 sceMpegBaseYCrCbCopyVme(ScePVoid YUVBuffer, SceInt32 *Buffer, SceInt32 Type);
9008 +SceInt32 sceMpegBaseCscInit(SceInt32 width);
9009 +SceInt32 sceMpegBaseCscVme(ScePVoid pRGBbuffer, ScePVoid pRGBbuffer2, SceInt32 width, SceMpegYCrCbBuffer* pYCrCbBuffer);
9011 +SceInt32 sceMpegbase_BEA18F91(SceMpegLLI *pLLI);
9013 +#ifdef __cplusplus
9015 +#endif
9017 +#endif
9018 diff --git a/newlib/psp/include/pspmscm.h b/newlib/psp/include/pspmscm.h
9019 new file mode 100644
9020 index 0000000..69ed5b4
9021 --- /dev/null
9022 +++ b/newlib/psp/include/pspmscm.h
9023 @@ -0,0 +1,66 @@
9025 + * PSP Software Development Kit - https://github.com/pspdev
9026 + * -----------------------------------------------------------------------
9027 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
9029 + * pspmscm.h - Memory stick utility functions
9031 + * Copyright (c) 2006 Adrahil
9033 + */
9034 +#ifndef PSPMSCM_H
9035 +#define PSPMSCM_H
9037 +#ifdef __cplusplus
9038 +extern "C" {
9039 +#endif
9041 +/**
9042 + * Returns whether a memory stick is current inserted
9044 + * @return 1 if memory stick inserted, 0 if not or if < 0 on error
9045 + */
9046 +static __inline__ int MScmIsMediumInserted(void)
9048 + int status, ret;
9050 + ret = sceIoDevctl("mscmhc0:", 0x02025806, 0, 0, &status, sizeof(status));
9051 + if(ret < 0) return ret;
9052 + if(status != 1) return 0;
9054 + return 1;
9057 +/* Event which has occurred in the memory stick ejection callback, passed in arg2 */
9058 +#define MS_CB_EVENT_INSERTED 1
9059 +#define MS_CB_EVENT_EJECTED 2
9061 +/**
9062 + * Registers a memory stick ejection callback
9064 + * @param cbid - The uid of an allocated callback
9066 + * @return 0 on success, < 0 on error
9067 + */
9068 +static __inline__ int MScmRegisterMSInsertEjectCallback(SceUID cbid)
9070 + return sceIoDevctl("fatms0:", 0x02415821, &cbid, sizeof(cbid), 0, 0);
9073 +/**
9074 + * Unregister a memory stick ejection callback
9076 + * @param cbid - The uid of an allocated callback
9078 + * @return 0 on success, < 0 on error
9079 + */
9080 +static __inline__ int MScmUnregisterMSInsertEjectCallback(SceUID cbid)
9082 + return sceIoDevctl("fatms0:", 0x02415822, &cbid, sizeof(cbid), 0, 0);
9085 +#ifdef __cplusplus
9087 +#endif
9089 +#endif /* PSPMSCM_H */
9090 diff --git a/newlib/psp/include/pspnand_driver.h b/newlib/psp/include/pspnand_driver.h
9091 new file mode 100644
9092 index 0000000..de8b13e
9093 --- /dev/null
9094 +++ b/newlib/psp/include/pspnand_driver.h
9095 @@ -0,0 +1,75 @@
9097 + * PSP Software Development Kit - https://github.com/pspdev
9098 + * -----------------------------------------------------------------------
9099 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
9101 + * pspnand_driver.h - Definitions and interfaces to the NAND (flash) driver.
9103 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@0xd6.org>
9105 + */
9107 +#ifndef PSPNAND_DRIVER_H
9108 +#define PSPNAND_DRIVER_H
9110 +#include <pspkerneltypes.h>
9112 +#ifdef __cplusplus
9113 +extern "C" {
9114 +#endif
9116 +int sceNandSetWriteProtect(int protectFlag);
9118 +int sceNandLock(int writeFlag);
9120 +void sceNandUnlock(void);
9122 +int sceNandReadStatus(void);
9124 +int sceNandReset(int flag);
9126 +int sceNandReadId(void *buf, SceSize size);
9128 +int sceNandReadPages(u32 ppn, void *buf, void *buf2, u32 count);
9131 +// sceNandWritePages
9132 +// sceNandReadAccess
9133 +// sceNandWriteAccess
9134 +// sceNandEraseBlock
9135 +// sceNandReadExtraOnly
9136 +// sceNandCalcEcc
9137 +// sceNandVerifyEcc
9138 +// sceNandCollectEcc
9141 +int sceNandGetPageSize(void);
9143 +int sceNandGetPagesPerBlock(void);
9145 +int sceNandGetTotalBlocks(void);
9148 +// sceNandWriteBlock
9149 +// sceNandWriteBlockWithVerify
9152 +int sceNandReadBlockWithRetry(u32 ppn, void *buf, void *buf2);
9155 +// sceNandVerifyBlockWithRetry
9156 +// sceNandEraseBlockWithRetry
9159 +int sceNandIsBadBlock(u32 ppn);
9162 +// sceNandEraseAllBlock
9163 +// sceNandTestBlock
9166 +#ifdef __cplusplus
9168 +#endif
9170 +#endif /* PSPNAND_DRIVER_H */
9171 diff --git a/newlib/psp/include/pspnet.h b/newlib/psp/include/pspnet.h
9172 new file mode 100644
9173 index 0000000..55d5914
9174 --- /dev/null
9175 +++ b/newlib/psp/include/pspnet.h
9176 @@ -0,0 +1,106 @@
9178 + * PSP Software Development Kit - https://github.com/pspdev
9179 + * -----------------------------------------------------------------------
9180 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
9182 + * pspnet.h - PSP networking libraries.
9184 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@0xd6.org>
9185 + * Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
9187 + * Portions based on PspPet's wifi_03 sample code.
9188 + *
9189 + */
9191 +#ifndef PSPNET_H
9192 +#define PSPNET_H
9194 +#ifdef __cplusplus
9195 +extern "C" {
9196 +#endif
9198 +typedef struct SceNetMallocStat
9200 + int pool;
9201 + int maximum;
9202 + int free;
9204 +} SceNetMallocStat;
9206 +/**
9207 + * Initialise the networking library
9209 + * @param poolsize - Memory pool size (appears to be for the whole of the networking library).
9210 + * @param calloutprio - Priority of the SceNetCallout thread.
9211 + * @param calloutstack - Stack size of the SceNetCallout thread (defaults to 4096 on non 1.5 firmware regardless of what value is passed).
9212 + * @param netintrprio - Priority of the SceNetNetintr thread.
9213 + * @param netintrstack - Stack size of the SceNetNetintr thread (defaults to 4096 on non 1.5 firmware regardless of what value is passed).
9215 + * @return 0 on success, < 0 on error
9216 + */
9217 +int sceNetInit(int poolsize, int calloutprio, int calloutstack, int netintrprio, int netintrstack);
9219 +/**
9220 + * Terminate the networking library
9222 + * @return 0 on success, < 0 on error
9223 + */
9224 +int sceNetTerm(void);
9226 +/**
9227 + * Free (delete) thread info/data
9229 + * @param thid - The thread id.
9231 + * @return 0 on success, < 0 on error
9232 + */
9233 +int sceNetFreeThreadinfo(int thid);
9235 +/**
9236 + * Abort a thread
9238 + * @param thid - The thread id.
9240 + * @return 0 on success, < 0 on error
9241 + */
9242 +int sceNetThreadAbort(int thid);
9244 +/**
9245 + * Convert string to a Mac address
9247 + * @param name - The string to convert.
9248 + * @param mac - Pointer to a buffer to store the result.
9249 + */
9250 +void sceNetEtherStrton(char *name, unsigned char *mac);
9252 +/**
9253 + * Convert Mac address to a string
9255 + * @param mac - The Mac address to convert.
9256 + * @param name - Pointer to a buffer to store the result.
9257 + */
9258 +void sceNetEtherNtostr(unsigned char *mac, char *name);
9260 +/**
9261 + * Retrieve the local Mac address
9263 + * @param mac - Pointer to a buffer to store the result.
9265 + * @return 0 on success, < 0 on error
9266 + */
9267 +int sceNetGetLocalEtherAddr(unsigned char *mac);
9269 +/**
9270 + * Retrieve the networking library memory usage
9272 + * @param stat - Pointer to a ::SceNetMallocStat type to store the result.
9274 + * @return 0 on success, < 0 on error
9275 + */
9276 +int sceNetGetMallocStat(SceNetMallocStat *stat);
9278 +#ifdef __cplusplus
9280 +#endif
9282 +#endif /* PSPNET_H */
9283 diff --git a/newlib/psp/include/pspnet_adhoc.h b/newlib/psp/include/pspnet_adhoc.h
9284 new file mode 100644
9285 index 0000000..3e1fa6f
9286 --- /dev/null
9287 +++ b/newlib/psp/include/pspnet_adhoc.h
9288 @@ -0,0 +1,309 @@
9290 + * PSP Software Development Kit - https://github.com/pspdev
9291 + * -----------------------------------------------------------------------
9292 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
9294 + * pspnet_adhoc.h - PSP Adhoc networking libraries.
9296 + * Copyright (c) 2006 James F.
9297 + * Copyright (c) 2008 InsertWittyName <tias_dp@hotmail.com>
9299 + * Based on the adhoc code in SMS Plus
9300 + *
9301 + */
9302 +#ifndef __PSPNET_ADHOC_H__
9303 +#define __PSPNET_ADHOC_H__
9305 +#ifdef __cplusplus
9306 +extern "C" {
9307 +#endif
9309 +/**
9310 + * Initialise the adhoc library.
9312 + * @return 0 on success, < 0 on error
9313 + */
9314 +int sceNetAdhocInit(void);
9316 +/**
9317 + * Terminate the adhoc library
9319 + * @return 0 on success, < 0 on error
9320 + */
9321 +int sceNetAdhocTerm(void);
9323 +/**
9324 + * Create a PDP object.
9326 + * @param mac - Your MAC address (from sceWlanGetEtherAddr)
9327 + * @param port - Port to use, lumines uses 0x309
9328 + * @param bufsize - Socket buffer size, lumines sets to 0x400
9329 + * @param unk1 - Unknown, lumines sets to 0
9331 + * @return The ID of the PDP object (< 0 on error)
9332 + */
9333 +int sceNetAdhocPdpCreate(unsigned char *mac, unsigned short port, unsigned int bufsize, int unk1);
9335 +/**
9336 + * Delete a PDP object.
9338 + * @param id - The ID returned from ::sceNetAdhocPdpCreate
9339 + * @param unk1 - Unknown, set to 0
9341 + * @return 0 on success, < 0 on error
9342 + */
9343 +int sceNetAdhocPdpDelete(int id, int unk1);
9345 +/**
9346 + * Set a PDP packet to a destination
9348 + * @param id - The ID as returned by ::sceNetAdhocPdpCreate
9349 + * @param destMacAddr - The destination MAC address, can be set to all 0xFF for broadcast
9350 + * @param port - The port to send to
9351 + * @param data - The data to send
9352 + * @param len - The length of the data.
9353 + * @param timeout - Timeout in microseconds.
9354 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9356 + * @return Bytes sent, < 0 on error
9357 + */
9358 +int sceNetAdhocPdpSend(int id, unsigned char *destMacAddr, unsigned short port, void *data, unsigned int len, unsigned int timeout, int nonblock);
9360 +/**
9361 + * Receive a PDP packet
9363 + * @param id - The ID of the PDP object, as returned by ::sceNetAdhocPdpCreate
9364 + * @param srcMacAddr - Buffer to hold the source mac address of the sender
9365 + * @param port - Buffer to hold the port number of he received data
9366 + * @param data - Data buffer
9367 + * @param dataLength - The length of the data buffer
9368 + * @param timeout - Timeout in microseconds.
9369 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9371 + * @return Number of bytes received, < 0 on error.
9372 + */
9373 +int sceNetAdhocPdpRecv(int id, unsigned char *srcMacAddr, unsigned short *port, void *data, void *dataLength, unsigned int timeout, int nonblock);
9375 +/**
9376 + * PDP status structure
9377 + */
9378 +typedef struct pdpStatStruct
9380 + /** Pointer to next PDP structure in list */
9381 + struct pdpStatStruct *next;
9382 + /** pdp ID */
9383 + int pdpId;
9384 + /** MAC address */
9385 + unsigned char mac[6];
9386 + /** Port */
9387 + unsigned short port;
9388 + /** Bytes received */
9389 + unsigned int rcvdData;
9390 +} pdpStatStruct;
9392 +/**
9393 + * Get the status of all PDP objects
9395 + * @param size - Pointer to the size of the stat array (e.g 20 for one structure)
9396 + * @param stat - Pointer to a list of ::pdpStatStruct structures.
9398 + * @return 0 on success, < 0 on error
9399 + */
9400 +int sceNetAdhocGetPdpStat(int *size, pdpStatStruct *stat);
9402 +/**
9403 + * Create own game object type data.
9405 + * @param data - A pointer to the game object data.
9406 + * @param size - Size of the game data.
9408 + * @return 0 on success, < 0 on error.
9409 + */
9410 +int sceNetAdhocGameModeCreateMaster(void *data, int size);
9412 +/**
9413 + * Create peer game object type data.
9415 + * @param mac - The mac address of the peer.
9416 + * @param data - A pointer to the game object data.
9417 + * @param size - Size of the game data.
9419 + * @return The id of the replica on success, < 0 on error.
9420 + */
9421 +int sceNetAdhocGameModeCreateReplica(unsigned char *mac, void *data, int size);
9423 +/**
9424 + * Update own game object type data.
9426 + * @return 0 on success, < 0 on error.
9427 + */
9428 +int sceNetAdhocGameModeUpdateMaster(void);
9430 +/**
9431 + * Update peer game object type data.
9433 + * @param id - The id of the replica returned by sceNetAdhocGameModeCreateReplica.
9434 + * @param unk1 - Pass 0.
9436 + * @return 0 on success, < 0 on error.
9437 + */
9438 +int sceNetAdhocGameModeUpdateReplica(int id, int unk1);
9440 +/**
9441 + * Delete own game object type data.
9443 + * @return 0 on success, < 0 on error.
9444 + */
9445 +int sceNetAdhocGameModeDeleteMaster(void);
9447 +/**
9448 + * Delete peer game object type data.
9450 + * @param id - The id of the replica.
9452 + * @return 0 on success, < 0 on error.
9453 + */
9454 +int sceNetAdhocGameModeDeleteReplica(int id);
9456 +/**
9457 + * Open a PTP connection
9459 + * @param srcmac - Local mac address.
9460 + * @param srcport - Local port.
9461 + * @param destmac - Destination mac.
9462 + * @param destport - Destination port
9463 + * @param bufsize - Socket buffer size
9464 + * @param delay - Interval between retrying (microseconds).
9465 + * @param count - Number of retries.
9466 + * @param unk1 - Pass 0.
9468 + * @return A socket ID on success, < 0 on error.
9469 + */
9470 +int sceNetAdhocPtpOpen(unsigned char *srcmac, unsigned short srcport, unsigned char *destmac, unsigned short destport, unsigned int bufsize, unsigned int delay, int count, int unk1);
9472 +/**
9473 + * Wait for connection created by sceNetAdhocPtpOpen()
9475 + * @param id - A socket ID.
9476 + * @param timeout - Timeout in microseconds.
9477 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9479 + * @return 0 on success, < 0 on error.
9480 + */
9481 +int sceNetAdhocPtpConnect(int id, unsigned int timeout, int nonblock);
9483 +/**
9484 + * Wait for an incoming PTP connection
9486 + * @param srcmac - Local mac address.
9487 + * @param srcport - Local port.
9488 + * @param bufsize - Socket buffer size
9489 + * @param delay - Interval between retrying (microseconds).
9490 + * @param count - Number of retries.
9491 + * @param queue - Connection queue length.
9492 + * @param unk1 - Pass 0.
9494 + * @return A socket ID on success, < 0 on error.
9495 + */
9496 +int sceNetAdhocPtpListen(unsigned char *srcmac, unsigned short srcport, unsigned int bufsize, unsigned int delay, int count, int queue, int unk1);
9498 +/**
9499 + * Accept an incoming PTP connection
9501 + * @param id - A socket ID.
9502 + * @param mac - Connecting peers mac.
9503 + * @param port - Connecting peers port.
9504 + * @param timeout - Timeout in microseconds.
9505 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9507 + * @return 0 on success, < 0 on error.
9508 + */
9509 +int sceNetAdhocPtpAccept(int id, unsigned char *mac, unsigned short *port, unsigned int timeout, int nonblock);
9511 +/**
9512 + * Send data
9514 + * @param id - A socket ID.
9515 + * @param data - Data to send.
9516 + * @param datasize - Size of the data.
9517 + * @param timeout - Timeout in microseconds.
9518 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9520 + * @return 0 success, < 0 on error.
9521 + */
9522 +int sceNetAdhocPtpSend(int id, void *data, int *datasize, unsigned int timeout, int nonblock);
9524 +/**
9525 + * Receive data
9527 + * @param id - A socket ID.
9528 + * @param data - Buffer for the received data.
9529 + * @param datasize - Size of the data received.
9530 + * @param timeout - Timeout in microseconds.
9531 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9533 + * @return 0 on success, < 0 on error.
9534 + */
9535 +int sceNetAdhocPtpRecv(int id, void *data, int *datasize, unsigned int timeout, int nonblock);
9537 +/**
9538 + * Wait for data in the buffer to be sent
9540 + * @param id - A socket ID.
9541 + * @param timeout - Timeout in microseconds.
9542 + * @param nonblock - Set to 0 to block, 1 for non-blocking.
9544 + * @return A socket ID on success, < 0 on error.
9545 + */
9546 +int sceNetAdhocPtpFlush(int id, unsigned int timeout, int nonblock);
9548 +/**
9549 + * Close a socket
9551 + * @param id - A socket ID.
9552 + * @param unk1 - Pass 0.
9554 + * @return A socket ID on success, < 0 on error.
9555 + */
9556 +int sceNetAdhocPtpClose(int id, int unk1);
9558 +/**
9559 + * PTP status structure
9560 + */
9561 +typedef struct ptpStatStruct
9563 + /** Pointer to next PTP structure in list */
9564 + struct ptpStatStruct *next;
9565 + /** ptp ID */
9566 + int ptpId;
9567 + /** MAC address */
9568 + unsigned char mac[6];
9569 + /** Peer MAC address */
9570 + unsigned char peermac[6];
9571 + /** Port */
9572 + unsigned short port;
9573 + /** Peer Port */
9574 + unsigned short peerport;
9575 + /** Bytes sent */
9576 + unsigned int sentData;
9577 + /** Bytes received */
9578 + unsigned int rcvdData;
9579 + /** Unknown */
9580 + int unk1;
9581 +} ptpStatStruct;
9583 +/**
9584 + * Get the status of all PTP objects
9586 + * @param size - Pointer to the size of the stat array (e.g 20 for one structure)
9587 + * @param stat - Pointer to a list of ::ptpStatStruct structures.
9589 + * @return 0 on success, < 0 on error
9590 + */
9591 +int sceNetAdhocGetPtpStat(int *size, ptpStatStruct *stat);
9593 +#ifdef __cplusplus
9595 +#endif
9597 +#endif
9598 diff --git a/newlib/psp/include/pspnet_adhocctl.h b/newlib/psp/include/pspnet_adhocctl.h
9599 new file mode 100644
9600 index 0000000..f357322
9601 --- /dev/null
9602 +++ b/newlib/psp/include/pspnet_adhocctl.h
9603 @@ -0,0 +1,288 @@
9605 + * PSP Software Development Kit - https://github.com/pspdev
9606 + * -----------------------------------------------------------------------
9607 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
9609 + * pspnet_adhocctl.h - PSP Adhoc control networking libraries.
9611 + * Copyright (c) 2006 James F.
9612 + * Copyright (c) 2008 InsertWittyName <tias_dp@hotmail.com>
9614 + * Based on the adhoc code in SMS Plus
9615 + *
9616 + */
9617 +#ifndef __PSPNETCTL_ADHOC_H__
9618 +#define __PSPNETCTL_ADHOC_H__
9620 +#ifdef __cplusplus
9621 +extern "C" {
9622 +#endif
9624 +/** Product structure */
9625 +struct productStruct
9627 + /** Unknown, set to 0, other values used are 1 and 2. Not sure on what they represent */
9628 + int unknown;
9629 + /** The product ID string */
9630 + char product[9];
9631 + /* possibly padding */
9632 + char unk[3];
9635 +/** Peer info structure */
9636 +struct SceNetAdhocctlPeerInfo
9638 + struct SceNetAdhocctlPeerInfo *next;
9639 + /** Nickname */
9640 + char nickname[128];
9641 + /** Mac address */
9642 + unsigned char mac[6];
9643 + /** Unknown */
9644 + unsigned char unknown[6];
9645 + /** Time stamp */
9646 + unsigned long timestamp;
9649 +/** Scan info structure */
9650 +struct SceNetAdhocctlScanInfo
9652 + struct SceNetAdhocctlScanInfo *next;
9653 + /** Channel number */
9654 + int channel;
9655 + /** Name of the connection (alphanumeric characters only) */
9656 + char name[8];
9657 + /** The BSSID */
9658 + unsigned char bssid[6];
9659 + /** Unknown */
9660 + unsigned char unknown[2];
9661 + /** Unknown */
9662 + int unknown2;
9665 +struct SceNetAdhocctlGameModeInfo
9667 + /** Number of peers (including self) */
9668 + int count;
9669 + /** MAC addresses of peers (including self) */
9670 + unsigned char macs[16][6];
9673 +/** Params structure */
9674 +struct SceNetAdhocctlParams
9676 + /** Channel number */
9677 + int channel;
9678 + /** Name of the connection */
9679 + char name[8];
9680 + /** The BSSID */
9681 + unsigned char bssid[6];
9682 + /** Nickname */
9683 + char nickname[128];
9686 +/**
9687 + * Initialise the Adhoc control library
9689 + * @param stacksize - Stack size of the adhocctl thread. Set to 0x2000
9690 + * @param priority - Priority of the adhocctl thread. Set to 0x30
9691 + * @param product - Pass a filled in ::productStruct
9693 + * @return 0 on success, < 0 on error
9694 + */
9695 +int sceNetAdhocctlInit(int stacksize, int priority, struct productStruct *product);
9697 +/**
9698 + * Terminate the Adhoc control library
9700 + * @return 0 on success, < on error.
9701 + */
9702 +int sceNetAdhocctlTerm(void);
9704 +/**
9705 + * Connect to the Adhoc control
9707 + * @param name - The name of the connection (maximum 8 alphanumeric characters).
9709 + * @return 0 on success, < 0 on error.
9710 + */
9711 +int sceNetAdhocctlConnect(const char *name);
9713 +/**
9714 + * Disconnect from the Adhoc control
9716 + * @return 0 on success, < 0 on error
9717 + */
9718 +int sceNetAdhocctlDisconnect(void);
9720 +/**
9721 + * Get the state of the Adhoc control
9723 + * @param event - Pointer to an integer to receive the status. Can continue when it becomes 1.
9725 + * @return 0 on success, < 0 on error
9726 + */
9727 +int sceNetAdhocctlGetState(int *event);
9729 +/**
9730 + * Connect to the Adhoc control (as a host)
9732 + * @param name - The name of the connection (maximum 8 alphanumeric characters).
9734 + * @return 0 on success, < 0 on error.
9735 + */
9736 +int sceNetAdhocctlCreate(const char *name);
9738 +/**
9739 + * Connect to the Adhoc control (as a client)
9741 + * @param scaninfo - A valid ::SceNetAdhocctlScanInfo struct that has been filled by sceNetAchocctlGetScanInfo
9743 + * @return 0 on success, < 0 on error.
9744 + */
9745 +int sceNetAdhocctlJoin(struct SceNetAdhocctlScanInfo *scaninfo);
9747 +/**
9748 + * Get the adhoc ID
9750 + * @param product - A pointer to a ::productStruct
9752 + * @return 0 on success, < 0 on error.
9753 + */
9754 +int sceNetAdhocctlGetAdhocId(struct productStruct *product);
9756 +/**
9757 + * Connect to the Adhoc control game mode (as a host)
9759 + * @param name - The name of the connection (maximum 8 alphanumeric characters).
9760 + * @param unknown - Pass 1.
9761 + * @param num - The total number of players (including the host).
9762 + * @param macs - A pointer to a list of the participating mac addresses, host first, then clients.
9763 + * @param timeout - Timeout in microseconds.
9764 + * @param unknown2 - pass 0.
9766 + * @return 0 on success, < 0 on error.
9767 + */
9768 +int sceNetAdhocctlCreateEnterGameMode(const char *name, int unknown, int num, unsigned char *macs, unsigned int timeout, int unknown2);
9770 +/**
9771 + * Connect to the Adhoc control game mode (as a client)
9773 + * @param name - The name of the connection (maximum 8 alphanumeric characters).
9774 + * @param hostmac - The mac address of the host.
9775 + * @param timeout - Timeout in microseconds.
9776 + * @param unknown - pass 0.
9778 + * @return 0 on success, < 0 on error.
9779 + */
9780 +int sceNetAdhocctlJoinEnterGameMode(const char *name, unsigned char *hostmac, unsigned int timeout, int unknown);
9782 +/**
9783 + * Get game mode information
9785 + * @param gamemodeinfo - Pointer to store the info.
9787 + * @return 0 on success, < 0 on error.
9788 + */
9789 +int sceNetAdhocctlGetGameModeInfo(struct SceNetAdhocctlGameModeInfo *gamemodeinfo);
9791 +/**
9792 + * Exit game mode.
9794 + * @return 0 on success, < 0 on error.
9795 + */
9796 +int sceNetAdhocctlExitGameMode(void);
9798 +/**
9799 + * Get a list of peers
9801 + * @param length - The length of the list.
9802 + * @param buf - An allocated area of size length.
9804 + * @return 0 on success, < 0 on error.
9805 + */
9806 +int sceNetAdhocctlGetPeerList(int *length, void *buf);
9808 +/**
9809 + * Get peer information
9811 + * @param mac - The mac address of the peer.
9812 + * @param size - Size of peerinfo.
9813 + * @param peerinfo - Pointer to store the information.
9815 + * @return 0 on success, < 0 on error.
9816 + */
9817 +int sceNetAdhocctlGetPeerInfo(unsigned char *mac, int size, struct SceNetAdhocctlPeerInfo *peerinfo);
9819 +/**
9820 + * Scan the adhoc channels
9822 + * @return 0 on success, < 0 on error.
9823 + */
9824 +int sceNetAdhocctlScan(void);
9826 +/**
9827 + * Get the results of a scan
9829 + * @param length - The length of the list.
9830 + * @param buf - An allocated area of size length.
9832 + * @return 0 on success, < 0 on error.
9833 + */
9834 +int sceNetAdhocctlGetScanInfo(int *length, void *buf);
9836 +typedef void (*sceNetAdhocctlHandler)(int flag, int error, void *unknown);
9838 +/**
9839 + * Register an adhoc event handler
9841 + * @param handler - The event handler.
9842 + * @param unknown - Pass NULL.
9844 + * @return Handler id on success, < 0 on error.
9845 + */
9846 +int sceNetAdhocctlAddHandler(sceNetAdhocctlHandler handler, void *unknown);
9848 +/**
9849 + * Delete an adhoc event handler
9851 + * @param id - The handler id as returned by sceNetAdhocctlAddHandler.
9853 + * @return 0 on success, < 0 on error.
9854 + */
9855 +int sceNetAdhocctlDelHandler(int id);
9857 +/**
9858 + * Get nickname from a mac address
9860 + * @param mac - The mac address.
9861 + * @param nickname - Pointer to a char buffer where the nickname will be stored.
9863 + * @return 0 on success, < 0 on error.
9864 + */
9865 +int sceNetAdhocctlGetNameByAddr(unsigned char *mac, char *nickname);
9867 +/**
9868 + * Get mac address from nickname
9870 + * @param nickname - The nickname.
9871 + * @param length - The length of the list.
9872 + * @param buf - An allocated area of size length.
9874 + * @return 0 on success, < 0 on error.
9875 + */
9876 +int sceNetAdhocctlGetAddrByName(char *nickname, int *length, void *buf);
9878 +/**
9879 + * Get Adhocctl parameter
9881 + * @param params - Pointer to a ::SceNetAdhocctlParams
9883 + * @return 0 on success, < 0 on error.
9884 + */
9885 +int sceNetAdhocctlGetParameter(struct SceNetAdhocctlParams *params);
9887 +#ifdef __cplusplus
9889 +#endif
9891 +#endif
9892 diff --git a/newlib/psp/include/pspnet_adhocmatching.h b/newlib/psp/include/pspnet_adhocmatching.h
9893 new file mode 100644
9894 index 0000000..b361056
9895 --- /dev/null
9896 +++ b/newlib/psp/include/pspnet_adhocmatching.h
9897 @@ -0,0 +1,268 @@
9899 + * PSP Software Development Kit - https://github.com/pspdev
9900 + * -----------------------------------------------------------------------
9901 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
9903 + * pspnet_adhocmatching.h - PSP Adhoc matching networking libraries.
9905 + * Copyright (c) 2006 James F.
9906 + * Copyright (c) 2008 InsertWittyName <tias_dp@hotmail.com>
9908 + * Based on the adhoc code in SMS Plus
9909 + *
9910 + */
9911 +#ifndef __PSPNETMATCHING_ADHOC_H__
9912 +#define __PSPNETMATCHING_ADHOC_H__
9914 +#ifdef __cplusplus
9915 +extern "C" {
9916 +#endif
9918 +/**
9919 + * Matching events used in pspAdhocMatchingCallback
9920 + */
9921 +enum pspAdhocMatchingEvents
9923 + /** Hello event. optdata contains data if optlen > 0. */
9924 + PSP_ADHOC_MATCHING_EVENT_HELLO = 1,
9925 + /** Join request. optdata contains data if optlen > 0. */
9926 + PSP_ADHOC_MATCHING_EVENT_JOIN = 2,
9927 + /** Target left matching. */
9928 + PSP_ADHOC_MATCHING_EVENT_LEFT = 3,
9929 + /** Join request rejected. */
9930 + PSP_ADHOC_MATCHING_EVENT_REJECT = 4,
9931 + /** Join request cancelled. */
9932 + PSP_ADHOC_MATCHING_EVENT_CANCEL = 5,
9933 + /** Join request accepted. optdata contains data if optlen > 0. */
9934 + PSP_ADHOC_MATCHING_EVENT_ACCEPT = 6,
9935 + /** Matching is complete. */
9936 + PSP_ADHOC_MATCHING_EVENT_COMPLETE = 7,
9937 + /** Ping timeout event. */
9938 + PSP_ADHOC_MATCHING_EVENT_TIMEOUT = 8,
9939 + /** Error event. */
9940 + PSP_ADHOC_MATCHING_EVENT_ERROR = 9,
9941 + /** Peer disconnect event. */
9942 + PSP_ADHOC_MATCHING_EVENT_DISCONNECT = 10,
9943 + /** Data received event. optdata contains data if optlen > 0. */
9944 + PSP_ADHOC_MATCHING_EVENT_DATA = 11,
9945 + /** Data acknowledged event. */
9946 + PSP_ADHOC_MATCHING_EVENT_DATA_CONFIRM = 12,
9947 + /** Data timeout event. */
9948 + PSP_ADHOC_MATCHING_EVENT_DATA_TIMEOUT = 13
9951 +/**
9952 + * Matching modes used in sceNetAdhocMatchingCreate
9953 + */
9954 +enum pspAdhocMatchingModes
9956 + /** Host */
9957 + PSP_ADHOC_MATCHING_MODE_HOST = 1,
9958 + /** Client */
9959 + PSP_ADHOC_MATCHING_MODE_CLIENT = 2,
9960 + /** Peer to peer */
9961 + PSP_ADHOC_MATCHING_MODE_PTP = 3
9964 +/**
9965 + * Linked list for sceNetAdhocMatchingGetMembers
9966 + */
9967 +struct pspAdhocMatchingMember
9969 + struct pspAdhocMatchingMember *next;
9970 + unsigned char mac[6];
9971 + char unknown[2];
9974 +/**
9975 + * Linked list for sceNetAdhocMatchingGetMembers
9976 + */
9977 +struct pspAdhocPoolStat
9979 + /** Size of the pool */
9980 + int size;
9981 + /** Maximum size of the pool */
9982 + int maxsize;
9983 + /** Unused memory in the pool */
9984 + int freesize;
9987 +/**
9988 + * Initialise the Adhoc matching library
9990 + * @param memsize - Internal memory pool size. Lumines uses 0x20000
9991 + *
9992 + * @return 0 on success, < 0 on error
9993 + */
9994 +int sceNetAdhocMatchingInit(int memsize);
9996 +/**
9997 + * Terminate the Adhoc matching library
9999 + * @return 0 on success, < 0 on error
10000 + */
10001 +int sceNetAdhocMatchingTerm(void);
10003 +/** Matching callback */
10004 +typedef void (*pspAdhocMatchingCallback)(int matchingid, int event, unsigned char *mac, int optlen, void *optdata);
10006 +/**
10007 + * Create an Adhoc matching object
10009 + * @param mode - One of ::pspAdhocMatchingModes
10010 + * @param maxpeers - Maximum number of peers to match (only used when mode is PSP_ADHOC_MATCHING_MODE_HOST)
10011 + * @param port - Port. Lumines uses 0x22B
10012 + * @param bufsize - Receiving buffer size
10013 + * @param hellodelay - Hello message send delay in microseconds (only used when mode is PSP_ADHOC_MATCHING_MODE_HOST or PSP_ADHOC_MATCHING_MODE_PTP)
10014 + * @param pingdelay - Ping send delay in microseconds. Lumines uses 0x5B8D80 (only used when mode is PSP_ADHOC_MATCHING_MODE_HOST or PSP_ADHOC_MATCHING_MODE_PTP)
10015 + * @param initcount - Initial count of the of the resend counter. Lumines uses 3
10016 + * @param msgdelay - Message send delay in microseconds
10017 + * @param callback - Callback to be called for matching
10019 + * @return ID of object on success, < 0 on error.
10020 + */
10021 +int sceNetAdhocMatchingCreate(int mode, int maxpeers, unsigned short port, int bufsize, unsigned int hellodelay, unsigned int pingdelay, int initcount, unsigned int msgdelay, pspAdhocMatchingCallback callback);
10023 +/**
10024 + * Delete an Adhoc matching object
10026 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10028 + * @return 0 on success, < 0 on error.
10029 + */
10030 +int sceNetAdhocMatchingDelete(int matchingid);
10032 +/**
10033 + * Start a matching object
10035 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10036 + * @param evthpri - Priority of the event handler thread. Lumines uses 0x10
10037 + * @param evthstack - Stack size of the event handler thread. Lumines uses 0x2000
10038 + * @param inthpri - Priority of the input handler thread. Lumines uses 0x10
10039 + * @param inthstack - Stack size of the input handler thread. Lumines uses 0x2000
10040 + * @param optlen - Size of hellodata
10041 + * @param optdata - Pointer to block of data passed to callback
10043 + * @return 0 on success, < 0 on error
10044 + */
10045 +int sceNetAdhocMatchingStart(int matchingid, int evthpri, int evthstack, int inthpri, int inthstack, int optlen, void *optdata);
10047 +/**
10048 + * Stop a matching object
10050 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10052 + * @return 0 on success, < 0 on error.
10053 + */
10054 +int sceNetAdhocMatchingStop(int matchingid);
10056 +/**
10057 + * Select a matching target
10059 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10060 + * @param mac - MAC address to select
10061 + * @param optlen - Optional data length
10062 + * @param optdata - Pointer to the optional data
10064 + * @return 0 on success, < 0 on error.
10065 + */
10066 +int sceNetAdhocMatchingSelectTarget(int matchingid, unsigned char *mac, int optlen, void *optdata);
10068 +/**
10069 + * Cancel a matching target
10071 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10072 + * @param mac - The MAC address to cancel
10074 + * @return 0 on success, < 0 on error.
10075 + */
10076 +int sceNetAdhocMatchingCancelTarget(int matchingid, unsigned char *mac);
10078 +/**
10079 + * Cancel a matching target (with optional data)
10081 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10082 + * @param mac - The MAC address to cancel
10083 + * @param optlen - Optional data length
10084 + * @param optdata - Pointer to the optional data
10086 + * @return 0 on success, < 0 on error.
10087 + */
10088 +int sceNetAdhocMatchingCancelTargetWithOpt(int matchingid, unsigned char *mac, int optlen, void *optdata);
10090 +/**
10091 + * Send data to a matching target
10093 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10094 + * @param mac - The MAC address to send the data to
10095 + * @param datalen - Length of the data
10096 + * @param data - Pointer to the data
10098 + * @return 0 on success, < 0 on error.
10099 + */
10100 +int sceNetAdhocMatchingSendData(int matchingid, unsigned char *mac, int datalen, void *data);
10102 +/**
10103 + * Abort a data send to a matching target
10105 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10106 + * @param mac - The MAC address to send the data to
10108 + * @return 0 on success, < 0 on error.
10109 + */
10110 +int sceNetAdhocMatchingAbortSendData(int matchingid, unsigned char *mac);
10112 +/**
10113 + * Set the optional hello message
10115 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10116 + * @param optlen - Length of the hello data
10117 + * @param optdata - Pointer to the hello data
10119 + * @return 0 on success, < 0 on error.
10120 + */
10121 +int sceNetAdhocMatchingSetHelloOpt(int matchingid, int optlen, void *optdata);
10123 +/**
10124 + * Get the optional hello message
10126 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10127 + * @param optlen - Length of the hello data
10128 + * @param optdata - Pointer to the hello data
10130 + * @return 0 on success, < 0 on error.
10131 + */
10132 +int sceNetAdhocMatchingGetHelloOpt(int matchingid, int *optlen, void *optdata);
10134 +/**
10135 + * Get a list of matching members
10137 + * @param matchingid - The ID returned from ::sceNetAdhocMatchingCreate
10138 + * @param length - The length of the list.
10139 + * @param buf - An allocated area of size length.
10141 + * @return 0 on success, < 0 on error.
10142 + */
10143 +int sceNetAdhocMatchingGetMembers(int matchingid, int *length, void *buf);
10145 +/**
10146 + * Get the maximum memory usage by the matching library
10148 + * @return The memory usage on success, < 0 on error.
10149 + */
10150 +int sceNetAdhocMatchingGetPoolMaxAlloc(void);
10152 +/**
10153 + * Get the status of the memory pool used by the matching library
10155 + * @param poolstat - A ::pspAdhocPoolStat.
10157 + * @return 0 on success, < 0 on error.
10158 + */
10159 +int sceNetAdhocMatchingGetPoolStat(struct pspAdhocPoolStat *poolstat);
10161 +#ifdef __cplusplus
10163 +#endif
10165 +#endif
10166 diff --git a/newlib/psp/include/pspnet_apctl.h b/newlib/psp/include/pspnet_apctl.h
10167 new file mode 100644
10168 index 0000000..9bcce95
10169 --- /dev/null
10170 +++ b/newlib/psp/include/pspnet_apctl.h
10171 @@ -0,0 +1,170 @@
10173 + * PSP Software Development Kit - https://github.com/pspdev
10174 + * -----------------------------------------------------------------------
10175 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10177 + * pspnet_apctl.h - PSP networking libraries.
10179 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@0xd6.org>
10180 + * Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
10182 + * Portions based on PspPet's wifi_03 sample code.
10183 + *
10184 + */
10186 +#ifndef PSPNET_APCTL_H
10187 +#define PSPNET_APCTL_H
10189 +#ifdef __cplusplus
10190 +extern "C" {
10191 +#endif
10193 +#define PSP_NET_APCTL_STATE_DISCONNECTED 0
10194 +#define PSP_NET_APCTL_STATE_SCANNING 1
10195 +#define PSP_NET_APCTL_STATE_JOINING 2
10196 +#define PSP_NET_APCTL_STATE_GETTING_IP 3
10197 +#define PSP_NET_APCTL_STATE_GOT_IP 4
10198 +#define PSP_NET_APCTL_STATE_EAP_AUTH 5
10199 +#define PSP_NET_APCTL_STATE_KEY_EXCHANGE 6
10201 +#define PSP_NET_APCTL_EVENT_CONNECT_REQUEST 0
10202 +#define PSP_NET_APCTL_EVENT_SCAN_REQUEST 1
10203 +#define PSP_NET_APCTL_EVENT_SCAN_COMPLETE 2
10204 +#define PSP_NET_APCTL_EVENT_ESTABLISHED 3
10205 +#define PSP_NET_APCTL_EVENT_GET_IP 4
10206 +#define PSP_NET_APCTL_EVENT_DISCONNECT_REQUEST 5
10207 +#define PSP_NET_APCTL_EVENT_ERROR 6
10208 +#define PSP_NET_APCTL_EVENT_INFO 7
10209 +#define PSP_NET_APCTL_EVENT_EAP_AUTH 8
10210 +#define PSP_NET_APCTL_EVENT_KEY_EXCHANGE 9
10211 +#define PSP_NET_APCTL_EVENT_RECONNECT 10
10213 +#define PSP_NET_APCTL_INFO_PROFILE_NAME 0
10214 +#define PSP_NET_APCTL_INFO_BSSID 1
10215 +#define PSP_NET_APCTL_INFO_SSID 2
10216 +#define PSP_NET_APCTL_INFO_SSID_LENGTH 3
10217 +#define PSP_NET_APCTL_INFO_SECURITY_TYPE 4
10218 +#define PSP_NET_APCTL_INFO_STRENGTH 5
10219 +#define PSP_NET_APCTL_INFO_CHANNEL 6
10220 +#define PSP_NET_APCTL_INFO_POWER_SAVE 7
10221 +#define PSP_NET_APCTL_INFO_IP 8
10222 +#define PSP_NET_APCTL_INFO_SUBNETMASK 9
10223 +#define PSP_NET_APCTL_INFO_GATEWAY 10
10224 +#define PSP_NET_APCTL_INFO_PRIMDNS 11
10225 +#define PSP_NET_APCTL_INFO_SECDNS 12
10226 +#define PSP_NET_APCTL_INFO_USE_PROXY 13
10227 +#define PSP_NET_APCTL_INFO_PROXY_URL 14
10228 +#define PSP_NET_APCTL_INFO_PROXY_PORT 15
10229 +#define PSP_NET_APCTL_INFO_8021_EAP_TYPE 16
10230 +#define PSP_NET_APCTL_INFO_START_BROWSER 17
10231 +#define PSP_NET_APCTL_INFO_WIFISP 18
10233 +#define PSP_NET_APCTL_INFO_SECURITY_TYPE_NONE 0
10234 +#define PSP_NET_APCTL_INFO_SECURITY_TYPE_WEP 1
10235 +#define PSP_NET_APCTL_INFO_SECURITY_TYPE_WPA 2
10237 +union SceNetApctlInfo
10239 + char name[64]; /* Name of the config used */
10240 + unsigned char bssid[6]; /* MAC address of the access point */
10241 + unsigned char ssid[32]; /* ssid */
10242 + unsigned int ssidLength; /* ssid string length*/
10243 + unsigned int securityType; /* 0 for none, 1 for WEP, 2 for WPA) */
10244 + unsigned char strength; /* Signal strength in % */
10245 + unsigned char channel; /* Channel */
10246 + unsigned char powerSave; /* 1 on, 0 off */
10247 + char ip[16]; /* PSP's ip */
10248 + char subNetMask[16]; /* Subnet mask */
10249 + char gateway[16]; /* Gateway */
10250 + char primaryDns[16]; /* Primary DNS */
10251 + char secondaryDns[16]; /* Secondary DNS */
10252 + unsigned int useProxy; /* 1 for proxy, 0 for no proxy */
10253 + char proxyUrl[128]; /* Proxy url */
10254 + unsigned short proxyPort; /* Proxy port */
10255 + unsigned int eapType; /* 0 is none, 1 is EAP-MD5 */
10256 + unsigned int startBrowser; /* Should browser be started */
10257 + unsigned int wifisp; /* 1 if connection is for Wifi service providers (WISP) */
10261 +typedef void (*sceNetApctlHandler)(int oldState, int newState, int event, int error, void *pArg);
10263 +/**
10264 + * Init the apctl.
10266 + * @param stackSize - The stack size of the internal thread.
10268 + * @param initPriority - The priority of the internal thread.
10270 + * @return < 0 on error.
10271 + */
10272 +int sceNetApctlInit(int stackSize, int initPriority);
10274 +/**
10275 + * Terminate the apctl.
10277 + * @return < 0 on error.
10278 + */
10279 +int sceNetApctlTerm(void);
10281 +/**
10282 + * Get the apctl information.
10284 + * @param code - One of the PSP_NET_APCTL_INFO_* defines.
10286 + * @param pInfo - Pointer to a ::SceNetApctlInfo.
10288 + * @return < 0 on error.
10289 + */
10290 +int sceNetApctlGetInfo(int code, union SceNetApctlInfo *pInfo);
10292 +/**
10293 + * Add an apctl event handler.
10295 + * @param handler - Pointer to the event handler function.
10297 + * @param pArg - Value to be passed to the pArg parameter of the handler function.
10299 + * @return A handler id or < 0 on error.
10300 + */
10301 +int sceNetApctlAddHandler(sceNetApctlHandler handler, void *pArg);
10303 +/**
10304 + * Delete an apctl event handler.
10306 + * @param handlerId - A handler as created returned from sceNetApctlAddHandler.
10308 + * @return < 0 on error.
10309 + */
10310 +int sceNetApctlDelHandler(int handlerId);
10312 +/**
10313 + * Connect to an access point.
10315 + * @param connIndex - The index of the connection.
10317 + * @return < 0 on error.
10318 + */
10319 +int sceNetApctlConnect(int connIndex);
10321 +/**
10322 + * Disconnect from an access point.
10324 + * @return < 0 on error.
10325 + */
10326 +int sceNetApctlDisconnect(void);
10328 +/**
10329 + * Get the state of the access point connection.
10331 + * @param pState - Pointer to receive the current state (one of the PSP_NET_APCTL_STATE_* defines).
10333 + * @return < 0 on error.
10334 + */
10335 +int sceNetApctlGetState(int *pState);
10337 +#ifdef __cplusplus
10339 +#endif
10341 +#endif /* PSPNET_APCTL_H */
10342 diff --git a/newlib/psp/include/pspnet_inet.h b/newlib/psp/include/pspnet_inet.h
10343 new file mode 100644
10344 index 0000000..a4bb6a0
10345 --- /dev/null
10346 +++ b/newlib/psp/include/pspnet_inet.h
10347 @@ -0,0 +1,59 @@
10349 + * PSP Software Development Kit - https://github.com/pspdev
10350 + * -----------------------------------------------------------------------
10351 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10353 + * pspnet_inet.h - PSP networking libraries.
10355 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@0xd6.org>
10357 + * Portions based on PspPet's wifi_03 sample code.
10358 + *
10359 + */
10361 +#ifndef PSPNET_INET_H
10362 +#define PSPNET_INET_H
10364 +#ifdef __cplusplus
10365 +extern "C" {
10366 +#endif
10368 +#include <sys/socket.h>
10370 +/**
10371 + * This struct is needed because tv_sec size is different from what newlib expect
10372 + * Newlib expects 64bits for seconds and PSP expects 32bits
10373 + */
10374 +struct SceNetInetTimeval {
10375 + uint32_t tv_sec;
10376 + uint32_t tv_usec;
10379 +int sceNetInetInit(void);
10380 +int sceNetInetSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct SceNetInetTimeval *timeout);
10381 +int sceNetInetTerm(void);
10382 +int sceNetInetGetErrno(void);
10383 +int sceNetInetAccept(int s, struct sockaddr *addr, socklen_t *addrlen);
10384 +int sceNetInetBind(int s, const struct sockaddr *my_addr, socklen_t addrlen);
10385 +int sceNetInetConnect(int s, const struct sockaddr *serv_addr, socklen_t addrlen);
10386 +int sceNetInetGetsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
10387 +int sceNetInetListen(int s, int backlog);
10388 +size_t sceNetInetRecv(int s, void *buf, size_t len, int flags);
10389 +size_t sceNetInetRecvfrom(int s, void *buf, size_t flags, int, struct sockaddr *from, socklen_t *fromlen);
10390 +size_t sceNetInetSend(int s, const void *buf, size_t len, int flags);
10391 +size_t sceNetInetSendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
10392 +int sceNetInetSetsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
10393 +int sceNetInetShutdown(int s, int how);
10394 +int sceNetInetSocket(int domain, int type, int protocol);
10395 +int sceNetInetClose(int s);
10396 +int sceNetInetGetErrno(void);
10397 +int sceNetInetGetpeername(int s, struct sockaddr *name, socklen_t *namelen);
10398 +int sceNetInetGetsockname(int s, struct sockaddr *name, socklen_t *namelen);
10399 +ssize_t sceNetInetSendmsg(int s, const struct msghdr *msg, int flags);
10400 +ssize_t sceNetInetRecvmsg(int s, struct msghdr *msg, int flags);
10402 +#ifdef __cplusplus
10404 +#endif
10406 +#endif /* PSPNET_INET_H */
10407 diff --git a/newlib/psp/include/pspnet_resolver.h b/newlib/psp/include/pspnet_resolver.h
10408 new file mode 100644
10409 index 0000000..df0ff28
10410 --- /dev/null
10411 +++ b/newlib/psp/include/pspnet_resolver.h
10412 @@ -0,0 +1,97 @@
10414 + * PSP Software Development Kit - https://github.com/pspdev
10415 + * -----------------------------------------------------------------------
10416 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10418 + * pspnet_resolver.h - PSP networking libraries.
10420 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@0xd6.org>
10422 + * Portions based on PspPet's wifi_03 sample code.
10423 + *
10424 + */
10426 +#ifndef PSPNET_RESOLVER_H
10427 +#define PSPNET_RESOLVER_H
10429 +#ifdef __cplusplus
10430 +extern "C" {
10431 +#endif
10433 +#include <netinet/in.h>
10435 +/**
10436 + * Inititalise the resolver library
10438 + * @return 0 on sucess, < 0 on error.
10439 + */
10440 +int sceNetResolverInit(void);
10442 +/**
10443 + * Create a resolver object
10445 + * @param rid - Pointer to receive the resolver id
10446 + * @param buf - Temporary buffer
10447 + * @param buflen - Length of the temporary buffer
10449 + * @return 0 on success, < 0 on error
10450 + */
10451 +int sceNetResolverCreate(int *rid, void *buf, SceSize buflen);
10453 +/**
10454 + * Delete a resolver
10456 + * @param rid - The resolver to delete
10458 + * @return 0 on success, < 0 on error
10459 + */
10460 +int sceNetResolverDelete(int rid);
10462 +/**
10463 + * Begin a name to address lookup
10465 + * @param rid - Resolver id
10466 + * @param hostname - Name to resolve
10467 + * @param addr - Pointer to in_addr structure to receive the address
10468 + * @param timeout - Number of seconds before timeout
10469 + * @param retry - Number of retires
10471 + * @return 0 on success, < 0 on error
10472 + */
10473 +int sceNetResolverStartNtoA(int rid, const char *hostname, struct in_addr* addr, unsigned int timeout, int retry);
10475 +/**
10476 + * Begin a address to name lookup
10478 + * @param rid -Resolver id
10479 + * @param addr - Pointer to the address to resolve
10480 + * @param hostname - Buffer to receive the name
10481 + * @param hostname_len - Length of the buffer
10482 + * @param timeout - Number of seconds before timeout
10483 + * @param retry - Number of retries
10485 + * @return 0 on success, < 0 on error
10486 + */
10487 +int sceNetResolverStartAtoN(int rid, const struct in_addr* addr, char *hostname, SceSize hostname_len, unsigned int timeout, int retry);
10489 +/**
10490 + * Stop a resolver operation
10491 + *
10492 + * @param rid - Resolver id
10493 + *
10494 + * @return 0 on success, < 0 on error
10495 + */
10496 +int sceNetResolverStop(int rid);
10498 +/**
10499 + * Terminate the resolver library
10501 + * @return 0 on success, < 0 on error
10502 + */
10503 +int sceNetResolverTerm(void);
10505 +#ifdef __cplusplus
10507 +#endif
10509 +#endif /* PSPNET_RESOLVER_H */
10510 diff --git a/newlib/psp/include/pspopenpsid.h b/newlib/psp/include/pspopenpsid.h
10511 new file mode 100644
10512 index 0000000..949924b
10513 --- /dev/null
10514 +++ b/newlib/psp/include/pspopenpsid.h
10515 @@ -0,0 +1,30 @@
10517 + * PSP Software Development Kit - https://github.com/pspdev
10518 + * -----------------------------------------------------------------------
10519 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10521 + * pspopenpsid.h - Prototypes for the OpenPSID library
10523 + * Copyright (c) 2008 InsertWittyName (David Perry)
10525 + */
10527 +#ifndef __PSPOPENPSID_H__
10528 +#define __PSPOPENPSID_H__
10530 +#ifdef __cplusplus
10531 +extern "C" {
10532 +#endif
10534 +typedef struct PspOpenPSID
10536 + unsigned char data[16];
10537 +} PspOpenPSID;
10539 +int sceOpenPSIDGetOpenPSID(PspOpenPSID *openpsid);
10541 +#ifdef __cplusplus
10543 +#endif
10545 +#endif /* __PSPOPENPSID_H__ */
10546 diff --git a/newlib/psp/include/psppower.h b/newlib/psp/include/psppower.h
10547 new file mode 100644
10548 index 0000000..bbd3766
10549 --- /dev/null
10550 +++ b/newlib/psp/include/psppower.h
10551 @@ -0,0 +1,279 @@
10553 + * PSP Software Development Kit - https://github.com/pspdev
10554 + * -----------------------------------------------------------------------
10555 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10557 + * psppower.h - Prototypes for the scePower library.
10559 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
10560 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
10561 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
10562 + * Copyright (c) 2005 David Perry <tias_dp@hotmail.com>
10564 + */
10565 +#ifndef __POWER_H__
10566 +#define __POWER_H__
10568 +#include <pspkerneltypes.h>
10570 +#ifdef __cplusplus
10571 +extern "C" {
10572 +#endif
10574 +/**
10575 + * Power callback flags
10576 + */
10577 + /*indicates the power switch it pushed, putting the unit into suspend mode*/
10578 +#define PSP_POWER_CB_POWER_SWITCH 0x80000000
10579 +/*indicates the hold switch is on*/
10580 +#define PSP_POWER_CB_HOLD_SWITCH 0x40000000
10581 +/*what is standby mode?*/
10582 +#define PSP_POWER_CB_STANDBY 0x00080000
10583 +/*indicates the resume process has been completed (only seems to be triggered when another event happens)*/
10584 +#define PSP_POWER_CB_RESUME_COMPLETE 0x00040000
10585 +/*indicates the unit is resuming from suspend mode*/
10586 +#define PSP_POWER_CB_RESUMING 0x00020000
10587 +/*indicates the unit is suspending, seems to occur due to inactivity*/
10588 +#define PSP_POWER_CB_SUSPENDING 0x00010000
10589 +/*indicates the unit is plugged into an AC outlet*/
10590 +#define PSP_POWER_CB_AC_POWER 0x00001000
10591 +/*indicates the battery charge level is low*/
10592 +#define PSP_POWER_CB_BATTERY_LOW 0x00000100
10593 +/*indicates there is a battery present in the unit*/
10594 +#define PSP_POWER_CB_BATTERY_EXIST 0x00000080
10595 +/*unknown*/
10596 +#define PSP_POWER_CB_BATTPOWER 0x0000007F
10598 +/**
10599 + * Power tick flags
10600 + */
10601 +/* All */
10602 +#define PSP_POWER_TICK_ALL 0
10603 +/* Suspend */
10604 +#define PSP_POWER_TICK_SUSPEND 1
10605 +/* Display */
10606 +#define PSP_POWER_TICK_DISPLAY 6
10608 +/**
10609 + * Power Callback Function Definition
10611 + * @param unknown - unknown function, appears to cycle between 1,2 and 3
10612 + * @param powerInfo - combination of PSP_POWER_CB_ flags
10613 + */
10614 +typedef void (*powerCallback_t)(int unknown, int powerInfo);
10616 +/**
10617 + * Register Power Callback Function
10619 + * @param slot - slot of the callback in the list, 0 to 15, pass -1 to get an auto assignment.
10620 + * @param cbid - callback id from calling sceKernelCreateCallback
10622 + * @return 0 on success, the slot number if -1 is passed, < 0 on error.
10623 + */
10624 +int scePowerRegisterCallback(int slot, SceUID cbid);
10626 +/**
10627 + * Unregister Power Callback Function
10629 + * @param slot - slot of the callback
10631 + * @return 0 on success, < 0 on error.
10632 + */
10633 +int scePowerUnregisterCallback(int slot);
10635 +/**
10636 + * Check if unit is plugged in
10638 + * @return 1 if plugged in, 0 if not plugged in, < 0 on error.
10639 + */
10640 +int scePowerIsPowerOnline(void);
10642 +/**
10643 + * Check if a battery is present
10645 + * @return 1 if battery present, 0 if battery not present, < 0 on error.
10646 + */
10647 +int scePowerIsBatteryExist(void);
10649 +/**
10650 + * Check if the battery is charging
10652 + * @return 1 if battery charging, 0 if battery not charging, < 0 on error.
10653 + */
10654 +int scePowerIsBatteryCharging(void);
10656 +/**
10657 + * Get the status of the battery charging
10658 + */
10659 +int scePowerGetBatteryChargingStatus(void);
10661 +/**
10662 + * Check if the battery is low
10664 + * @return 1 if the battery is low, 0 if the battery is not low, < 0 on error.
10665 + */
10666 +int scePowerIsLowBattery(void);
10668 +/**
10669 + * Get battery life as integer percent
10671 + * @return Battery charge percentage (0-100), < 0 on error.
10672 + */
10673 +int scePowerGetBatteryLifePercent(void);
10675 +/**
10676 + * Get battery life as time
10678 + * @return Battery life in minutes, < 0 on error.
10679 + */
10680 +int scePowerGetBatteryLifeTime(void);
10682 +/**
10683 + * Get temperature of the battery
10684 + */
10685 +int scePowerGetBatteryTemp(void);
10687 +/**
10688 + * unknown? - crashes PSP in usermode
10689 + */
10690 +int scePowerGetBatteryElec(void);
10692 +/**
10693 + * Get battery volt level
10694 + */
10695 +int scePowerGetBatteryVolt(void);
10697 +/**
10698 + * Set CPU Frequency
10699 + * @param cpufreq - new CPU frequency, valid values are 1 - 333
10700 + */
10701 +int scePowerSetCpuClockFrequency(int cpufreq);
10703 +/**
10704 + * Set Bus Frequency
10705 + * @param busfreq - new BUS frequency, valid values are 1 - 167
10706 + */
10707 +int scePowerSetBusClockFrequency(int busfreq);
10709 +/**
10710 + * Alias for scePowerGetCpuClockFrequencyInt
10711 + * @return frequency as int
10712 + */
10713 +int scePowerGetCpuClockFrequency(void);
10715 +/**
10716 + * Get CPU Frequency as Integer
10717 + * @return frequency as int
10718 + */
10719 +int scePowerGetCpuClockFrequencyInt(void);
10721 +/**
10722 + * Get CPU Frequency as Float
10723 + * @return frequency as float
10724 + */
10725 +float scePowerGetCpuClockFrequencyFloat(void);
10727 +/**
10728 + * Alias for scePowerGetBusClockFrequencyInt
10729 + * @return frequency as int
10730 + */
10731 +int scePowerGetBusClockFrequency(void);
10733 +/**
10734 + * Get Bus fequency as Integer
10735 + * @return frequency as int
10736 + */
10737 +int scePowerGetBusClockFrequencyInt(void);
10739 +/**
10740 + * Get Bus frequency as Float
10741 + * @return frequency as float
10742 + */
10743 +float scePowerGetBusClockFrequencyFloat(void);
10745 +/**
10746 + * Set Clock Frequencies
10748 + * @param pllfreq - pll frequency, valid from 19-333
10749 + * @param cpufreq - cpu frequency, valid from 1-333
10750 + * @param busfreq - bus frequency, valid from 1-167
10751 + *
10752 + * and:
10753 + *
10754 + * cpufreq <= pllfreq
10755 + * busfreq*2 <= pllfreq
10757 + */
10758 +int scePowerSetClockFrequency(int pllfreq, int cpufreq, int busfreq);
10760 +/**
10761 + * Lock power switch
10763 + * Note: if the power switch is toggled while locked
10764 + * it will fire immediately after being unlocked.
10766 + * @param unknown - pass 0
10768 + * @return 0 on success, < 0 on error.
10769 + */
10770 +int scePowerLock(int unknown);
10772 +/**
10773 + * Unlock power switch
10775 + * @param unknown - pass 0
10777 + * @return 0 on success, < 0 on error.
10778 + */
10779 +int scePowerUnlock(int unknown);
10781 +/**
10782 + * Generate a power tick, preventing unit from
10783 + * powering off and turning off display.
10785 + * @param type - Either PSP_POWER_TICK_ALL, PSP_POWER_TICK_SUSPEND or PSP_POWER_TICK_DISPLAY
10787 + * @return 0 on success, < 0 on error.
10788 + */
10789 +int scePowerTick(int type);
10791 +/**
10792 + * Get Idle timer
10794 + */
10795 +int scePowerGetIdleTimer(void);
10797 +/**
10798 + * Enable Idle timer
10800 + * @param unknown - pass 0
10801 + */
10802 +int scePowerIdleTimerEnable(int unknown);
10804 +/**
10805 + * Disable Idle timer
10807 + * @param unknown - pass 0
10808 + */
10809 +int scePowerIdleTimerDisable(int unknown);
10811 +/**
10812 + * Request the PSP to go into standby
10814 + * @return 0 always
10815 + */
10816 +int scePowerRequestStandby(void);
10818 +/**
10819 + * Request the PSP to go into suspend
10821 + * @return 0 always
10822 + */
10823 +int scePowerRequestSuspend(void);
10826 +#ifdef __cplusplus
10828 +#endif
10830 +#endif
10831 diff --git a/newlib/psp/include/pspprof.h b/newlib/psp/include/pspprof.h
10832 new file mode 100644
10833 index 0000000..d47722a
10834 --- /dev/null
10835 +++ b/newlib/psp/include/pspprof.h
10836 @@ -0,0 +1,24 @@
10838 + * PSP Software Development Kit - https://github.com/pspdev
10839 + * -----------------------------------------------------------------------
10840 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10842 + * pspprof.h - Prototypes for the profiler library
10844 + * Copyright (c) 2006 Urchin
10846 + */
10847 +#ifndef __PSPPROF_H__
10848 +#define __PSPPROF_H__
10850 +#ifdef __cplusplus
10851 +extern "C" {
10852 +#endif
10854 +void gprof_cleanup();
10856 +#ifdef __cplusplus
10858 +#endif
10860 +#endif /* __PSPPROF_H__ */
10861 diff --git a/newlib/psp/include/pspreg.h b/newlib/psp/include/pspreg.h
10862 new file mode 100644
10863 index 0000000..5624bf8
10864 --- /dev/null
10865 +++ b/newlib/psp/include/pspreg.h
10866 @@ -0,0 +1,236 @@
10868 + * PSP Software Development Kit - https://github.com/pspdev
10869 + * -----------------------------------------------------------------------
10870 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
10872 + * pspreg.h - Prototypes for the sceReg library.
10874 + * Copyright (c) 2005 James F
10876 + */
10878 +#ifndef __REG_H__
10879 +#define __REG_H__
10881 +#ifdef __cplusplus
10882 +extern "C" {
10883 +#endif
10885 +/** @addtogroup Reg Registry Kernel Library */
10886 +/**@{*/
10888 +/** System registry path */
10889 +#define SYSTEM_REGISTRY "/system"
10891 +/** Size of a keyname, used in ::sceRegGetKeys */
10892 +#define REG_KEYNAME_SIZE 27
10894 +/** Key types */
10895 +enum RegKeyTypes
10897 + /** Key is a directory */
10898 + REG_TYPE_DIR = 1,
10899 + /** Key is an integer (4 bytes) */
10900 + REG_TYPE_INT = 2,
10901 + /** Key is a string */
10902 + REG_TYPE_STR = 3,
10903 + /** Key is a binary string */
10904 + REG_TYPE_BIN = 4,
10907 +/** Typedef for a registry handle */
10908 +typedef unsigned int REGHANDLE;
10910 +/** Struct used to open a registry */
10911 +struct RegParam
10913 + unsigned int regtype; /* 0x0, set to 1 only for system */
10914 + /** Seemingly never used, set to ::SYSTEM_REGISTRY */
10915 + char name[256]; /* 0x4-0x104 */
10916 + /** Length of the name */
10917 + unsigned int namelen; /* 0x104 */
10918 + /** Unknown, set to 1 */
10919 + unsigned int unk2; /* 0x108 */
10920 + /** Unknown, set to 1 */
10921 + unsigned int unk3; /* 0x10C */
10924 +/**
10925 + * Open the registry
10927 + * @param reg - A filled in ::RegParam structure
10928 + * @param mode - Open mode (set to 1)
10929 + * @param h - Pointer to a REGHANDLE to receive the registry handle
10931 + * @return 0 on success, < 0 on error
10932 + */
10933 +int sceRegOpenRegistry(struct RegParam *reg, int mode, REGHANDLE *h);
10935 +/**
10936 + * Flush the registry to disk
10938 + * @param h - The open registry handle
10940 + * @return 0 on success, < 0 on error
10941 + */
10942 +int sceRegFlushRegistry(REGHANDLE h);
10944 +/**
10945 + * Close the registry
10947 + * @param h - The open registry handle
10949 + * @return 0 on success, < 0 on error
10950 + */
10951 +int sceRegCloseRegistry(REGHANDLE h);
10953 +/**
10954 + * Open a registry directory
10956 + * @param h - The open registry handle
10957 + * @param name - The path to the dir to open (e.g. /CONFIG/SYSTEM)
10958 + * @param mode - Open mode (can be 1 or 2, probably read or read/write
10959 + * @param hd - Pointer to a REGHANDLE to receive the registry dir handle
10961 + * @return 0 on success, < 0 on error
10962 + */
10963 +int sceRegOpenCategory(REGHANDLE h, const char *name, int mode, REGHANDLE *hd);
10965 +/**
10966 + * Remove a registry dir
10968 + * @param h - The open registry dir handle
10969 + * @param name - The name of the key
10971 + * @return 0 on success, < 0 on error
10972 + */
10973 +int sceRegRemoveCategory(REGHANDLE h, const char *name);
10975 +/**
10976 + * Close the registry directory
10978 + * @param hd - The open registry dir handle
10980 + * @return 0 on success, < 0 on error
10981 + */
10982 +int sceRegCloseCategory(REGHANDLE hd);
10984 +/**
10985 + * Flush the registry directory to disk
10987 + * @param hd - The open registry dir handle
10989 + * @return 0 on success, < 0 on error
10990 + */
10991 +int sceRegFlushCategory(REGHANDLE hd);
10993 +/**
10994 + * Get a key's information
10996 + * @param hd - The open registry dir handle
10997 + * @param name - Name of the key
10998 + * @param hk - Pointer to a REGHANDLE to get registry key handle
10999 + * @param type - Type of the key, on of ::RegKeyTypes
11000 + * @param size - The size of the key's value in bytes
11002 + * @return 0 on success, < 0 on error
11003 + */
11004 +int sceRegGetKeyInfo(REGHANDLE hd, const char *name, REGHANDLE *hk, unsigned int *type, SceSize *size);
11006 +/**
11007 + * Get a key's information by name
11009 + * @param hd - The open registry dir handle
11010 + * @param name - Name of the key
11011 + * @param type - Type of the key, on of ::RegKeyTypes
11012 + * @param size - The size of the key's value in bytes
11014 + * @return 0 on success, < 0 on error
11015 + */
11016 +int sceRegGetKeyInfoByName(REGHANDLE hd, const char *name, unsigned int *type, SceSize *size);
11018 +/**
11019 + * Get a key's value
11021 + * @param hd - The open registry dir handle
11022 + * @param hk - The open registry key handler (from ::sceRegGetKeyInfo)
11023 + * @param buf - Buffer to hold the value
11024 + * @param size - The size of the buffer
11026 + * @return 0 on success, < 0 on error
11027 + */
11028 +int sceRegGetKeyValue(REGHANDLE hd, REGHANDLE hk, void *buf, SceSize size);
11030 +/**
11031 + * Get a key's value by name
11033 + * @param hd - The open registry dir handle
11034 + * @param name - The key name
11035 + * @param buf - Buffer to hold the value
11036 + * @param size - The size of the buffer
11038 + * @return 0 on success, < 0 on error
11039 + */
11040 +int sceRegGetKeyValueByName(REGHANDLE hd, const char *name, void *buf, SceSize size);
11042 +/**
11043 + * Set a key's value
11045 + * @param hd - The open registry dir handle
11046 + * @param name - The key name
11047 + * @param buf - Buffer to hold the value
11048 + * @param size - The size of the buffer
11050 + * @return 0 on success, < 0 on error
11051 + */
11052 +int sceRegSetKeyValue(REGHANDLE hd, const char *name, const void *buf, SceSize size);
11054 +/**
11055 + * Get number of subkeys in the current dir
11057 + * @param hd - The open registry dir handle
11058 + * @param num - Pointer to an integer to receive the number
11060 + * @return 0 on success, < 0 on error
11061 + */
11062 +int sceRegGetKeysNum(REGHANDLE hd, int *num);
11064 +/**
11065 + * Get the key names in the current directory
11067 + * @param hd - The open registry dir handle
11068 + * @param buf - Buffer to hold the NUL terminated strings, should be num*REG_KEYNAME_SIZE
11069 + * @param num - Number of elements in buf
11071 + * @return 0 on success, < 0 on error
11072 + */
11073 +int sceRegGetKeys(REGHANDLE hd, char *buf, int num);
11075 +/**
11076 + * Create a key
11077 + *
11078 + * @param hd - The open registry dir handle
11079 + * @param name - Name of the key to create
11080 + * @param type - Type of key (note cannot be a directory type)
11081 + * @param size - Size of the allocated value space
11083 + * @return 0 on success, < 0 on error
11084 + */
11085 +int sceRegCreateKey(REGHANDLE hd, const char *name, int type, SceSize size);
11087 +/**
11088 + * Remove a registry (HONESTLY, DO NOT USE)
11090 + * @param reg - Filled out registry parameter
11092 + * @return 0 on success, < 0 on error
11093 + */
11094 +int sceRegRemoveRegistry(struct RegParam *reg);
11096 +/**@}*/
11098 +#ifdef __cplusplus
11100 +#endif
11102 +#endif
11103 diff --git a/newlib/psp/include/psprtc.h b/newlib/psp/include/psprtc.h
11104 new file mode 100644
11105 index 0000000..be3aef0
11106 --- /dev/null
11107 +++ b/newlib/psp/include/psprtc.h
11108 @@ -0,0 +1,281 @@
11110 + * PSP Software Development Kit - https://github.com/pspdev
11111 + * -----------------------------------------------------------------------
11112 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
11114 + * psprtc.h - Prototypes for the sceRtc library
11116 + * Function returns marked with (?) have not been tested.
11118 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11120 + */
11121 +#ifndef __PSPRTC_H__
11122 +#define __PSPRTC_H__
11124 +#ifdef __cplusplus
11125 +extern "C" {
11126 +#endif
11128 +typedef struct {
11129 + u16 year;
11130 + u16 month;
11131 + u16 day;
11132 + u16 hour;
11133 + u16 minutes;
11134 + u16 seconds;
11135 + u32 microseconds;
11136 +} pspTime;
11138 +enum pspRtcCheckValidErrors {
11139 + PSP_TIME_INVALID_YEAR = -1,
11140 + PSP_TIME_INVALID_MONTH = -2,
11141 + PSP_TIME_INVALID_DAY = -3,
11142 + PSP_TIME_INVALID_HOUR = -4,
11143 + PSP_TIME_INVALID_MINUTES = -5,
11144 + PSP_TIME_INVALID_SECONDS = -6,
11145 + PSP_TIME_INVALID_MICROSECONDS = -7
11148 +/**
11149 + * Get the resolution of the tick counter
11151 + * @return # of ticks per second
11152 + */
11153 +u32 sceRtcGetTickResolution();
11155 +/**
11156 + * Get current tick count
11158 + * @param tick - pointer to u64 to receive tick count
11159 + * @return 0 on success, < 0 on error
11160 + */
11161 +int sceRtcGetCurrentTick(u64 *tick);
11163 +/**
11164 + * Get current tick count, adjusted for local time zone
11166 + * @param time - pointer to pspTime struct to receive time
11167 + * @param tz - time zone to adjust to (minutes from UTC)
11168 + * @return 0 on success, < 0 on error
11169 + */
11170 +int sceRtcGetCurrentClock(pspTime *time, int tz);
11172 +/**
11173 + * Get current local time into a pspTime struct
11175 + * @param time - pointer to pspTime struct to receive time
11176 + * @return 0 on success, < 0 on error
11177 + */
11178 +int sceRtcGetCurrentClockLocalTime(pspTime *time);
11180 +/**
11181 + * Convert a UTC-based tickcount into a local time tick count
11183 + * @param tickUTC - pointer to u64 tick in UTC time
11184 + * @param tickLocal - pointer to u64 to receive tick in local time
11185 + * @return 0 on success, < 0 on error
11186 + */
11187 +int sceRtcConvertUtcToLocalTime(const u64* tickUTC, u64* tickLocal);
11189 +/**
11190 + * Convert a local time based tickcount into a UTC-based tick count
11192 + * @param tickLocal - pointer to u64 tick in local time
11193 + * @param tickUTC - pointer to u64 to receive tick in UTC based time
11194 + * @return 0 on success, < 0 on error
11195 + */
11196 +int sceRtcConvertLocalTimeToUTC(const u64* tickLocal, u64* tickUTC);
11198 +/**
11199 + * Check if a year is a leap year
11201 + * @param year - year to check if is a leap year
11202 + * @return 1 on leapyear, 0 if not
11203 + */
11204 +int sceRtcIsLeapYear(int year);
11206 +/**
11207 + * Get number of days in a specific month
11209 + * @param year - year in which to check (accounts for leap year)
11210 + * @param month - month to get number of days for
11211 + * @return # of days in month, <0 on error (?)
11212 + */
11213 +int sceRtcGetDaysInMonth(int year, int month);
11215 +/**
11216 + * Get day of the week for a date
11218 + * @param year - year in which to check (accounts for leap year)
11219 + * @param month - month that day is in
11220 + * @param day - day to get day of week for
11221 + * @return day of week with 0 representing Monday
11222 + */
11223 +int sceRtcGetDayOfWeek(int year, int month, int day);
11225 +/**
11226 + * Validate pspDate component ranges
11228 + * @param date - pointer to pspDate struct to be checked
11229 + * @return 0 on success, one of ::pspRtcCheckValidErrors on error
11230 + */
11231 +int sceRtcCheckValid(const pspTime* date);
11233 +/**
11234 + * Set a pspTime struct based on ticks
11236 + * @param date - pointer to pspTime struct to set
11237 + * @param tick - pointer to ticks to convert
11238 + * @return 0 on success, < 0 on error
11239 + */
11240 +int sceRtcSetTick(pspTime* date, const u64* tick);
11242 +/**
11243 + * Set ticks based on a pspTime struct
11245 + * @param date - pointer to pspTime to convert
11246 + * @param tick - pointer to tick to set
11247 + * @return 0 on success, < 0 on error
11248 + */
11249 +int sceRtcGetTick(const pspTime* date, u64 *tick);
11251 +/**
11252 + * Compare two ticks
11254 + * @param tick1 - pointer to first tick
11255 + * @param tick2 - poiinter to second tick
11256 + * @return 0 on equal, <0 when tick1 < tick2, >0 when tick1 > tick2
11257 + */
11258 +int sceRtcCompareTick(const u64* tick1, const u64* tick2);
11260 +/**
11261 + * Add two ticks
11263 + * @param destTick - pointer to tick to hold result
11264 + * @param srcTick - pointer to source tick
11265 + * @param numTicks - number of ticks to add
11266 + * @return 0 on success, <0 on error
11267 + */
11268 +int sceRtcTickAddTicks(u64* destTick, const u64* srcTick, u64 numTicks);
11270 +/**
11271 + * Add an amount of ms to a tick
11273 + * @param destTick - pointer to tick to hold result
11274 + * @param srcTick - pointer to source tick
11275 + * @param numMS - number of ms to add
11276 + * @return 0 on success, <0 on error
11277 + */
11278 +int sceRtcTickAddMicroseconds(u64* destTick, const u64* srcTick, u64 numMS);
11280 +/**
11281 + * Add an amount of seconds to a tick
11283 + * @param destTick - pointer to tick to hold result
11284 + * @param srcTick - pointer to source tick
11285 + * @param numSecs - number of seconds to add
11286 + * @return 0 on success, <0 on error
11287 + */
11288 +int sceRtcTickAddSeconds(u64* destTick, const u64* srcTick, u64 numSecs);
11290 +/**
11291 + * Add an amount of minutes to a tick
11293 + * @param destTick - pointer to tick to hold result
11294 + * @param srcTick - pointer to source tick
11295 + * @param numMins - number of minutes to add
11296 + * @return 0 on success, <0 on error
11297 + */
11298 +int sceRtcTickAddMinutes(u64* destTick, const u64* srcTick, u64 numMins);
11300 +/**
11301 + * Add an amount of hours to a tick
11303 + * @param destTick - pointer to tick to hold result
11304 + * @param srcTick - pointer to source tick
11305 + * @param numHours - number of hours to add
11306 + * @return 0 on success, <0 on error
11307 + */
11308 +int sceRtcTickAddHours(u64* destTick, const u64* srcTick, int numHours);
11310 +/**
11311 + * Add an amount of days to a tick
11313 + * @param destTick - pointer to tick to hold result
11314 + * @param srcTick - pointer to source tick
11315 + * @param numDays - number of days to add
11316 + * @return 0 on success, <0 on error
11317 + */
11318 +int sceRtcTickAddDays(u64* destTick, const u64* srcTick, int numDays);
11320 +/**
11321 + * Add an amount of weeks to a tick
11323 + * @param destTick - pointer to tick to hold result
11324 + * @param srcTick - pointer to source tick
11325 + * @param numWeeks - number of weeks to add
11326 + * @return 0 on success, <0 on error
11327 + */
11328 +int sceRtcTickAddWeeks(u64* destTick, const u64* srcTick, int numWeeks);
11331 +/**
11332 + * Add an amount of months to a tick
11334 + * @param destTick - pointer to tick to hold result
11335 + * @param srcTick - pointer to source tick
11336 + * @param numMonths - number of months to add
11337 + * @return 0 on success, <0 on error
11338 + */
11339 +int sceRtcTickAddMonths(u64* destTick, const u64* srcTick, int numMonths);
11341 +/**
11342 + * Add an amount of years to a tick
11344 + * @param destTick - pointer to tick to hold result
11345 + * @param srcTick - pointer to source tick
11346 + * @param numYears - number of years to add
11347 + * @return 0 on success, <0 on error
11348 + */
11349 +int sceRtcTickAddYears(u64* destTick, const u64* srcTick, int numYears);
11351 +int sceRtcSetTime_t(pspTime* date, const time_t time);
11352 +int sceRtcGetTime_t(const pspTime* date, time_t *time);
11353 +int sceRtcSetDosTime(pspTime* date, u32 dosTime);
11354 +int sceRtcGetDosTime(pspTime* date, u32 dosTime);
11355 +int sceRtcSetWin32FileTime(pspTime* date, u64* win32Time);
11356 +int sceRtcGetWin32FileTime(pspTime* date, u64* win32Time);
11358 +int sceRtcParseDateTime(u64 *destTick, const char *dateString);
11360 +/**
11361 + * Format Tick-representation UTC time in RFC2822 format
11362 + */
11363 +int sceRtcFormatRFC2822(char *pszDateTime, const u64 *pUtc, int iTimeZoneMinutes);
11365 +/**
11366 + * Format Tick-representation UTC time in RFC2822 format
11367 + */
11368 +int sceRtcFormatRFC2822LocalTime(char *pszDateTime, const u64 *pUtc);
11370 +/**
11371 + * Format Tick-representation UTC time in RFC3339(ISO8601) format
11372 + */
11373 +int sceRtcFormatRFC3339(char *pszDateTime, const u64 *pUtc, int iTimeZoneMinutes);
11375 +/**
11376 + * Format Tick-representation UTC time in RFC3339(ISO8601) format
11377 + */
11378 +int sceRtcFormatRFC3339LocalTime(char *pszDateTime, const u64 *pUtc);
11380 +/**
11381 + * Parse time information represented in RFC3339 format
11382 + */
11383 +int sceRtcParseRFC3339(u64 *pUtc, const char *pszDateTime);
11385 +#ifdef __cplusplus
11387 +#endif
11389 +#endif
11390 diff --git a/newlib/psp/include/pspsdk.h b/newlib/psp/include/pspsdk.h
11391 new file mode 100644
11392 index 0000000..e267ba2
11393 --- /dev/null
11394 +++ b/newlib/psp/include/pspsdk.h
11395 @@ -0,0 +1,295 @@
11397 + * PSP Software Development Kit - https://github.com/pspdev
11398 + * -----------------------------------------------------------------------
11399 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
11401 + * pspsdk.h - Interface to the PSPSDK utility library.
11403 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
11404 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
11405 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11407 + */
11409 +#ifndef PSPSDK_H
11410 +#define PSPSDK_H
11412 +#include <pspkerneltypes.h>
11413 +#include <pspmodulemgr.h>
11414 +#include <pspmoduleinfo.h>
11415 +#include <pspthreadman.h>
11417 +#ifdef __cplusplus
11418 +extern "C" {
11419 +#endif
11421 +/** @defgroup PSPSDK PSPSDK Utility Library */
11423 +/** @addtogroup PSPSDK */
11424 +/**@{*/
11426 +/**
11427 + * Query a modules information from its uid.
11428 + * @note this is a replacement function for the broken kernel sceKernelQueryModuleInfo in v1.0 firmware
11429 + * DO NOT use on a anything above that version. This also needs kernel mode access where
11430 + * the normal one has a user mode stub.
11431 + *
11432 + * @param uid - The UID of the module to query.
11433 + * @param modinfo - Pointer a module SceKernelModuleInfo structure.
11435 + * @return < 0 on error.
11436 + */
11437 +int pspSdkQueryModuleInfoV1(SceUID uid, SceKernelModuleInfo *modinfo);
11439 +/**
11440 + * Get the list of module IDs.
11441 + * @note This is a replacement function for the missing v1.5 sceKernelGetModuleIdList
11442 + * on v1.0 firmware. DO NOT use on anything above that version.
11444 + * @param readbuf - Buffer to store the module list.
11445 + * @param readbufsize - Number of elements in the readbuffer.
11446 + * @param idcount - Returns the number of module ids
11448 + * @return >= 0 on success
11449 + */
11450 +int pspSdkGetModuleIdList(SceUID *readbuf, int readbufsize, int *idcount);
11452 +/**
11453 + * Patch the sceModuleManager module to nullify LoadDeviceCheck() calls.
11455 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes.
11457 + * @note This function must be called while running in kernel mode. The program
11458 + * must also be linked against the pspkernel library.
11459 + */
11460 +int pspSdkInstallNoDeviceCheckPatch(void);
11462 +/**
11463 + * Patch sceLoadCore module to remove loading plain module checks
11465 + * @note This function must be called while running in kernel mode.
11467 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes.
11468 + */
11469 +int pspSdkInstallNoPlainModuleCheckPatch(void);
11471 +/**
11472 + * Patch sceLoadModuleWithApiType to remove the kernel check in loadmodule allowing all modules to load
11474 + * @note This function must be called while running in kernel mode
11476 + * @return 0 on success
11477 + */
11478 +int pspSdkInstallKernelLoadModulePatch(void);
11480 +/**
11481 + * Load a module and start it.
11483 + * @param filename - Path to the module.
11484 + * @param mpid - Memory parition ID to use to load the module int.
11486 + * @return - The UID of the module on success, otherwise one of ::PspKernelErrorCodes.
11487 + */
11488 +SceUID pspSdkLoadStartModule(const char *filename, int mpid);
11490 +/**
11491 + * Load a module and start it with arguments
11493 + * @param filename - Path to the module.
11494 + * @param mpid - Memory parition ID to use to load the module int.
11495 + * @param argc - Number of arguments to pass to start module
11496 + * @param argv - Array of arguments
11498 + * @return - The UID of the module on success, otherwise one of ::PspKernelErrorCodes.
11499 + */
11500 +SceUID pspSdkLoadStartModuleWithArgs(const char *filename, int mpid, int argc, char * const argv[]);
11502 +/**
11503 + * Manually fixup library imports for late binding modules.
11505 + * @param moduleId - Id of the module to fixup
11506 + */
11507 +void pspSdkFixupImports(int moduleId);
11509 +/**
11510 + * Load Inet related modules.
11511 + * @note You must be in kernel mode to execute this function.
11513 + * @return - 0 on success, otherwise one of ::PspKernelErrorCodes.
11514 + */
11515 +int pspSdkLoadInetModules();
11517 +/**
11518 + * Initialize Inet related modules.
11520 + * @return - 0 on success, otherwise one of ::PspKernelErrorCodes.
11521 + */
11522 +int pspSdkInetInit();
11524 +/**
11525 + * Terminate Inet related modules.
11526 + */
11527 +void pspSdkInetTerm();
11529 +/**
11530 + * Search for a thread with the given name and retrieve it's ::SceKernelThreadInfo struct.
11532 + * @param name - The name of the thread to search for.
11533 + * @param pUID - If the thread with the given name is found, it's ::SceUID is stored here.
11534 + * @param pInfo - If the thread with the given name is found, it's ::SceKernelThreadInfo data is stored here.
11536 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11537 + */
11538 +int pspSdkReferThreadStatusByName(const char *name, SceUID *pUID, SceKernelThreadInfo *pInfo);
11540 +/**
11541 + * Search for a semaphore with the given name and retrieve it's ::SceKernelSemaInfo struct.
11543 + * @param name - The name of the sema to search for.
11544 + * @param pUID - If the sema with the given name is found, it's ::SceUID is stored here.
11545 + * @param pInfo - If the sema with the given name is found, it's ::SceKernelSemaInfo data is stored here.
11547 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11548 + */
11549 +int pspSdkReferSemaStatusByName(const char *name, SceUID *pUID, SceKernelSemaInfo *pInfo);
11551 +/**
11552 + * Search for an event flag with the given name and retrieve it's ::SceKernelEventFlagInfo struct.
11554 + * @param name - The name of the event flag to search for.
11555 + * @param pUID - If the event flag with the given name is found, it's ::SceUID is stored here.
11556 + * @param pInfo - If the event flag with the given name is found, it's ::SceKernelEventFlagInfo data is stored here.
11558 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11559 + */
11560 +int pspSdkReferEventFlagStatusByName(const char *name, SceUID *pUID, SceKernelEventFlagInfo *pInfo);
11562 +/**
11563 + * Search for a message box with the given name and retrieve it's ::SceKernelMbxInfo struct.
11565 + * @param name - The name of the message box to search for.
11566 + * @param pUID - If the message box with the given name is found, it's ::SceUID is stored here.
11567 + * @param pInfo - If the message box with the given name is found, it's ::SceKernelMbxInfo data is stored here.
11569 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11570 + */
11571 +int pspSdkReferMboxStatusByName(const char *name, SceUID *pUID, SceKernelMbxInfo *pInfo);
11573 +/**
11574 + * Search for a VPL with the given name and retrieve it's ::SceKernelVplInfo struct.
11576 + * @param name - The name of to search for.
11577 + * @param pUID - If the given name is found, it's ::SceUID is stored here.
11578 + * @param pInfo - If the given name is found, it's ::SceKernelVplInfo data is stored here.
11580 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11581 + */
11582 +int pspSdkReferVplStatusByName(const char *name, SceUID *pUID, SceKernelVplInfo *pInfo);
11584 +/**
11585 + * Search for a FPL with the given name and retrieve it's ::SceKernelFplInfo struct.
11587 + * @param name - The name of to search for.
11588 + * @param pUID - If the given name is found, it's ::SceUID is stored here.
11589 + * @param pInfo - If the given name is found, it's ::SceKernelFplInfo data is stored here.
11591 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11592 + */
11593 +int pspSdkReferFplStatusByName(const char *name, SceUID *pUID, SceKernelFplInfo *pInfo);
11595 +/**
11596 + * Search for a message pipe with the given name and retrieve it's ::SceKernelMppInfo struct.
11598 + * @param name - The name of to search for.
11599 + * @param pUID - If the given name is found, it's ::SceUID is stored here.
11600 + * @param pInfo - If the given name is found, it's ::SceKernelMppInfo data is stored here.
11602 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11603 + */
11604 +int pspSdkReferMppStatusByName(const char *name, SceUID *pUID, SceKernelMppInfo *pInfo);
11606 +/**
11607 + * Search for a callback with the given name and retrieve it's ::SceKernelCallbackInfo struct.
11609 + * @param name - The name of to search for.
11610 + * @param pUID - If the given name is found, it's ::SceUID is stored here.
11611 + * @param pInfo - If the given name is found, it's ::SceKernelMppInfo data is stored here.
11613 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11614 + */
11615 +int pspSdkReferCallbackStatusByName(const char *name, SceUID *pUID, SceKernelCallbackInfo *pInfo);
11617 +/**
11618 + * Search for a vtimer with the given name and retrieve it's ::SceKernelVTimerInfo struct.
11620 + * @param name - The name of to search for.
11621 + * @param pUID - If the given name is found, it's ::SceUID is stored here.
11622 + * @param pInfo - If the given name is found, it's ::SceKernelVTimerInfo data is stored here.
11624 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11625 + */
11626 +int pspSdkReferVTimerStatusByName(const char *name, SceUID *pUID, SceKernelVTimerInfo *pInfo);
11628 +/**
11629 + * Search for a thread event handler with the given name and retrieve it's ::SceKernelThreadEventHandlerInfo struct.
11631 + * @param name - The name of to search for.
11632 + * @param pUID - If the given name is found, it's ::SceUID is stored here.
11633 + * @param pInfo - If the given name is found, it's ::SceKernelThreadEventHandlerInfo data is stored here.
11635 + * @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
11636 + */
11637 +int pspSdkReferThreadEventHandlerStatusByName(const char *name, SceUID *pUID, SceKernelThreadEventHandlerInfo *pInfo);
11639 +/**
11640 + * Disable interrupts
11642 + * @note Do not disable interrupts for too long otherwise the watchdog will get you.
11644 + * @return The previous state of the interrupt enable bit (should be passed back to ::pspSdkEnableInterrupts)
11645 + */
11646 +unsigned int pspSdkDisableInterrupts(void);
11648 +/**
11649 + * Enable interrupts
11651 + * @param istate - The interrupt state as returned from ::pspSdkDisableInterrupts
11652 + */
11653 +void pspSdkEnableInterrupts(unsigned int istate);
11655 +/**
11656 + * Set the processors K1 register to a known value
11658 + * @note This function is for use in kernel mode syscall exports. The kernel
11659 + * sets the k1 register to indicate what mode called the function, i.e.
11660 + * whether it was directly called, was called via a syscall from a kernel
11661 + * thread or called via a syscall from a user thread. By setting k1 to 0
11662 + * before doing anything in your code you can make the other functions think
11663 + * you are calling from a kernel thread and therefore disable numerous
11664 + * protections.
11666 + * @param k1 - The k1 value to set
11667 + *
11668 + * @return The previous value of k1
11669 + */
11670 +unsigned int pspSdkSetK1(unsigned int k1);
11672 +/**
11673 + * Get the current value of the processors K1 register
11675 + * @return The current value of K1
11676 + */
11677 +unsigned int pspSdkGetK1(void);
11679 +/**
11680 + * Disable the CPUs FPU exceptions
11681 + */
11682 +void pspSdkDisableFPUExceptions(void);
11684 +/**@}*/
11686 +#ifdef __cplusplus
11688 +#endif
11690 +#endif /* PSPSDK_H */
11691 diff --git a/newlib/psp/include/pspsircs.h b/newlib/psp/include/pspsircs.h
11692 new file mode 100644
11693 index 0000000..5aae391
11694 --- /dev/null
11695 +++ b/newlib/psp/include/pspsircs.h
11696 @@ -0,0 +1,45 @@
11698 + * PSP Software Development Kit - https://github.com/pspdev
11699 + * -----------------------------------------------------------------------
11700 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
11702 + * pspmodulemgr.h - Prototypes to manage manage modules.
11704 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
11705 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
11706 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11707 + * Copyright (c) 2005 Matthew H <matthewh@webone.com.au>
11709 + * $$
11710 + */
11711 +#ifndef __SIRCS_H__
11712 +#define __SIRCS_H__
11714 +/** @defgroup Sony Integrated Remote Control System Library
11715 + * This module contains the imports for the kernel's remote control routines.
11716 + */
11718 +#ifdef __cplusplus
11719 +extern "C" {
11720 +#endif
11722 +/** @addtogroup Sony Integrated Remote Control System Library */
11723 +/**@{*/
11725 +struct sircs_data {
11726 + u8 type; // 12, 15 or 20 bits
11727 + u8 cmd; // 7 bit cmd
11728 + u16 dev; // 5, 8 or 13 bit device address
11729 +} __packed__;
11731 +/**
11732 + */
11733 +int sceSircsSend(struct sircs_data* sd, int count);
11735 +/**@}*/
11737 +#ifdef __cplusplus
11739 +#endif
11741 +#endif
11742 diff --git a/newlib/psp/include/pspssl.h b/newlib/psp/include/pspssl.h
11743 new file mode 100644
11744 index 0000000..b4bced2
11745 --- /dev/null
11746 +++ b/newlib/psp/include/pspssl.h
11747 @@ -0,0 +1,58 @@
11749 + * PSP Software Development Kit - https://github.com/pspdev
11750 + * -----------------------------------------------------------------------
11751 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
11753 + * pspssl.h - Interface to the ssl library.
11755 + * Copyright (c) 2008 David Perry (InsertWittyName)
11756 + * Copyright (c) 2008 moonlight
11758 + */
11760 +#ifndef __PSPSSL_H__
11761 +#define __PSPSSL_H__
11763 +#if defined(__cplusplus)
11764 +extern "C" {
11765 +#endif
11767 +/**
11768 + * Init the ssl library.
11770 + * @param unknown1 - Memory size? Pass 0x28000
11772 + * @return 0 on success
11774 +int sceSslInit(int unknown1);
11776 +/**
11777 + * Terminate the ssl library.
11779 + * @return 0 on success
11781 +int sceSslEnd(void);
11783 +/**
11784 + * Get the maximum memory size used by ssl.
11786 + * @param memory - Pointer where the maximum memory used value will be stored.
11788 + * @return 0 on success
11790 +int sceSslGetUsedMemoryMax(unsigned int *memory);
11792 +/**
11793 + * Get the current memory size used by ssl.
11795 + * @param memory - Pointer where the current memory used value will be stored.
11797 + * @return 0 on success
11799 +int sceSslGetUsedMemoryCurrent(unsigned int *memory);
11801 +#if defined(__cplusplus)
11803 +#endif
11805 +#endif
11806 diff --git a/newlib/psp/include/pspstdio.h b/newlib/psp/include/pspstdio.h
11807 new file mode 100644
11808 index 0000000..891ae75
11809 --- /dev/null
11810 +++ b/newlib/psp/include/pspstdio.h
11811 @@ -0,0 +1,56 @@
11813 + * PSP Software Development Kit - https://github.com/pspdev
11814 + * -----------------------------------------------------------------------
11815 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
11817 + * pspstdio.h - Prototypes for the sceStdio library.
11819 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
11820 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
11821 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11823 + */
11824 +#ifndef __PSPSTDIO_H__
11825 +#define __PSPSTDIO_H__
11827 +#include <pspkerneltypes.h>
11829 +/** @defgroup Stdio Stdio Library
11830 + * This module contains the imports for the kernel's stdio routines.
11831 + */
11833 +#ifdef __cplusplus
11834 +extern "C" {
11835 +#endif
11837 +/** @addtogroup Stdio Stdio Library */
11838 +/**@{*/
11840 +/**
11841 + * Function to get the current standard in file no
11842 + *
11843 + * @return The stdin fileno
11844 + */
11845 +SceUID sceKernelStdin(void);
11847 +/**
11848 + * Function to get the current standard out file no
11849 + *
11850 + * @return The stdout fileno
11851 + */
11852 +SceUID sceKernelStdout(void);
11854 +/**
11855 + * Function to get the current standard err file no
11856 + *
11857 + * @return The stderr fileno
11858 + */
11859 +SceUID sceKernelStderr(void);
11861 +/**@}*/
11863 +#ifdef __cplusplus
11865 +#endif
11867 +#endif
11868 diff --git a/newlib/psp/include/pspstdio_kernel.h b/newlib/psp/include/pspstdio_kernel.h
11869 new file mode 100644
11870 index 0000000..acc37f6
11871 --- /dev/null
11872 +++ b/newlib/psp/include/pspstdio_kernel.h
11873 @@ -0,0 +1,71 @@
11875 + * PSP Software Development Kit - https://github.com/pspdev
11876 + * -----------------------------------------------------------------------
11877 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
11879 + * pspstdio_kernel.h - Interface to the kernel mode library for Stdio.
11881 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
11882 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
11883 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11885 + */
11887 +#ifndef PSPSTDIO_KERNEL_H
11888 +#define PSPSTDIO_KERNEL_H
11890 +#include <psptypes.h>
11891 +#include <pspkerneltypes.h>
11892 +#include <pspiofilemgr.h>
11894 +/** @defgroup Stdio_Kernel Driver interface to Stdio
11895 + * This module contains the imports for the kernel's stdio routines.
11896 + */
11898 +#ifdef __cplusplus
11899 +extern "C" {
11900 +#endif
11902 +/** @addtogroup Stdio_Kernel Driver interface to Stdio */
11903 +/**@{*/
11905 +/**
11906 + * Function reopen the stdout file handle to a new file
11908 + * @param file - The file to open.
11909 + * @param flags - The open flags
11910 + * @param mode - The file mode
11911 + *
11912 + * @return < 0 on error.
11913 + */
11914 +int sceKernelStdoutReopen(const char *file, int flags, SceMode mode);
11916 +/**
11917 + * Function reopen the stderr file handle to a new file
11919 + * @param file - The file to open.
11920 + * @param flags - The open flags
11921 + * @param mode - The file mode
11922 + *
11923 + * @return < 0 on error.
11924 + */
11925 +int sceKernelStderrReopen(const char *file, int flags, SceMode mode);
11928 +/**
11929 + * fprintf but for file descriptors
11931 + * @param fd - file descriptor from sceIoOpen
11932 + * @param format - format string
11933 + * @param ... - variables
11934 + *
11935 + * @return number of characters printed, <0 on error
11936 + */
11937 +int fdprintf(int fd, const char *format, ...);
11938 +/**@}*/
11940 +#ifdef __cplusplus
11942 +#endif
11944 +#endif /* PSPSTDIO_KERNEL_H */
11945 diff --git a/newlib/psp/include/pspstub.s b/newlib/psp/include/pspstub.s
11946 new file mode 100644
11947 index 0000000..ca04503
11948 --- /dev/null
11949 +++ b/newlib/psp/include/pspstub.s
11950 @@ -0,0 +1,83 @@
11951 +# common.s - GAS macros for creating import libraries.
11953 +# Use STUB_START to declare the start of an import library. The module parameter
11954 +# is the name of the library to import, flags_ver is both the import flags and library
11955 +# version, and stub_len is both the number of stubs to import and the size of the
11956 +# stub itself (in 32-bit words).
11957 +# Use the STUB_FUNC macro for each stub you want to import. The funcid parameter is
11958 +# the 32-bit SHA1-derived NID value, and the funcname is the name you want to call
11959 +# the imported function.
11960 +# Use STUB_END to declare the end of your import library.
11962 +.macro STUB_START module, flags_ver, stub_len
11964 + .set push
11965 + .section .rodata.sceResident, "a"
11966 + .word 0
11967 +__stub_modulestr_\module:
11968 + .asciz "\module"
11969 + .align 2
11971 + .section .lib.stub, "a", @progbits
11972 + .word __stub_modulestr_\module
11973 + .word \flags_ver
11974 + .word \stub_len
11975 + .word __stub_idtable_\module
11976 + .word __stub_text_\module
11978 + .section .rodata.sceNid, "a"
11979 +__stub_idtable_\module:
11981 + .section .sceStub.text, "ax", @progbits
11982 +__stub_text_\module:
11984 + .set pop
11985 +.endm
11987 +.macro STUB_FUNC funcid, funcname
11989 + .set push
11990 + .set noreorder
11992 + .section .sceStub.text, "ax", @progbits
11993 + .globl \funcname
11994 + .type \funcname, @function
11995 + .ent \funcname, 0
11996 +\funcname:
11997 + jr $ra
11998 + nop
11999 + .end \funcname
12000 + .size \funcname, .-\funcname
12002 + .section .rodata.sceNid
12003 + .word \funcid
12005 + .set pop
12006 +.endm
12008 +.macro STUB_FUNC_WITH_ALIAS funcid, funcname, alias
12010 + .set push
12011 + .set noreorder
12013 + .section .sceStub.text, "ax", @progbits
12014 + .globl \alias
12015 + .type \alias, @function
12016 +\alias:
12017 + .globl \funcname
12018 + .type \funcname, @function
12019 + .ent \funcname, 0
12020 +\funcname:
12021 + jr $ra
12022 + nop
12023 + .end \funcname
12024 + .size \funcname, .-\funcname
12026 + .section .rodata.sceNid
12027 + .word \funcid
12029 + .set pop
12030 +.endm
12032 +.macro STUB_END
12033 +.endm
12034 diff --git a/newlib/psp/include/pspsuspend.h b/newlib/psp/include/pspsuspend.h
12035 new file mode 100644
12036 index 0000000..31e9913
12037 --- /dev/null
12038 +++ b/newlib/psp/include/pspsuspend.h
12039 @@ -0,0 +1,56 @@
12041 + * PSP Software Development Kit - https://github.com/pspdev
12042 + * -----------------------------------------------------------------------
12043 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12045 + * pspsuspend.h - User interface to the PSP suspend.
12047 + * Copyright (c) 2006 James F
12049 + */
12051 +#ifndef __PSPSUSPEND_H__
12052 +#define __PSPSUSPEND_H__
12054 +#include <psptypes.h>
12056 +#ifdef __cplusplus
12057 +extern "C" {
12058 +#endif
12060 +/**
12061 + * Allocate the extra 4megs of RAM
12063 + * @param unk - No idea as it is never used, set to anything
12064 + * @param ptr - Pointer to a pointer to hold the address of the memory
12065 + * @param size - Pointer to an int which will hold the size of the memory
12067 + * @return 0 on success
12068 + */
12069 +int sceKernelVolatileMemLock(int unk, void **ptr, int *size);
12071 +/**
12072 + * Try and allocate the extra 4megs of RAM, will return an error if
12073 + * something has already allocated it
12075 + * @param unk - No idea as it is never used, set to anything
12076 + * @param ptr - Pointer to a pointer to hold the address of the memory
12077 + * @param size - Pointer to an int which will hold the size of the memory
12079 + * @return 0 on success
12080 + */
12081 +int sceKernelVolatileMemTryLock(int unk, void **ptr, int *size);
12083 +/**
12084 + * Deallocate the extra 4 megs of RAM
12086 + * @param unk - Set to 0, otherwise it fails in 3.52+, possibly earlier
12087 + * @return 0 on success
12088 + */
12089 +int sceKernelVolatileMemUnlock(int unk);
12091 +#ifdef __cplusplus
12093 +#endif
12095 +#endif
12096 diff --git a/newlib/psp/include/pspsysclib.h b/newlib/psp/include/pspsysclib.h
12097 new file mode 100644
12098 index 0000000..57d9917
12099 --- /dev/null
12100 +++ b/newlib/psp/include/pspsysclib.h
12101 @@ -0,0 +1,42 @@
12103 + * PSP Software Development Kit - https://github.com/pspdev
12104 + * -----------------------------------------------------------------------
12105 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12107 + * pspsysclib.h - Interface to sysclib library.
12109 + * Copyright (c) 2007 James F
12111 + */
12113 +#ifndef PSPSYSCLIB_H
12114 +#define PSPSYSCLIB_H
12116 +#include <pspkerneltypes.h>
12117 +#include <stdarg.h>
12119 +#ifdef __cplusplus
12120 +extern "C" {
12121 +#endif
12123 +/** Callback type, ch is 0x200 on start of string, 0x201 on end */
12124 +typedef void (*prnt_callback)(void *ctx, int ch);
12126 +/**
12127 + * Generic print routine
12129 + * @param cb - Callback, called for every character printed
12130 + * @param ctx - Context parameter passed to the callback
12131 + * @param fmt - Format data
12132 + * @param args - Arguments for format
12134 + */
12135 +void prnt(prnt_callback cb, void *ctx, const char *fmt, va_list args);
12137 +/*@}*/
12139 +#ifdef __cplusplus
12141 +#endif
12143 +#endif
12144 diff --git a/newlib/psp/include/pspsyscon.h b/newlib/psp/include/pspsyscon.h
12145 new file mode 100644
12146 index 0000000..526e5a4
12147 --- /dev/null
12148 +++ b/newlib/psp/include/pspsyscon.h
12149 @@ -0,0 +1,85 @@
12151 + * PSP Software Development Kit - https://github.com/pspdev
12152 + * -----------------------------------------------------------------------
12153 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12155 + * pspsyscon.h - Interface to sceSyscon_driver.
12157 + * Copyright (c) 2006 James F
12159 + */
12161 +#ifndef PSPSYSCON_H
12162 +#define PSPSYSCON_H
12164 +#include <pspkerneltypes.h>
12166 +/** @defgroup Syscon Interface to the sceSyscon_driver library.
12167 + */
12169 +#ifdef __cplusplus
12170 +extern "C" {
12171 +#endif
12173 +/** @addtogroup Syscon Interface to the sceSyscon_driver library. */
12174 +/**@{*/
12176 +/**
12177 + * Force the PSP to go into standby
12178 + */
12179 +void sceSysconPowerStandby(void);
12181 +/**
12182 + * Reset the PSP
12184 + * @param unk1 - Unknown, pass 1
12185 + * @param unk2 - Unknown, pass 1
12186 + */
12187 +void sceSysconResetDevice(int unk1, int unk2);
12189 +#define SCE_LED_POWER 1
12190 +#define LED_ON 1
12191 +#define LED_OFF 0
12192 +/**
12193 + * Control an LED
12195 + * @param SceLED - The led to toggle (only SCE_LED_POWER)
12196 + * @param state - Whether to turn on or off
12197 + */
12198 +int sceSysconCtrlLED(int SceLED, int state);
12200 +/**
12201 + * Control the remote control power
12203 + * @param power - 1 is on, 0 is off
12204 + *
12205 + * @return < 0 on error
12206 + */
12207 +int sceSysconCtrlHRPower(int power);
12210 +int sceSysconGetHPConnect(void);
12212 +int sceSysconSetHPConnectCallback( void (*)(int), int unk0 );
12214 +int sceSysconSetHRPowerCallback( void (*)(int), int unk0 );
12216 +/**
12217 + * Get the PSP's Pommel version
12218 + * @param version - A pointer to an int to receive the Pommel version into
12219 + */
12220 +int sceSysconGetPommelVersion( int* version );
12222 +/**
12223 + * Get the PSP's Baryon version
12224 + * @param version - A pointer to an int to receive the Baryon version into
12225 + */
12226 +int sceSysconGetBaryonVersion( int* version );
12228 +/**@}*/
12230 +#ifdef __cplusplus
12232 +#endif
12234 +#endif
12235 diff --git a/newlib/psp/include/pspsysevent.h b/newlib/psp/include/pspsysevent.h
12236 new file mode 100644
12237 index 0000000..62a6640
12238 --- /dev/null
12239 +++ b/newlib/psp/include/pspsysevent.h
12240 @@ -0,0 +1,88 @@
12242 + * PSP Software Development Kit - https://github.com/pspdev
12243 + * -----------------------------------------------------------------------
12244 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12246 + * pspsysevent.h - Prototypes for the sceSysEventForKernel library
12248 + * Copyright (c) 2007 Iaroslav Gaponenko <adrahil@gmail.com>
12250 + */
12251 +#ifndef __PSPSYSEVENT_H__
12252 +#define __PSPSYSEVENT_H__
12254 +#ifdef __cplusplus
12255 +extern "C" {
12256 +#endif
12258 +typedef struct PspSysEventHandler _PspSysEventHandler;
12260 +typedef int (*PspSysEventHandlerFunc)(int ev_id, char* ev_name, void* param, int* result);
12262 +typedef struct PspSysEventHandler{
12263 + int size;
12264 + char* name;
12265 + int type_mask;
12266 + int (*handler)(int ev_id, char* ev_name, void* param, int* result);
12267 + int r28;
12268 + int busy;
12269 + _PspSysEventHandler *next;
12270 + int reserved[9];
12271 +}PspSysEventHandler;
12274 +/**
12275 + * Dispatch a SysEvent event.
12277 + * @param ev_type_mask - the event type mask
12278 + * @param ev_id - the event id
12279 + * @param ev_name - the event name
12280 + * @param param - the pointer to the custom parameters
12281 + * @param result - the pointer to the result
12282 + * @param break_nonzero - set to 1 to interrupt the calling chain after the first non-zero return
12283 + * @param break_handler - the pointer to the event handler having interrupted
12284 + * @return 0 on success, < 0 on error
12285 + */
12286 +int sceKernelSysEventDispatch(int ev_type_mask, int ev_id, char* ev_name, void* param, int* result, int break_nonzero, PspSysEventHandler* break_handler);
12289 +/**
12290 + * Get the first SysEvent handler (the rest can be found with the linked list).
12292 + * @return 0 on error, handler on success
12293 + */
12294 +PspSysEventHandler* sceKernelReferSysEventHandler(void);
12297 +/**
12298 + * Check if a SysEvent handler is registered.
12300 + * @param handler - the handler to check
12301 + * @return 0 if the handler is not registered
12302 + */
12303 +int sceKernelIsRegisterSysEventHandler(PspSysEventHandler* handler);
12306 +/**
12307 + * Register a SysEvent handler.
12309 + * @param handler - the handler to register
12310 + * @return 0 on success, < 0 on error
12311 + */
12312 +int sceKernelRegisterSysEventHandler(PspSysEventHandler* handler);
12315 +/**
12316 + * Unregister a SysEvent handler.
12318 + * @param handler - the handler to unregister
12319 + * @return 0 on success, < 0 on error
12320 + */
12321 +int sceKernelUnregisterSysEventHandler(PspSysEventHandler* handler);
12323 +#ifdef __cplusplus
12325 +#endif
12327 +#endif
12329 diff --git a/newlib/psp/include/pspsysmem.h b/newlib/psp/include/pspsysmem.h
12330 new file mode 100644
12331 index 0000000..16447a6
12332 --- /dev/null
12333 +++ b/newlib/psp/include/pspsysmem.h
12334 @@ -0,0 +1,138 @@
12336 + * PSP Software Development Kit - https://github.com/pspdev
12337 + * -----------------------------------------------------------------------
12338 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12340 + * pspsysmem.h - Interface to the system memory manager.
12342 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
12344 + */
12346 +/* Note: Some of the structures, types, and definitions in this file were
12347 + extrapolated from symbolic debugging information found in the Japanese
12348 + version of Puzzle Bobble. */
12350 +#ifndef PSPSYSMEM_H
12351 +#define PSPSYSMEM_H
12353 +#include <pspkerneltypes.h>
12355 +/** @defgroup SysMem System Memory Manager
12356 + * This module contains routines to manage heaps of memory.
12357 + */
12359 +/** @addtogroup SysMem System Memory Manager */
12360 +/**@{*/
12362 +#ifdef __cplusplus
12363 +extern "C" {
12364 +#endif
12366 +/** Specifies the type of allocation used for memory blocks. */
12367 +enum PspSysMemBlockTypes {
12368 + /** Allocate from the lowest available address. */
12369 + PSP_SMEM_Low = 0,
12370 + /** Allocate from the highest available address. */
12371 + PSP_SMEM_High,
12372 + /** Allocate from the specified address. */
12373 + PSP_SMEM_Addr
12376 +typedef int SceKernelSysMemAlloc_t;
12378 +/**
12379 + * Allocate a memory block from a memory partition.
12381 + * @param partitionid - The UID of the partition to allocate from.
12382 + * @param name - Name assigned to the new block.
12383 + * @param type - Specifies how the block is allocated within the partition. One of ::PspSysMemBlockTypes.
12384 + * @param size - Size of the memory block, in bytes.
12385 + * @param addr - If type is PSP_SMEM_Addr, then addr specifies the lowest address allocate the block from.
12387 + * @return The UID of the new block, or if less than 0 an error.
12388 + */
12389 +SceUID sceKernelAllocPartitionMemory(SceUID partitionid, const char *name, int type, SceSize size, void *addr);
12391 +/**
12392 + * Free a memory block allocated with ::sceKernelAllocPartitionMemory.
12394 + * @param blockid - UID of the block to free.
12396 + * @return ? on success, less than 0 on error.
12397 + */
12398 +int sceKernelFreePartitionMemory(SceUID blockid);
12400 +/**
12401 + * Get the address of a memory block.
12403 + * @param blockid - UID of the memory block.
12405 + * @return The lowest address belonging to the memory block.
12406 + */
12407 +void * sceKernelGetBlockHeadAddr(SceUID blockid);
12409 +/**
12410 + * Get the total amount of free memory.
12412 + * @return The total amount of free memory, in bytes.
12413 + */
12414 +SceSize sceKernelTotalFreeMemSize(void);
12416 +/**
12417 + * Get the size of the largest free memory block.
12419 + * @return The size of the largest free memory block, in bytes.
12420 + */
12421 +SceSize sceKernelMaxFreeMemSize(void);
12423 +/**
12424 + * Get the firmware version.
12425 + *
12426 + * @return The firmware version.
12427 + * 0x01000300 on v1.00 unit,
12428 + * 0x01050001 on v1.50 unit,
12429 + * 0x01050100 on v1.51 unit,
12430 + * 0x01050200 on v1.52 unit,
12431 + * 0x02000010 on v2.00/v2.01 unit,
12432 + * 0x02050010 on v2.50 unit,
12433 + * 0x02060010 on v2.60 unit,
12434 + * 0x02070010 on v2.70 unit,
12435 + * 0x02070110 on v2.71 unit.
12436 + */
12437 +int sceKernelDevkitVersion(void);
12439 +#if _PSP_FW_VERSION >= 150
12441 +/**
12442 + * Kernel printf function.
12444 + * @param format - The format string.
12445 + * @param ... - Arguments for the format string.
12446 + */
12447 +void sceKernelPrintf(const char *format, ...) __attribute__((format(printf, 1, 2)));
12449 +#endif
12451 +/**
12452 + * Set the version of the SDK with which the caller was compiled.
12453 + * Version numbers are as for sceKernelDevkitVersion().
12455 + * @return 0 on success, < 0 on error.
12456 + */
12457 +int sceKernelSetCompiledSdkVersion(int version);
12459 +/**
12460 + * Get the SDK version set with sceKernelSetCompiledSdkVersion().
12462 + * @return Version number, or 0 if unset.
12463 + */
12464 +int sceKernelGetCompiledSdkVersion(void);
12466 +#ifdef __cplusplus
12468 +#endif
12470 +/**@}*/
12472 +#endif /* PSPSYSMEM_H */
12473 diff --git a/newlib/psp/include/pspsysmem_kernel.h b/newlib/psp/include/pspsysmem_kernel.h
12474 new file mode 100644
12475 index 0000000..8dd60a6
12476 --- /dev/null
12477 +++ b/newlib/psp/include/pspsysmem_kernel.h
12478 @@ -0,0 +1,224 @@
12480 + * PSP Software Development Kit - https://github.com/pspdev
12481 + * -----------------------------------------------------------------------
12482 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12484 + * pspsysmem_kernel.h - Interface to the system memory manager (kernel).
12486 + * Copyright (c) 2005 James F.
12488 + */
12490 +/* Note: Some of the structures, types, and definitions in this file were
12491 + extrapolated from symbolic debugging information found in the Japanese
12492 + version of Puzzle Bobble. */
12494 +#ifndef PSPSYSMEMKERNEL_H
12495 +#define PSPSYSMEMKERNEL_H
12497 +#include <pspkerneltypes.h>
12498 +#include <pspsysmem.h>
12500 +/** @defgroup SysMemKern System Memory Manager Kernel
12501 + * This module contains routines to manage heaps of memory.
12502 + */
12504 +/** @addtogroup SysMemKern System Memory Manager Kernel */
12505 +/**@{*/
12507 +#ifdef __cplusplus
12508 +extern "C" {
12509 +#endif
12511 +typedef struct _PspSysmemPartitionInfo
12513 + SceSize size;
12514 + unsigned int startaddr;
12515 + unsigned int memsize;
12516 + unsigned int attr;
12517 +} PspSysmemPartitionInfo;
12519 +/**
12520 + * Query the parition information
12522 + * @param pid - The partition id
12523 + * @param info - Pointer to the ::PspSysmemPartitionInfo structure
12525 + * @return 0 on success.
12526 + */
12527 +int sceKernelQueryMemoryPartitionInfo(int pid, PspSysmemPartitionInfo *info);
12529 +/**
12530 + * Get the total amount of free memory.
12532 + * @param pid - The partition id
12534 + * @return The total amount of free memory, in bytes.
12535 + */
12536 +SceSize sceKernelPartitionTotalFreeMemSize(int pid);
12538 +/**
12539 + * Get the size of the largest free memory block.
12541 + * @param pid - The partition id
12543 + * @return The size of the largest free memory block, in bytes.
12544 + */
12545 +SceSize sceKernelPartitionMaxFreeMemSize(int pid);
12547 +/**
12548 + * Get the kernel to dump the internal memory table to Kprintf
12549 + */
12550 +void sceKernelSysMemDump(void);
12552 +/**
12553 + * Dump the list of memory blocks
12554 + */
12555 +void sceKernelSysMemDumpBlock(void);
12557 +/**
12558 + * Dump the tail blocks
12559 + */
12560 +void sceKernelSysMemDumpTail(void);
12562 +/**
12563 + * Set the protection of a block of ddr memory
12565 + * @param addr - Address to set protection on
12566 + * @param size - Size of block
12567 + * @param prot - Protection bitmask
12569 + * @return < 0 on error
12570 + */
12571 +int sceKernelSetDdrMemoryProtection(void *addr, int size, int prot);
12573 +/**
12574 + * Create a heap.
12576 + * @param partitionid - The UID of the partition where allocate the heap.
12577 + * @param size - The size in bytes of the heap.
12578 + * @param unk - Unknown, probably some flag or type, pass 1.
12579 + * @param name - Name assigned to the new heap.
12581 + * @return The UID of the new heap, or if less than 0 an error.
12583 +SceUID sceKernelCreateHeap(SceUID partitionid, SceSize size, int unk, const char *name);
12585 +/**
12586 + * Allocate a memory block from a heap.
12588 + * @param heapid - The UID of the heap to allocate from.
12589 + * @param size - The number of bytes to allocate.
12591 + * @return The address of the allocated memory block, or NULL on error.
12593 +void *sceKernelAllocHeapMemory(SceUID heapid, SceSize size);
12595 +/**
12596 + * Free a memory block allocated from a heap.
12598 + * @param heapid - The UID of the heap where block belongs.
12599 + * @param block - The block of memory to free from the heap.
12601 + * @return 0 on success, < 0 on error.
12602 + */
12603 +int sceKernelFreeHeapMemory(SceUID heapid, void *block);
12605 +/**
12606 + * Delete a heap.
12608 + * @param heapid - The UID of the heap to delete.
12610 + * @return 0 on success, < 0 on error.
12612 +int sceKernelDeleteHeap(SceUID heapid);
12614 +/**
12615 + * Get the amount of free size of a heap, in bytes.
12617 + * @param heapid - The UID of the heap
12619 + * @return the free size of the heap, in bytes. < 0 on error.
12621 +SceSize sceKernelHeapTotalFreeSize(SceUID heapid);
12623 +/** Structure of a UID control block */
12624 +struct _uidControlBlock {
12625 + struct _uidControlBlock *parent;
12626 + struct _uidControlBlock *nextChild;
12627 + struct _uidControlBlock *type; //(0x8)
12628 + u32 UID; //(0xC)
12629 + char *name; //(0x10)
12630 + unsigned char unk;
12631 + unsigned char size; // Size in words
12632 + short attribute;
12633 + struct _uidControlBlock *nextEntry;
12634 +} __attribute__((packed));
12635 +typedef struct _uidControlBlock uidControlBlock;
12637 +/**
12638 + * Get a UID control block
12640 + * @param uid - The UID to find
12641 + * @param block - Pointer to hold the pointer to the block
12643 + * @return 0 on success
12644 + */
12645 +int sceKernelGetUIDcontrolBlock(SceUID uid, uidControlBlock** block);
12647 +/**
12648 + * Get a UID control block on a particular type
12650 + * @param uid - The UID to find
12651 + * @param type - Pointer to the type UID block
12652 + * @param block - Pointer to hold the pointer to the block
12654 + * @return 0 on success
12655 + */
12656 +int sceKernelGetUIDcontrolBlockWithType(SceUID uid, uidControlBlock* type, uidControlBlock** block);
12658 +/**
12659 + * Get the root of the UID tree (1.5+ only)
12661 + * @return Pointer to the UID tree root
12662 + */
12663 +uidControlBlock* SysMemForKernel_536AD5E1(void);
12665 +/**
12666 + * Delete a UID
12668 + * @param uid - The UID to delete
12670 + * @return 0 on success
12671 + */
12672 +int sceKernelDeleteUID(SceUID uid);
12674 +/**
12675 + * Get the model of PSP
12677 + * @return <= 0 original, 1 slim
12678 + */
12679 +int sceKernelGetModel(void);
12681 +/**
12682 + * Set the version of the SDK with which the caller was compiled.
12683 + * Version numbers are as for sceKernelDevkitVersion().
12685 + * @return 0 on success, < 0 on error.
12686 + */
12687 +int sceKernelSetCompiledSdkVersion(int version);
12689 +/**
12690 + * Get the SDK version set with sceKernelSetCompiledSdkVersion().
12692 + * @return Version number, or 0 if unset.
12693 + */
12694 +int sceKernelGetCompiledSdkVersion(void);
12696 +#ifdef __cplusplus
12698 +#endif
12700 +/**@}*/
12702 +#endif /* PSPSYSMEMKERNEL_H */
12703 diff --git a/newlib/psp/include/pspsysreg.h b/newlib/psp/include/pspsysreg.h
12704 new file mode 100644
12705 index 0000000..c1cad61
12706 --- /dev/null
12707 +++ b/newlib/psp/include/pspsysreg.h
12708 @@ -0,0 +1,82 @@
12710 + * PSP Software Development Kit - https://github.com/pspdev
12711 + * -----------------------------------------------------------------------
12712 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12714 + * pspsysreg.h - Interface to sceSysreg_driver.
12716 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
12717 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
12718 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
12720 + */
12722 +#ifndef PSPSYSREG_H
12723 +#define PSPSYSREG_H
12725 +#include <pspkerneltypes.h>
12727 +/** @defgroup Sysreg Interface to the sceSysreg_driver library.
12728 + */
12730 +#ifdef __cplusplus
12731 +extern "C" {
12732 +#endif
12734 +/** @addtogroup Sysreg Interface to the sceSysreg_driver library. */
12735 +/**@{*/
12737 +/**
12738 + * Enable the ME reset.
12740 + * @return < 0 on error.
12741 + */
12742 +int sceSysregMeResetEnable(void);
12744 +/**
12745 + * Disable the ME reset.
12747 + * @return < 0 on error.
12748 + */
12749 +int sceSysregMeResetDisable(void);
12751 +/**
12752 + * Enable the VME reset.
12754 + * @return < 0 on error.
12755 + */
12756 +int sceSysregVmeResetEnable(void);
12758 +/**
12759 + * Disable the VME reset.
12761 + * @return < 0 on error.
12762 + */
12763 +int sceSysregVmeResetDisable(void);
12765 +/**
12766 + * Enable the ME bus clock.
12768 + * @return < 0 on error.
12769 + */
12770 +int sceSysregMeBusClockEnable(void);
12772 +/**
12773 + * Disable the ME bus clock.
12775 + * @return < 0 on error.
12776 + */
12777 +int sceSysregMeBusClockDisable(void);
12779 +/**
12780 + * Get the PSP's Tachyon version.
12781 + */
12782 +int sceSysregGetTachyonVersion(void);
12784 +/**@}*/
12786 +#ifdef __cplusplus
12788 +#endif
12790 +#endif /* PSPLOADCORE_H */
12791 diff --git a/newlib/psp/include/pspsystimer.h b/newlib/psp/include/pspsystimer.h
12792 new file mode 100644
12793 index 0000000..1437c80
12794 --- /dev/null
12795 +++ b/newlib/psp/include/pspsystimer.h
12796 @@ -0,0 +1,92 @@
12798 + * PSP Software Development Kit - https://github.com/pspdev
12799 + * -----------------------------------------------------------------------
12800 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12802 + * pspsystimer.h - Prototypes for the sceSystimer library.
12804 + * Copyright (c) 2007 Iaroslav Gaponenko <adrahil@gmail.com>
12806 + */
12808 +#ifndef __SYSTIMER_H__
12809 +#define __SYSTIMER_H__
12811 +#ifdef __cplusplus
12812 +extern "C" {
12813 +#endif
12815 +typedef int SceSysTimerId;
12817 +/**
12818 + * Allocate a new SysTimer timer instance.
12820 + * @return SysTimerId on success, < 0 on error
12821 + */
12822 +SceSysTimerId sceSTimerAlloc(void);
12824 +/**
12825 + * Free an instance of a SysTimer timer.
12827 + * @param timer - The timer id.
12829 + */
12830 +void sceSTimerFree(SceSysTimerId timer);
12832 +/**
12833 + * Start the SysTimer timer count.
12835 + * @param timer - The timer id.
12837 + */
12838 +void sceSTimerStartCount(SceSysTimerId timer);
12840 +/**
12841 + * Stop the current SysTimer timer count.
12843 + * @param timer - The timer id.
12845 + */
12846 +void sceSTimerStopCount(SceSysTimerId timer);
12848 +/**
12849 + * Reset the current SysTimer timer count.
12851 + * @param timer - The timer id.
12853 + */
12854 +void sceSTimerResetCount(SceSysTimerId timer);
12856 +/**
12857 + * Get the current SysTimer timer count.
12859 + * @param timer - The timer id.
12860 + * @param count - The pointer to an integer into which the count will be written.
12862 + */
12863 +void sceSTimerGetCount(SceSysTimerId timer, int* count);
12865 +/**
12866 + * Setup a SysTimer handler
12868 + * @param timer - The timer id.
12869 + * @param cycle - The timer cycle in microseconds (???). Maximum: 4194303 which represents ~1/10 seconds.
12870 + * @param handler - The handler function. Has to return -1.
12871 + * @param unk1 - Unknown. Pass 0.
12873 + */
12874 +void sceSTimerSetHandler(SceSysTimerId timer, int cycle, int (*handler)(void), int unk1);
12876 +/* Unknown functions. */
12877 +//probably something to set the cycle of an active timer.
12878 +void SysTimerForKernel_53231A15(SceSysTimerId timer, int unk1);
12879 +//more complex. computes some ratio (unk2/unk1) and saves both parameters into the hardware registers. Might be some sort of scaling factor?
12880 +void SysTimerForKernel_B53534B4(SceSysTimerId timer, int unk1, int unk2);
12884 +#ifdef __cplusplus
12886 +#endif
12888 +#endif
12889 diff --git a/newlib/psp/include/pspthreadman.h b/newlib/psp/include/pspthreadman.h
12890 new file mode 100644
12891 index 0000000..f35c9a2
12892 --- /dev/null
12893 +++ b/newlib/psp/include/pspthreadman.h
12894 @@ -0,0 +1,1836 @@
12896 + * PSP Software Development Kit - https://github.com/pspdev
12897 + * -----------------------------------------------------------------------
12898 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
12900 + * pspthreadman.h - Library imports for the kernel threading library.
12902 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
12903 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
12904 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
12905 + * Copyright (c) 2005 Florin Sasu
12907 + */
12908 +#ifndef __THREADMAN_H__
12909 +#define __THREADMAN_H__
12911 +#include <psptypes.h>
12912 +#include <pspkerneltypes.h>
12913 +/* Include for profile register definitions */
12914 +#include <pspdebug.h>
12916 +/* Note: Some of the structures, types, and definitions in this file were
12917 + extrapolated from symbolic debugging information found in the Japanese
12918 + version of Puzzle Bobble. */
12920 +/** @defgroup ThreadMan Thread Manager Library
12921 + * Library imports for the kernel threading library.
12922 + */
12924 +#ifdef __cplusplus
12925 +extern "C" {
12926 +#endif
12928 +/** @addtogroup ThreadMan */
12930 +/**@{*/
12932 +/** 64-bit system clock type. */
12933 +typedef struct SceKernelSysClock {
12934 + SceUInt32 low;
12935 + SceUInt32 hi;
12936 +} SceKernelSysClock;
12938 +/** Attribute for threads. */
12939 +enum PspThreadAttributes
12941 + /** Enable VFPU access for the thread. */
12942 + PSP_THREAD_ATTR_VFPU = 0x00004000,
12943 + /** Start the thread in user mode (done automatically
12944 + if the thread creating it is in user mode). */
12945 + PSP_THREAD_ATTR_USER = 0x80000000,
12946 + /** Thread is part of the USB/WLAN API. */
12947 + PSP_THREAD_ATTR_USBWLAN = 0xa0000000,
12948 + /** Thread is part of the VSH API. */
12949 + PSP_THREAD_ATTR_VSH = 0xc0000000,
12950 + /** Allow using scratchpad memory for a thread, NOT USABLE ON V1.0 */
12951 + PSP_THREAD_ATTR_SCRATCH_SRAM = 0x00008000,
12952 + /** Disables filling the stack with 0xFF on creation */
12953 + PSP_THREAD_ATTR_NO_FILLSTACK = 0x00100000,
12954 + /** Clear the stack when the thread is deleted */
12955 + PSP_THREAD_ATTR_CLEAR_STACK = 0x00200000,
12958 +/* Maintained for compatibility with older versions of PSPSDK. */
12959 +#define THREAD_ATTR_VFPU PSP_THREAD_ATTR_VFPU
12960 +#define THREAD_ATTR_USER PSP_THREAD_ATTR_USER
12963 +/* Threads. */
12965 +typedef int (*SceKernelThreadEntry)(SceSize args, void *argp);
12967 +/** Additional options used when creating threads. */
12968 +typedef struct SceKernelThreadOptParam {
12969 + /** Size of the ::SceKernelThreadOptParam structure. */
12970 + SceSize size;
12971 + /** UID of the memory block (?) allocated for the thread's stack. */
12972 + SceUID stackMpid;
12973 +} SceKernelThreadOptParam;
12975 +/** Structure to hold the status information for a thread
12976 + * @see sceKernelReferThreadStatus
12977 + */
12978 +typedef struct SceKernelThreadInfo {
12979 + /** Size of the structure */
12980 + SceSize size;
12981 + /** Nul terminated name of the thread */
12982 + char name[32];
12983 + /** Thread attributes */
12984 + SceUInt attr;
12985 + /** Thread status */
12986 + int status;
12987 + /** Thread entry point */
12988 + SceKernelThreadEntry entry;
12989 + /** Thread stack pointer */
12990 + void * stack;
12991 + /** Thread stack size */
12992 + int stackSize;
12993 + /** Pointer to the gp */
12994 + void * gpReg;
12995 + /** Initial priority */
12996 + int initPriority;
12997 + /** Current priority */
12998 + int currentPriority;
12999 + /** Wait type */
13000 + int waitType;
13001 + /** Wait id */
13002 + SceUID waitId;
13003 + /** Wakeup count */
13004 + int wakeupCount;
13005 + /** Exit status of the thread */
13006 + int exitStatus;
13007 + /** Number of clock cycles run */
13008 + SceKernelSysClock runClocks;
13009 + /** Interrupt preemption count */
13010 + SceUInt intrPreemptCount;
13011 + /** Thread preemption count */
13012 + SceUInt threadPreemptCount;
13013 + /** Release count */
13014 + SceUInt releaseCount;
13015 +} SceKernelThreadInfo;
13017 +/** Statistics about a running thread.
13018 + * @see sceKernelReferThreadRunStatus.
13019 + */
13020 +typedef struct SceKernelThreadRunStatus {
13021 + SceSize size;
13022 + int status;
13023 + int currentPriority;
13024 + int waitType;
13025 + int waitId;
13026 + int wakeupCount;
13027 + SceKernelSysClock runClocks;
13028 + SceUInt intrPreemptCount;
13029 + SceUInt threadPreemptCount;
13030 + SceUInt releaseCount;
13031 +} SceKernelThreadRunStatus;
13033 +/* Sure there must be more than this, but haven't seen them */
13034 +enum PspThreadStatus
13036 + PSP_THREAD_RUNNING = 1,
13037 + PSP_THREAD_READY = 2,
13038 + PSP_THREAD_WAITING = 4,
13039 + PSP_THREAD_SUSPEND = 8,
13040 + PSP_THREAD_STOPPED = 16,
13041 + PSP_THREAD_KILLED = 32, /* Thread manager has killed the thread (stack overflow) */
13044 +/**
13045 + * Create a thread
13047 + * @par Example:
13048 + * @code
13049 + * SceUID thid;
13050 + * thid = sceKernelCreateThread("my_thread", threadFunc, 0x18, 0x10000, 0, NULL);
13051 + * @endcode
13053 + * @param name - An arbitrary thread name.
13054 + * @param entry - The thread function to run when started.
13055 + * @param initPriority - The initial priority of the thread. Less if higher priority.
13056 + * @param stackSize - The size of the initial stack.
13057 + * @param attr - The thread attributes, zero or more of ::PspThreadAttributes.
13058 + * @param option - Additional options specified by ::SceKernelThreadOptParam.
13060 + * @return UID of the created thread, or an error code.
13061 + */
13062 +SceUID sceKernelCreateThread(const char *name, SceKernelThreadEntry entry, int initPriority,
13063 + int stackSize, SceUInt attr, SceKernelThreadOptParam *option);
13065 +/**
13066 + * Delate a thread
13068 + * @param thid - UID of the thread to be deleted.
13070 + * @return < 0 on error.
13071 + */
13072 +int sceKernelDeleteThread(SceUID thid);
13074 +/**
13075 + * Start a created thread
13077 + * @param thid - Thread id from sceKernelCreateThread
13078 + * @param arglen - Length of the data pointed to by argp, in bytes
13079 + * @param argp - Pointer to the arguments.
13080 + */
13081 +int sceKernelStartThread(SceUID thid, SceSize arglen, void *argp);
13083 +/**
13084 + * Exit a thread
13086 + * @param status - Exit status.
13087 + */
13088 +int sceKernelExitThread(int status);
13090 +/**
13091 + * Exit a thread and delete itself.
13093 + * @param status - Exit status
13094 + */
13095 +int sceKernelExitDeleteThread(int status);
13097 +/**
13098 + * Terminate a thread.
13100 + * @param thid - UID of the thread to terminate.
13102 + * @return Success if >= 0, an error if < 0.
13103 + */
13104 +int sceKernelTerminateThread(SceUID thid);
13106 +/**
13107 + * Terminate and delete a thread.
13109 + * @param thid - UID of the thread to terminate and delete.
13111 + * @return Success if >= 0, an error if < 0.
13112 + */
13113 +int sceKernelTerminateDeleteThread(SceUID thid);
13115 +/**
13116 + * Suspend the dispatch thread
13118 + * @return The current state of the dispatch thread, < 0 on error
13119 + */
13120 +int sceKernelSuspendDispatchThread(void);
13122 +/**
13123 + * Resume the dispatch thread
13125 + * @param state - The state of the dispatch thread
13126 + * (from ::sceKernelSuspendDispatchThread)
13128 + * @return 0 on success, < 0 on error
13129 + */
13130 +int sceKernelResumeDispatchThread(int state);
13132 +/**
13133 + * Sleep thread
13135 + * @return < 0 on error.
13136 + */
13137 +int sceKernelSleepThread(void);
13139 +/**
13140 + * Sleep thread but service any callbacks as necessary
13142 + * @par Example:
13143 + * @code
13144 + * // Once all callbacks have been setup call this function
13145 + * sceKernelSleepThreadCB();
13146 + * @endcode
13147 + */
13148 +int sceKernelSleepThreadCB(void);
13150 +/**
13151 + * Wake a thread previously put into the sleep state.
13153 + * @param thid - UID of the thread to wake.
13155 + * @return Success if >= 0, an error if < 0.
13156 + */
13157 +int sceKernelWakeupThread(SceUID thid);
13159 +/**
13160 + * Cancel a thread that was to be woken with ::sceKernelWakeupThread.
13162 + * @param thid - UID of the thread to cancel.
13164 + * @return Success if >= 0, an error if < 0.
13165 + */
13166 +int sceKernelCancelWakeupThread(SceUID thid);
13168 +/**
13169 + * Suspend a thread.
13171 + * @param thid - UID of the thread to suspend.
13173 + * @return Success if >= 0, an error if < 0.
13174 + */
13175 +int sceKernelSuspendThread(SceUID thid);
13177 +/**
13178 + * Resume a thread previously put into a suspended state with ::sceKernelSuspendThread.
13180 + * @param thid - UID of the thread to resume.
13182 + * @return Success if >= 0, an error if < 0.
13183 + */
13184 +int sceKernelResumeThread(SceUID thid);
13186 +/**
13187 + * Wait until a thread has ended.
13189 + * @param thid - Id of the thread to wait for.
13190 + * @param timeout - Timeout in microseconds (assumed).
13192 + * @return < 0 on error.
13193 + */
13194 +int sceKernelWaitThreadEnd(SceUID thid, SceUInt *timeout);
13196 +/**
13197 + * Wait until a thread has ended and handle callbacks if necessary.
13199 + * @param thid - Id of the thread to wait for.
13200 + * @param timeout - Timeout in microseconds (assumed).
13202 + * @return < 0 on error.
13203 + */
13204 +int sceKernelWaitThreadEndCB(SceUID thid, SceUInt *timeout);
13206 +/**
13207 + * Delay the current thread by a specified number of microseconds
13209 + * @param delay - Delay in microseconds.
13211 + * @par Example:
13212 + * @code
13213 + * sceKernelDelayThread(1000000); // Delay for a second
13214 + * @endcode
13215 + */
13216 +int sceKernelDelayThread(SceUInt delay);
13218 +/**
13219 + * Delay the current thread by a specified number of microseconds and handle any callbacks.
13221 + * @param delay - Delay in microseconds.
13223 + * @par Example:
13224 + * @code
13225 + * sceKernelDelayThread(1000000); // Delay for a second
13226 + * @endcode
13227 + */
13228 +int sceKernelDelayThreadCB(SceUInt delay);
13230 +/**
13231 + * Delay the current thread by a specified number of sysclocks
13233 + * @param delay - Delay in sysclocks
13235 + * @return 0 on success, < 0 on error
13236 + */
13237 +int sceKernelDelaySysClockThread(SceKernelSysClock *delay);
13239 +/**
13240 + * Delay the current thread by a specified number of sysclocks handling callbacks
13242 + * @param delay - Delay in sysclocks
13244 + * @return 0 on success, < 0 on error
13246 + */
13247 +int sceKernelDelaySysClockThreadCB(SceKernelSysClock *delay);
13249 +/**
13250 + * Modify the attributes of the current thread.
13252 + * @param unknown - Set to 0.
13253 + * @param attr - The thread attributes to modify. One of ::PspThreadAttributes.
13255 + * @return < 0 on error.
13256 + */
13257 +int sceKernelChangeCurrentThreadAttr(int unknown, SceUInt attr);
13259 +/**
13260 + * Change the threads current priority.
13261 + *
13262 + * @param thid - The ID of the thread (from sceKernelCreateThread or sceKernelGetThreadId)
13263 + * @param priority - The new priority (the lower the number the higher the priority)
13265 + * @par Example:
13266 + * @code
13267 + * int thid = sceKernelGetThreadId();
13268 + * // Change priority of current thread to 16
13269 + * sceKernelChangeThreadPriority(thid, 16);
13270 + * @endcode
13272 + * @return 0 if successful, otherwise the error code.
13273 + */
13274 +int sceKernelChangeThreadPriority(SceUID thid, int priority);
13276 +/**
13277 + * Rotate thread ready queue at a set priority
13279 + * @param priority - The priority of the queue
13280 + *
13281 + * @return 0 on success, < 0 on error.
13282 + */
13283 +int sceKernelRotateThreadReadyQueue(int priority);
13285 +/**
13286 + * Release a thread in the wait state.
13288 + * @param thid - The UID of the thread.
13290 + * @return 0 on success, < 0 on error
13291 + */
13292 +int sceKernelReleaseWaitThread(SceUID thid);
13294 +/**
13295 + * Get the current thread Id
13297 + * @return The thread id of the calling thread.
13298 + */
13299 +int sceKernelGetThreadId(void);
13301 +/**
13302 + * Get the current priority of the thread you are in.
13304 + * @return The current thread priority
13305 + */
13306 +int sceKernelGetThreadCurrentPriority(void);
13308 +/**
13309 + * Get the exit status of a thread.
13311 + * @param thid - The UID of the thread to check.
13313 + * @return The exit status
13314 + */
13315 +int sceKernelGetThreadExitStatus(SceUID thid);
13317 +/**
13318 + * Check the thread stack?
13320 + * @return Unknown.
13321 + */
13322 +int sceKernelCheckThreadStack(void);
13324 +/**
13325 + * Get the free stack size for a thread.
13327 + * @param thid - The thread ID. Seem to take current thread
13328 + * if set to 0.
13330 + * @return The free size.
13331 + */
13332 +int sceKernelGetThreadStackFreeSize(SceUID thid);
13334 +/**
13335 + * Get the status information for the specified thread.
13336 + *
13337 + * @param thid - Id of the thread to get status
13338 + * @param info - Pointer to the info structure to receive the data.
13339 + * Note: The structures size field should be set to
13340 + * sizeof(SceKernelThreadInfo) before calling this function.
13342 + * @par Example:
13343 + * @code
13344 + * SceKernelThreadInfo status;
13345 + * status.size = sizeof(SceKernelThreadInfo);
13346 + * if(sceKernelReferThreadStatus(thid, &status) == 0)
13347 + * { Do something... }
13348 + * @endcode
13349 + * @return 0 if successful, otherwise the error code.
13350 + */
13351 +int sceKernelReferThreadStatus(SceUID thid, SceKernelThreadInfo *info);
13353 +/**
13354 + * Retrive the runtime status of a thread.
13356 + * @param thid - UID of the thread to retrive status.
13357 + * @param status - Pointer to a ::SceKernelThreadRunStatus struct to receive the runtime status.
13359 + * @return 0 if successful, otherwise the error code.
13360 + */
13361 +int sceKernelReferThreadRunStatus(SceUID thid, SceKernelThreadRunStatus *status);
13364 +/* Semaphores. */
13366 +/** Additional options used when creating semaphores. */
13367 +typedef struct SceKernelSemaOptParam {
13368 + /** Size of the ::SceKernelSemaOptParam structure. */
13369 + SceSize size;
13370 +} SceKernelSemaOptParam;
13372 +/** Current state of a semaphore.
13373 + * @see sceKernelReferSemaStatus.
13374 + */
13375 +typedef struct SceKernelSemaInfo {
13376 + /** Size of the ::SceKernelSemaInfo structure. */
13377 + SceSize size;
13378 + /** NUL-terminated name of the semaphore. */
13379 + char name[32];
13380 + /** Attributes. */
13381 + SceUInt attr;
13382 + /** The initial count the semaphore was created with. */
13383 + int initCount;
13384 + /** The current count. */
13385 + int currentCount;
13386 + /** The maximum count. */
13387 + int maxCount;
13388 + /** The number of threads waiting on the semaphore. */
13389 + int numWaitThreads;
13390 +} SceKernelSemaInfo;
13392 +/**
13393 + * Creates a new semaphore
13395 + * @par Example:
13396 + * @code
13397 + * int semaid;
13398 + * semaid = sceKernelCreateSema("MyMutex", 0, 1, 1, 0);
13399 + * @endcode
13401 + * @param name - Specifies the name of the sema
13402 + * @param attr - Sema attribute flags (normally set to 0)
13403 + * @param initVal - Sema initial value
13404 + * @param maxVal - Sema maximum value
13405 + * @param option - Sema options (normally set to 0)
13406 + * @return A semaphore id
13407 + */
13408 +SceUID sceKernelCreateSema(const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option);
13410 +/**
13411 + * Destroy a semaphore
13413 + * @param semaid - The semaid returned from a previous create call.
13414 + * @return Returns the value 0 if its succesful otherwise -1
13415 + */
13416 +int sceKernelDeleteSema(SceUID semaid);
13418 +/**
13419 + * Send a signal to a semaphore
13421 + * @par Example:
13422 + * @code
13423 + * // Signal the sema
13424 + * sceKernelSignalSema(semaid, 1);
13425 + * @endcode
13427 + * @param semaid - The sema id returned from sceKernelCreateSema
13428 + * @param signal - The amount to signal the sema (i.e. if 2 then increment the sema by 2)
13430 + * @return < 0 On error.
13431 + */
13432 +int sceKernelSignalSema(SceUID semaid, int signal);
13434 +/**
13435 + * Lock a semaphore
13437 + * @par Example:
13438 + * @code
13439 + * sceKernelWaitSema(semaid, 1, 0);
13440 + * @endcode
13442 + * @param semaid - The sema id returned from sceKernelCreateSema
13443 + * @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
13444 + * @param timeout - Timeout in microseconds (assumed).
13446 + * @return < 0 on error.
13447 + */
13448 +int sceKernelWaitSema(SceUID semaid, int signal, SceUInt *timeout);
13450 +/**
13451 + * Lock a semaphore a handle callbacks if necessary.
13453 + * @par Example:
13454 + * @code
13455 + * sceKernelWaitSemaCB(semaid, 1, 0);
13456 + * @endcode
13458 + * @param semaid - The sema id returned from sceKernelCreateSema
13459 + * @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
13460 + * @param timeout - Timeout in microseconds (assumed).
13462 + * @return < 0 on error.
13463 + */
13464 +int sceKernelWaitSemaCB(SceUID semaid, int signal, SceUInt *timeout);
13466 +/**
13467 + * Poll a sempahore.
13469 + * @param semaid - UID of the semaphore to poll.
13470 + * @param signal - The value to test for.
13472 + * @return < 0 on error.
13473 + */
13474 +int sceKernelPollSema(SceUID semaid, int signal);
13476 +/**
13477 + * Retrieve information about a semaphore.
13479 + * @param semaid - UID of the semaphore to retrieve info for.
13480 + * @param info - Pointer to a ::SceKernelSemaInfo struct to receive the info.
13482 + * @return < 0 on error.
13483 + */
13484 +int sceKernelReferSemaStatus(SceUID semaid, SceKernelSemaInfo *info);
13486 +/** Struct as workarea for lightweight mutex */
13487 +typedef struct {
13488 + /** Count */
13489 + int lockLevel;
13490 + /** Locking thread */
13491 + SceUID lockThread;
13492 + /** Attribute */
13493 + int attr;
13494 + /** Number of waiting threads */
13495 + int numWaitThreads;
13496 + /** UID */
13497 + SceUID uid;
13498 + /** Padding */
13499 + int pad[3];
13500 +} SceLwMutexWorkarea;
13502 +/**
13503 + * Create a lightweight mutex
13505 + * @param workarea - The pointer to the workarea
13506 + * @param name - The name of the lightweight mutex
13507 + * @param attr -
13508 + * @param initialCount - THe inital value of the mutex
13509 + * @param optionsPTr - Other optioons for mutex
13511 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes
13512 + */
13513 +int sceKernelCreateLwMutex(SceLwMutexWorkarea *workarea, const char *name, u32 attr, int initialCount, u32 *optionsPtr);
13515 +/**
13516 + * Delete a lightweight mutex
13518 + * @param workarea - The pointer to the workarea
13520 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes
13521 + */
13522 +int sceKernelDeleteLwMutex(SceLwMutexWorkarea *workarea);
13524 +/**
13525 + * Try to lock a lightweight mutex
13527 + * @param workarea - The pointer to the workarea
13528 + * @param lockCount - value of increase the lock counter
13530 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes
13531 + */
13532 +int sceKernelTryLockLwMutex(SceLwMutexWorkarea *workarea, int lockCount);
13534 +/**
13535 + * Lock a lightweight mutex
13537 + * @param workarea - The pointer to the workarea
13538 + * @param lockCount - value of increase the lock counter
13539 + * @param pTimeout - The pointer for timeout waiting
13541 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes
13542 + */
13543 +int sceKernelLockLwMutex(SceLwMutexWorkarea *workarea, int lockCount, unsigned int *pTimeout);
13545 +/**
13546 + * Lock a lightweight mutex
13548 + * @param workarea - The pointer to the workarea
13549 + * @param name - The name of the lightweight mutex
13550 + * @param lockCount - value of decrease the lock counter
13552 + * @return 0 on success, otherwise one of ::PspKernelErrorCodes
13553 + */
13554 +int sceKernelUnlockLwMutex(SceLwMutexWorkarea *workarea, int lockCount);
13556 +/* Event flags. */
13558 +/** Structure to hold the event flag information */
13559 +typedef struct SceKernelEventFlagInfo {
13560 + SceSize size;
13561 + char name[32];
13562 + SceUInt attr;
13563 + SceUInt initPattern;
13564 + SceUInt currentPattern;
13565 + int numWaitThreads;
13566 +} SceKernelEventFlagInfo;
13568 +struct SceKernelEventFlagOptParam {
13569 + SceSize size;
13572 +typedef struct SceKernelEventFlagOptParam SceKernelEventFlagOptParam;
13574 +/** Event flag creation attributes */
13575 +enum PspEventFlagAttributes
13577 + /** Allow the event flag to be waited upon by multiple threads */
13578 + PSP_EVENT_WAITMULTIPLE = 0x200
13581 +/** Event flag wait types */
13582 +enum PspEventFlagWaitTypes
13584 + /** Wait for all bits in the pattern to be set */
13585 + PSP_EVENT_WAITAND = 0,
13586 + /** Wait for one or more bits in the pattern to be set */
13587 + PSP_EVENT_WAITOR = 1,
13588 + /** Clear the wait pattern when it matches */
13589 + PSP_EVENT_WAITCLEAR = 0x20
13592 +/**
13593 + * Create an event flag.
13595 + * @param name - The name of the event flag.
13596 + * @param attr - Attributes from ::PspEventFlagAttributes
13597 + * @param bits - Initial bit pattern.
13598 + * @param opt - Options, set to NULL
13599 + * @return < 0 on error. >= 0 event flag id.
13601 + * @par Example:
13602 + * @code
13603 + * int evid;
13604 + * evid = sceKernelCreateEventFlag("wait_event", 0, 0, 0);
13605 + * @endcode
13606 + */
13607 +SceUID sceKernelCreateEventFlag(const char *name, int attr, int bits, SceKernelEventFlagOptParam *opt);
13609 +/**
13610 + * Set an event flag bit pattern.
13612 + * @param evid - The event id returned by sceKernelCreateEventFlag.
13613 + * @param bits - The bit pattern to set.
13615 + * @return < 0 On error
13616 + */
13617 +int sceKernelSetEventFlag(SceUID evid, u32 bits);
13619 +/**
13620 + * Clear a event flag bit pattern
13622 + * @param evid - The event id returned by ::sceKernelCreateEventFlag
13623 + * @param bits - The bits to clean
13625 + * @return < 0 on Error
13626 + */
13627 +int sceKernelClearEventFlag(SceUID evid, u32 bits);
13629 +/**
13630 + * Poll an event flag for a given bit pattern.
13632 + * @param evid - The event id returned by sceKernelCreateEventFlag.
13633 + * @param bits - The bit pattern to poll for.
13634 + * @param wait - Wait type, one or more of ::PspEventFlagWaitTypes or'ed together
13635 + * @param outBits - The bit pattern that was matched.
13636 + * @return < 0 On error
13637 + */
13638 +int sceKernelPollEventFlag(int evid, u32 bits, u32 wait, u32 *outBits);
13640 +/**
13641 + * Wait for an event flag for a given bit pattern.
13643 + * @param evid - The event id returned by sceKernelCreateEventFlag.
13644 + * @param bits - The bit pattern to poll for.
13645 + * @param wait - Wait type, one or more of ::PspEventFlagWaitTypes or'ed together
13646 + * @param outBits - The bit pattern that was matched.
13647 + * @param timeout - Timeout in microseconds
13648 + * @return < 0 On error
13649 + */
13650 +int sceKernelWaitEventFlag(int evid, u32 bits, u32 wait, u32 *outBits, SceUInt *timeout);
13652 +/**
13653 + * Wait for an event flag for a given bit pattern with callback.
13655 + * @param evid - The event id returned by sceKernelCreateEventFlag.
13656 + * @param bits - The bit pattern to poll for.
13657 + * @param wait - Wait type, one or more of ::PspEventFlagWaitTypes or'ed together
13658 + * @param outBits - The bit pattern that was matched.
13659 + * @param timeout - Timeout in microseconds
13660 + * @return < 0 On error
13661 + */
13662 +int sceKernelWaitEventFlagCB(int evid, u32 bits, u32 wait, u32 *outBits, SceUInt *timeout);
13664 +/**
13665 + * Delete an event flag
13667 + * @param evid - The event id returned by sceKernelCreateEventFlag.
13669 + * @return < 0 On error
13670 + */
13671 +int sceKernelDeleteEventFlag(int evid);
13673 +/**
13674 + * Get the status of an event flag.
13675 + *
13676 + * @param event - The UID of the event.
13677 + * @param status - A pointer to a ::SceKernelEventFlagInfo structure.
13679 + * @return < 0 on error.
13680 + */
13681 +int sceKernelReferEventFlagStatus(SceUID event, SceKernelEventFlagInfo *status);
13684 +/* Message boxes. */
13686 +/** Additional options used when creating messageboxes. */
13687 +typedef struct SceKernelMbxOptParam {
13688 + /** Size of the ::SceKernelMbxOptParam structure. */
13689 + SceSize size;
13690 +} SceKernelMbxOptParam;
13692 +/** Current state of a messagebox.
13693 + * @see sceKernelReferMbxStatus.
13694 + */
13695 +typedef struct SceKernelMbxInfo {
13696 + /** Size of the ::SceKernelMbxInfo structure. */
13697 + SceSize size;
13698 + /** NUL-terminated name of the messagebox. */
13699 + char name[32];
13700 + /** Attributes. */
13701 + SceUInt attr;
13702 + /** The number of threads waiting on the messagebox. */
13703 + int numWaitThreads;
13704 + /** Number of messages currently in the messagebox. */
13705 + int numMessages;
13706 + /** The message currently at the head of the queue. */
13707 + void *firstMessage;
13708 +} SceKernelMbxInfo;
13710 +/**
13711 + * Header for a message box packet
13712 + */
13713 +typedef struct SceKernelMsgPacket {
13714 + /** Pointer to next msg (used by the kernel) */
13715 + struct SceKernelMsgPacket *next;
13716 + /** Priority ? */
13717 + SceUChar msgPriority;
13718 + SceUChar dummy[3];
13719 + /** After this can be any user defined data */
13720 +} SceKernelMsgPacket;
13722 +/**
13723 + * Creates a new messagebox
13725 + * @par Example:
13726 + * @code
13727 + * int mbxid;
13728 + * mbxid = sceKernelCreateMbx("MyMessagebox", 0, NULL);
13729 + * @endcode
13731 + * @param name - Specifies the name of the mbx
13732 + * @param attr - Mbx attribute flags (normally set to 0)
13733 + * @param option - Mbx options (normally set to NULL)
13734 + * @return A messagebox id
13735 + */
13736 +SceUID sceKernelCreateMbx(const char *name, SceUInt attr, SceKernelMbxOptParam *option);
13738 +/**
13739 + * Destroy a messagebox
13741 + * @param mbxid - The mbxid returned from a previous create call.
13742 + * @return Returns the value 0 if its succesful otherwise an error code
13743 + */
13744 +int sceKernelDeleteMbx(SceUID mbxid);
13746 +/**
13747 + * Send a message to a messagebox
13749 + * @par Example:
13750 + * @code
13751 + * struct MyMessage {
13752 + * SceKernelMsgPacket header;
13753 + * char text[8];
13754 + * };
13756 + * struct MyMessage msg = { {0}, "Hello" };
13757 + * // Send the message
13758 + * sceKernelSendMbx(mbxid, (void*) &msg);
13759 + * @endcode
13761 + * @param mbxid - The mbx id returned from sceKernelCreateMbx
13762 + * @param message - A message to be forwarded to the receiver.
13763 + * The start of the message should be the
13764 + * ::SceKernelMsgPacket structure, the rest
13766 + * @return < 0 On error.
13767 + */
13768 +int sceKernelSendMbx(SceUID mbxid, void *message);
13770 +/**
13771 + * Wait for a message to arrive in a messagebox
13773 + * @par Example:
13774 + * @code
13775 + * void *msg;
13776 + * sceKernelReceiveMbx(mbxid, &msg, NULL);
13777 + * @endcode
13779 + * @param mbxid - The mbx id returned from sceKernelCreateMbx
13780 + * @param pmessage - A pointer to where a pointer to the
13781 + * received message should be stored
13782 + * @param timeout - Timeout in microseconds
13784 + * @return < 0 on error.
13785 + */
13786 +int sceKernelReceiveMbx(SceUID mbxid, void **pmessage, SceUInt *timeout);
13788 +/**
13789 + * Wait for a message to arrive in a messagebox and handle callbacks if necessary.
13791 + * @par Example:
13792 + * @code
13793 + * void *msg;
13794 + * sceKernelReceiveMbxCB(mbxid, &msg, NULL);
13795 + * @endcode
13797 + * @param mbxid - The mbx id returned from sceKernelCreateMbx
13798 + * @param pmessage - A pointer to where a pointer to the
13799 + * received message should be stored
13800 + * @param timeout - Timeout in microseconds
13802 + * @return < 0 on error.
13803 + */
13804 +int sceKernelReceiveMbxCB(SceUID mbxid, void **pmessage, SceUInt *timeout);
13806 +/**
13807 + * Check if a message has arrived in a messagebox
13809 + * @par Example:
13810 + * @code
13811 + * void *msg;
13812 + * sceKernelPollMbx(mbxid, &msg);
13813 + * @endcode
13815 + * @param mbxid - The mbx id returned from sceKernelCreateMbx
13816 + * @param pmessage - A pointer to where a pointer to the
13817 + * received message should be stored
13819 + * @return < 0 on error (SCE_KERNEL_ERROR_MBOX_NOMSG if the mbx is empty).
13820 + */
13821 +int sceKernelPollMbx(SceUID mbxid, void **pmessage);
13823 +/**
13824 + * Abort all wait operations on a messagebox
13826 + * @par Example:
13827 + * @code
13828 + * sceKernelCancelReceiveMbx(mbxid, NULL);
13829 + * @endcode
13831 + * @param mbxid - The mbx id returned from sceKernelCreateMbx
13832 + * @param pnum - A pointer to where the number of threads which
13833 + * were waiting on the mbx should be stored (NULL
13834 + * if you don't care)
13836 + * @return < 0 on error
13837 + */
13838 +int sceKernelCancelReceiveMbx(SceUID mbxid, int *pnum);
13840 +/**
13841 + * Retrieve information about a messagebox.
13843 + * @param mbxid - UID of the messagebox to retrieve info for.
13844 + * @param info - Pointer to a ::SceKernelMbxInfo struct to receive the info.
13846 + * @return < 0 on error.
13847 + */
13848 +int sceKernelReferMbxStatus(SceUID mbxid, SceKernelMbxInfo *info);
13851 +/* Alarms. */
13853 +/** Prototype for alarm handlers. */
13854 +typedef SceUInt (*SceKernelAlarmHandler)(void *common);
13856 +/** Struct containing alarm info */
13857 +typedef struct SceKernelAlarmInfo {
13858 + /** Size of the structure (should be set before calling
13859 + * :: sceKernelReferAlarmStatus */
13860 + SceSize size;
13861 + /* The current schedule */
13862 + SceKernelSysClock schedule;
13863 + /** Pointer to the alarm handler */
13864 + SceKernelAlarmHandler handler;
13865 + /** Common pointer argument */
13866 + void * common;
13867 +} SceKernelAlarmInfo;
13869 +/**
13870 + * Set an alarm.
13871 + * @param clock - The number of micro seconds till the alarm occurrs.
13872 + * @param handler - Pointer to a ::SceKernelAlarmHandler
13873 + * @param common - Common pointer for the alarm handler
13875 + * @return A UID representing the created alarm, < 0 on error.
13876 + */
13877 +SceUID sceKernelSetAlarm(SceUInt clock, SceKernelAlarmHandler handler, void *common);
13879 +/**
13880 + * Set an alarm using a ::SceKernelSysClock structure for the time
13881 + *
13882 + * @param clock - Pointer to a ::SceKernelSysClock structure
13883 + * @param handler - Pointer to a ::SceKernelAlarmHandler
13884 + * @param common - Common pointer for the alarm handler.
13885 + *
13886 + * @return A UID representing the created alarm, < 0 on error.
13887 + */
13888 +SceUID sceKernelSetSysClockAlarm(SceKernelSysClock *clock, SceKernelAlarmHandler handler, void *common);
13890 +/**
13891 + * Cancel a pending alarm.
13893 + * @param alarmid - UID of the alarm to cancel.
13895 + * @return 0 on success, < 0 on error.
13896 + */
13897 +int sceKernelCancelAlarm(SceUID alarmid);
13899 +/**
13900 + * Refer the status of a created alarm.
13902 + * @param alarmid - UID of the alarm to get the info of
13903 + * @param info - Pointer to a ::SceKernelAlarmInfo structure
13905 + * @return 0 on success, < 0 on error.
13906 + */
13907 +int sceKernelReferAlarmStatus(SceUID alarmid, SceKernelAlarmInfo *info);
13909 +/* Callbacks. */
13911 +/** Callback function prototype */
13912 +typedef int (*SceKernelCallbackFunction)(int arg1, int arg2, void *arg);
13914 +/** Structure to hold the status information for a callback */
13915 +typedef struct SceKernelCallbackInfo {
13916 + /** Size of the structure (i.e. sizeof(SceKernelCallbackInfo)) */
13917 + SceSize size;
13918 + /** The name given to the callback */
13919 + char name[32];
13920 + /** The thread id associated with the callback */
13921 + SceUID threadId;
13922 + /** Pointer to the callback function */
13923 + SceKernelCallbackFunction callback;
13924 + /** User supplied argument for the callback */
13925 + void * common;
13926 + /** Unknown */
13927 + int notifyCount;
13928 + /** Unknown */
13929 + int notifyArg;
13930 +} SceKernelCallbackInfo;
13932 +/**
13933 + * Create callback
13935 + * @par Example:
13936 + * @code
13937 + * int cbid;
13938 + * cbid = sceKernelCreateCallback("Exit Callback", exit_cb, NULL);
13939 + * @endcode
13941 + * @param name - A textual name for the callback
13942 + * @param func - A pointer to a function that will be called as the callback
13943 + * @param arg - Argument for the callback ?
13945 + * @return >= 0 A callback id which can be used in subsequent functions, < 0 an error.
13946 + */
13947 +int sceKernelCreateCallback(const char *name, SceKernelCallbackFunction func, void *arg);
13949 +/**
13950 + * Gets the status of a specified callback.
13952 + * @param cb - The UID of the callback to refer.
13953 + * @param status - Pointer to a status structure. The size parameter should be
13954 + * initialised before calling.
13956 + * @return < 0 on error.
13957 + */
13958 +int sceKernelReferCallbackStatus(SceUID cb, SceKernelCallbackInfo *status);
13960 +/**
13961 + * Delete a callback
13963 + * @param cb - The UID of the specified callback
13965 + * @return 0 on success, < 0 on error
13966 + */
13967 +int sceKernelDeleteCallback(SceUID cb);
13969 +/**
13970 + * Notify a callback
13972 + * @param cb - The UID of the specified callback
13973 + * @param arg2 - Passed as arg2 into the callback function
13975 + * @return 0 on success, < 0 on error
13976 + */
13977 +int sceKernelNotifyCallback(SceUID cb, int arg2);
13979 +/**
13980 + * Cancel a callback ?
13982 + * @param cb - The UID of the specified callback
13984 + * @return 0 on succes, < 0 on error
13985 + */
13986 +int sceKernelCancelCallback(SceUID cb);
13988 +/**
13989 + * Get the callback count
13991 + * @param cb - The UID of the specified callback
13993 + * @return The callback count, < 0 on error
13994 + */
13995 +int sceKernelGetCallbackCount(SceUID cb);
13997 +/**
13998 + * Check callback ?
14000 + * @return Something or another
14001 + */
14002 +int sceKernelCheckCallback(void);
14004 +/* Misc. */
14006 +/** Threadman types for ::sceKernelGetThreadmanIdList */
14007 +enum SceKernelIdListType
14009 + SCE_KERNEL_TMID_Thread = 1,
14010 + SCE_KERNEL_TMID_Semaphore = 2,
14011 + SCE_KERNEL_TMID_EventFlag = 3,
14012 + SCE_KERNEL_TMID_Mbox = 4,
14013 + SCE_KERNEL_TMID_Vpl = 5,
14014 + SCE_KERNEL_TMID_Fpl = 6,
14015 + SCE_KERNEL_TMID_Mpipe = 7,
14016 + SCE_KERNEL_TMID_Callback = 8,
14017 + SCE_KERNEL_TMID_ThreadEventHandler = 9,
14018 + SCE_KERNEL_TMID_Alarm = 10,
14019 + SCE_KERNEL_TMID_VTimer = 11,
14020 + SCE_KERNEL_TMID_SleepThread = 64,
14021 + SCE_KERNEL_TMID_DelayThread = 65,
14022 + SCE_KERNEL_TMID_SuspendThread = 66,
14023 + SCE_KERNEL_TMID_DormantThread = 67,
14026 +/**
14027 + * Get a list of UIDs from threadman. Allows you to enumerate
14028 + * resources such as threads or semaphores.
14030 + * @param type - The type of resource to list, one of ::SceKernelIdListType.
14031 + * @param readbuf - A pointer to a buffer to store the list.
14032 + * @param readbufsize - The size of the buffer in SceUID units.
14033 + * @param idcount - Pointer to an integer in which to return the number of ids in the list.
14035 + * @return < 0 on error. Either 0 or the same as idcount on success.
14036 + */
14037 +int sceKernelGetThreadmanIdList(enum SceKernelIdListType type, SceUID *readbuf, int readbufsize, int *idcount);
14039 +/** Structure to contain the system status returned by ::sceKernelReferSystemStatus */
14040 +typedef struct SceKernelSystemStatus {
14041 + /** Size of the structure (should be set prior to the call) */
14042 + SceSize size;
14043 + /** The status ? */
14044 + SceUInt status;
14045 + /** The number of cpu clocks in the idle thread */
14046 + SceKernelSysClock idleClocks;
14047 + /** Number of times we resumed from idle */
14048 + SceUInt comesOutOfIdleCount;
14049 + /** Number of thread context switches */
14050 + SceUInt threadSwitchCount;
14051 + /** Number of vfpu switches ? */
14052 + SceUInt vfpuSwitchCount;
14053 +} SceKernelSystemStatus;
14055 +/**
14056 + * Get the current system status.
14058 + * @param status - Pointer to a ::SceKernelSystemStatus structure.
14060 + * @return < 0 on error.
14061 + */
14062 +int sceKernelReferSystemStatus(SceKernelSystemStatus *status);
14065 +/**
14066 + * Create a message pipe
14068 + * @param name - Name of the pipe
14069 + * @param part - ID of the memory partition
14070 + * @param attr - Set to 0?
14071 + * @param unk1 - Unknown
14072 + * @param opt - Message pipe options (set to NULL)
14074 + * @return The UID of the created pipe, < 0 on error
14075 + */
14076 +SceUID sceKernelCreateMsgPipe(const char *name, int part, int attr, void *unk1, void *opt);
14078 +/**
14079 + * Delete a message pipe
14081 + * @param uid - The UID of the pipe
14083 + * @return 0 on success, < 0 on error
14084 + */
14085 +int sceKernelDeleteMsgPipe(SceUID uid);
14087 +/**
14088 + * Send a message to a pipe
14090 + * @param uid - The UID of the pipe
14091 + * @param message - Pointer to the message
14092 + * @param size - Size of the message
14093 + * @param unk1 - Unknown
14094 + * @param unk2 - Unknown
14095 + * @param timeout - Timeout for send
14097 + * @return 0 on success, < 0 on error
14098 + */
14099 +int sceKernelSendMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
14101 +/**
14102 + * Send a message to a pipe (with callback)
14104 + * @param uid - The UID of the pipe
14105 + * @param message - Pointer to the message
14106 + * @param size - Size of the message
14107 + * @param unk1 - Unknown
14108 + * @param unk2 - Unknown
14109 + * @param timeout - Timeout for send
14111 + * @return 0 on success, < 0 on error
14112 + */
14113 +int sceKernelSendMsgPipeCB(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
14115 +/**
14116 + * Try to send a message to a pipe
14118 + * @param uid - The UID of the pipe
14119 + * @param message - Pointer to the message
14120 + * @param size - Size of the message
14121 + * @param unk1 - Unknown
14122 + * @param unk2 - Unknown
14124 + * @return 0 on success, < 0 on error
14125 + */
14126 +int sceKernelTrySendMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2);
14128 +/**
14129 + * Receive a message from a pipe
14131 + * @param uid - The UID of the pipe
14132 + * @param message - Pointer to the message
14133 + * @param size - Size of the message
14134 + * @param unk1 - Unknown
14135 + * @param unk2 - Unknown
14136 + * @param timeout - Timeout for receive
14138 + * @return 0 on success, < 0 on error
14139 + */
14140 +int sceKernelReceiveMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
14142 +/**
14143 + * Receive a message from a pipe (with callback)
14145 + * @param uid - The UID of the pipe
14146 + * @param message - Pointer to the message
14147 + * @param size - Size of the message
14148 + * @param unk1 - Unknown
14149 + * @param unk2 - Unknown
14150 + * @param timeout - Timeout for receive
14152 + * @return 0 on success, < 0 on error
14153 + */
14154 +int sceKernelReceiveMsgPipeCB(SceUID uid, void *message, unsigned int size, int unk1, void *unk2, unsigned int *timeout);
14156 +/**
14157 + * Receive a message from a pipe
14159 + * @param uid - The UID of the pipe
14160 + * @param message - Pointer to the message
14161 + * @param size - Size of the message
14162 + * @param unk1 - Unknown
14163 + * @param unk2 - Unknown
14165 + * @return 0 on success, < 0 on error
14166 + */
14167 +int sceKernelTryReceiveMsgPipe(SceUID uid, void *message, unsigned int size, int unk1, void *unk2);
14169 +/**
14170 + * Cancel a message pipe
14172 + * @param uid - UID of the pipe to cancel
14173 + * @param psend - Receive number of sending threads?
14174 + * @param precv - Receive number of receiving threads?
14176 + * @return 0 on success, < 0 on error
14177 + */
14178 +int sceKernelCancelMsgPipe(SceUID uid, int *psend, int *precv);
14180 +/** Message Pipe status info */
14181 +typedef struct SceKernelMppInfo {
14182 + SceSize size;
14183 + char name[32];
14184 + SceUInt attr;
14185 + int bufSize;
14186 + int freeSize;
14187 + int numSendWaitThreads;
14188 + int numReceiveWaitThreads;
14189 +} SceKernelMppInfo;
14191 +/**
14192 + * Get the status of a Message Pipe
14194 + * @param uid - The uid of the Message Pipe
14195 + * @param info - Pointer to a ::SceKernelMppInfo structure
14197 + * @return 0 on success, < 0 on error
14198 + */
14199 +int sceKernelReferMsgPipeStatus(SceUID uid, SceKernelMppInfo *info);
14201 +/* VPL Functions */
14203 +struct SceKernelVplOptParam {
14204 + SceSize size;
14207 +/**
14208 + * Create a variable pool
14210 + * @param name - Name of the pool
14211 + * @param part - The memory partition ID
14212 + * @param attr - Attributes
14213 + * @param size - Size of pool
14214 + * @param opt - Options (set to NULL)
14216 + * @return The UID of the created pool, < 0 on error.
14217 + */
14218 +SceUID sceKernelCreateVpl(const char *name, int part, int attr, unsigned int size, struct SceKernelVplOptParam *opt);
14220 +/**
14221 + * Delete a variable pool
14223 + * @param uid - The UID of the pool
14225 + * @return 0 on success, < 0 on error
14226 + */
14227 +int sceKernelDeleteVpl(SceUID uid);
14229 +/**
14230 + * Allocate from the pool
14232 + * @param uid - The UID of the pool
14233 + * @param size - The size to allocate
14234 + * @param data - Receives the address of the allocated data
14235 + * @param timeout - Amount of time to wait for allocation?
14237 + * @return 0 on success, < 0 on error
14238 + */
14239 +int sceKernelAllocateVpl(SceUID uid, unsigned int size, void **data, unsigned int *timeout);
14241 +/**
14242 + * Allocate from the pool (with callback)
14244 + * @param uid - The UID of the pool
14245 + * @param size - The size to allocate
14246 + * @param data - Receives the address of the allocated data
14247 + * @param timeout - Amount of time to wait for allocation?
14249 + * @return 0 on success, < 0 on error
14250 + */
14251 +int sceKernelAllocateVplCB(SceUID uid, unsigned int size, void **data, unsigned int *timeout);
14253 +/**
14254 + * Try to allocate from the pool
14256 + * @param uid - The UID of the pool
14257 + * @param size - The size to allocate
14258 + * @param data - Receives the address of the allocated data
14260 + * @return 0 on success, < 0 on error
14261 + */
14262 +int sceKernelTryAllocateVpl(SceUID uid, unsigned int size, void **data);
14264 +/**
14265 + * Free a block
14267 + * @param uid - The UID of the pool
14268 + * @param data - The data block to deallocate
14270 + * @return 0 on success, < 0 on error
14271 + */
14272 +int sceKernelFreeVpl(SceUID uid, void *data);
14274 +/**
14275 + * Cancel a pool
14277 + * @param uid - The UID of the pool
14278 + * @param pnum - Receives the number of waiting threads
14280 + * @return 0 on success, < 0 on error
14281 + */
14282 +int sceKernelCancelVpl(SceUID uid, int *pnum);
14284 +/** Variable pool status info */
14285 +typedef struct SceKernelVplInfo {
14286 + SceSize size;
14287 + char name[32];
14288 + SceUInt attr;
14289 + int poolSize;
14290 + int freeSize;
14291 + int numWaitThreads;
14292 +} SceKernelVplInfo;
14294 +/**
14295 + * Get the status of an VPL
14297 + * @param uid - The uid of the VPL
14298 + * @param info - Pointer to a ::SceKernelVplInfo structure
14300 + * @return 0 on success, < 0 on error
14301 + */
14302 +int sceKernelReferVplStatus(SceUID uid, SceKernelVplInfo *info);
14304 +/* FPL Functions */
14306 +struct SceKernelFplOptParam {
14307 + SceSize size;
14310 +/**
14311 + * Create a fixed pool
14313 + * @param name - Name of the pool
14314 + * @param part - The memory partition ID
14315 + * @param attr - Attributes
14316 + * @param size - Size of pool block
14317 + * @param blocks - Number of blocks to allocate
14318 + * @param opt - Options (set to NULL)
14320 + * @return The UID of the created pool, < 0 on error.
14321 + */
14322 +int sceKernelCreateFpl(const char *name, int part, int attr, unsigned int size, unsigned int blocks, struct SceKernelFplOptParam *opt);
14324 +/**
14325 + * Delete a fixed pool
14327 + * @param uid - The UID of the pool
14329 + * @return 0 on success, < 0 on error
14330 + */
14331 +int sceKernelDeleteFpl(SceUID uid);
14333 +/**
14334 + * Allocate from the pool
14336 + * @param uid - The UID of the pool
14337 + * @param data - Receives the address of the allocated data
14338 + * @param timeout - Amount of time to wait for allocation?
14340 + * @return 0 on success, < 0 on error
14341 + */
14342 +int sceKernelAllocateFpl(SceUID uid, void **data, unsigned int *timeout);
14344 +/**
14345 + * Allocate from the pool (with callback)
14347 + * @param uid - The UID of the pool
14348 + * @param data - Receives the address of the allocated data
14349 + * @param timeout - Amount of time to wait for allocation?
14351 + * @return 0 on success, < 0 on error
14352 + */
14353 +int sceKernelAllocateFplCB(SceUID uid, void **data, unsigned int *timeout);
14355 +/**
14356 + * Try to allocate from the pool
14358 + * @param uid - The UID of the pool
14359 + * @param data - Receives the address of the allocated data
14361 + * @return 0 on success, < 0 on error
14362 + */
14363 +int sceKernelTryAllocateFpl(SceUID uid, void **data);
14365 +/**
14366 + * Free a block
14368 + * @param uid - The UID of the pool
14369 + * @param data - The data block to deallocate
14371 + * @return 0 on success, < 0 on error
14372 + */
14373 +int sceKernelFreeFpl(SceUID uid, void *data);
14375 +/**
14376 + * Cancel a pool
14378 + * @param uid - The UID of the pool
14379 + * @param pnum - Receives the number of waiting threads
14381 + * @return 0 on success, < 0 on error
14382 + */
14383 +int sceKernelCancelFpl(SceUID uid, int *pnum);
14385 +/** Fixed pool status information */
14386 +typedef struct SceKernelFplInfo {
14387 + SceSize size;
14388 + char name[32];
14389 + SceUInt attr;
14390 + int blockSize;
14391 + int numBlocks;
14392 + int freeBlocks;
14393 + int numWaitThreads;
14394 +} SceKernelFplInfo;
14396 +/**
14397 + * Get the status of an FPL
14399 + * @param uid - The uid of the FPL
14400 + * @param info - Pointer to a ::SceKernelFplInfo structure
14402 + * @return 0 on success, < 0 on error
14403 + */
14404 +int sceKernelReferFplStatus(SceUID uid, SceKernelFplInfo *info);
14406 +/**
14407 + * Return from a timer handler (doesn't seem to do alot)
14408 + */
14409 +void _sceKernelReturnFromTimerHandler(void);
14411 +/**
14412 + * Return from a callback (used as a syscall for the return
14413 + * of the callback function)
14414 + */
14415 +void _sceKernelReturnFromCallback(void);
14417 +/**
14418 + * Convert a number of microseconds to a ::SceKernelSysClock structure
14420 + * @param usec - Number of microseconds
14421 + * @param clock - Pointer to a ::SceKernelSysClock structure
14423 + * @return 0 on success, < 0 on error
14424 + */
14425 +int sceKernelUSec2SysClock(unsigned int usec, SceKernelSysClock *clock);
14427 +/**
14428 + * Convert a number of microseconds to a wide time
14429 + *
14430 + * @param usec - Number of microseconds.
14432 + * @return The time
14433 + */
14434 +SceInt64 sceKernelUSec2SysClockWide(unsigned int usec);
14436 +/**
14437 + * Convert a ::SceKernelSysClock structure to microseconds
14439 + * @param clock - Pointer to a ::SceKernelSysClock structure
14440 + * @param low - Pointer to the low part of the time
14441 + * @param high - Pointer to the high part of the time
14443 + * @return 0 on success, < 0 on error
14444 + */
14445 +int sceKernelSysClock2USec(SceKernelSysClock *clock, unsigned int *low, unsigned int *high);
14447 +/**
14448 + * Convert a wide time to microseconds
14450 + * @param clock - Wide time
14451 + * @param low - Pointer to the low part of the time
14452 + * @param high - Pointer to the high part of the time
14454 + * @return 0 on success, < 0 on error
14455 + */
14456 +int sceKernelSysClock2USecWide(SceInt64 clock, unsigned *low, unsigned int *high);
14458 +/**
14459 + * Get the system time
14461 + * @param time - Pointer to a ::SceKernelSysClock structure
14463 + * @return 0 on success, < 0 on error
14464 + */
14465 +int sceKernelGetSystemTime(SceKernelSysClock *time);
14467 +/**
14468 + * Get the system time (wide version)
14470 + * @return The system time
14471 + */
14472 +SceInt64 sceKernelGetSystemTimeWide(void);
14474 +/**
14475 + * Get the low 32bits of the current system time
14477 + * @return The low 32bits of the system time
14478 + */
14479 +unsigned int sceKernelGetSystemTimeLow(void);
14481 +struct SceKernelVTimerOptParam {
14482 + SceSize size;
14485 +/**
14486 + * Create a virtual timer
14488 + * @param name - Name for the timer.
14489 + * @param opt - Pointer to an ::SceKernelVTimerOptParam (pass NULL)
14491 + * @return The VTimer's UID or < 0 on error.
14492 + */
14493 +SceUID sceKernelCreateVTimer(const char *name, struct SceKernelVTimerOptParam *opt);
14495 +/**
14496 + * Delete a virtual timer
14498 + * @param uid - The UID of the timer
14500 + * @return < 0 on error.
14501 + */
14502 +int sceKernelDeleteVTimer(SceUID uid);
14504 +/**
14505 + * Get the timer base
14507 + * @param uid - UID of the vtimer
14508 + * @param base - Pointer to a ::SceKernelSysClock structure
14510 + * @return 0 on success, < 0 on error
14511 + */
14512 +int sceKernelGetVTimerBase(SceUID uid, SceKernelSysClock *base);
14514 +/**
14515 + * Get the timer base (wide format)
14517 + * @param uid - UID of the vtimer
14519 + * @return The 64bit timer base
14520 + */
14521 +SceInt64 sceKernelGetVTimerBaseWide(SceUID uid);
14523 +/**
14524 + * Get the timer time
14526 + * @param uid - UID of the vtimer
14527 + * @param time - Pointer to a ::SceKernelSysClock structure
14529 + * @return 0 on success, < 0 on error
14530 + */
14531 +int sceKernelGetVTimerTime(SceUID uid, SceKernelSysClock *time);
14533 +/**
14534 + * Get the timer time (wide format)
14536 + * @param uid - UID of the vtimer
14538 + * @return The 64bit timer time
14539 + */
14540 +SceInt64 sceKernelGetVTimerTimeWide(SceUID uid);
14542 +/**
14543 + * Set the timer time
14545 + * @param uid - UID of the vtimer
14546 + * @param time - Pointer to a ::SceKernelSysClock structure
14548 + * @return 0 on success, < 0 on error
14549 + */
14550 +int sceKernelSetVTimerTime(SceUID uid, SceKernelSysClock *time);
14552 +/**
14553 + * Set the timer time (wide format)
14555 + * @param uid - UID of the vtimer
14556 + * @param time - Pointer to a ::SceKernelSysClock structure
14558 + * @return Possibly the last time
14559 + */
14560 +SceInt64 sceKernelSetVTimerTimeWide(SceUID uid, SceInt64 time);
14562 +/**
14563 + * Start a virtual timer
14565 + * @param uid - The UID of the timer
14567 + * @return < 0 on error
14568 + */
14569 +int sceKernelStartVTimer(SceUID uid);
14571 +/**
14572 + * Stop a virtual timer
14574 + * @param uid - The UID of the timer
14576 + * @return < 0 on error
14577 + */
14578 +int sceKernelStopVTimer(SceUID uid);
14580 +typedef SceUInt (*SceKernelVTimerHandler)(SceUID uid, SceKernelSysClock *, SceKernelSysClock *, void *);
14581 +typedef SceUInt (*SceKernelVTimerHandlerWide)(SceUID uid, SceInt64, SceInt64, void *);
14583 +/**
14584 + * Set the timer handler
14586 + * @param uid - UID of the vtimer
14587 + * @param time - Time to call the handler?
14588 + * @param handler - The timer handler
14589 + * @param common - Common pointer
14591 + * @return 0 on success, < 0 on error
14592 + */
14593 +int sceKernelSetVTimerHandler(SceUID uid, SceKernelSysClock *time, SceKernelVTimerHandler handler, void *common);
14595 +/**
14596 + * Set the timer handler (wide mode)
14598 + * @param uid - UID of the vtimer
14599 + * @param time - Time to call the handler?
14600 + * @param handler - The timer handler
14601 + * @param common - Common pointer
14603 + * @return 0 on success, < 0 on error
14604 + */
14605 +int sceKernelSetVTimerHandlerWide(SceUID uid, SceInt64 time, SceKernelVTimerHandlerWide handler, void *common);
14607 +/**
14608 + * Cancel the timer handler
14610 + * @param uid - The UID of the vtimer
14612 + * @return 0 on success, < 0 on error
14613 + */
14614 +int sceKernelCancelVTimerHandler(SceUID uid);
14616 +typedef struct SceKernelVTimerInfo {
14617 + SceSize size;
14618 + char name[32];
14619 + int active;
14620 + SceKernelSysClock base;
14621 + SceKernelSysClock current;
14622 + SceKernelSysClock schedule;
14623 + SceKernelVTimerHandler handler;
14624 + void * common;
14625 +} SceKernelVTimerInfo;
14627 +/**
14628 + * Get the status of a VTimer
14630 + * @param uid - The uid of the VTimer
14631 + * @param info - Pointer to a ::SceKernelVTimerInfo structure
14633 + * @return 0 on success, < 0 on error
14634 + */
14635 +int sceKernelReferVTimerStatus(SceUID uid, SceKernelVTimerInfo *info);
14637 +/**
14638 + * Exit the thread (probably used as the syscall when the main thread
14639 + * returns
14640 + */
14641 +void _sceKernelExitThread(void);
14643 +/**
14644 + * Get the type of a threadman uid
14646 + * @param uid - The uid to get the type from
14647 + *
14648 + * @return The type, < 0 on error
14649 + */
14650 +enum SceKernelIdListType sceKernelGetThreadmanIdType(SceUID uid);
14652 +typedef int (*SceKernelThreadEventHandler)(int mask, SceUID thid, void *common);
14654 +/** Struct for event handler info */
14655 +typedef struct SceKernelThreadEventHandlerInfo {
14656 + SceSize size;
14657 + char name[32];
14658 + SceUID threadId;
14659 + int mask;
14660 + SceKernelThreadEventHandler handler;
14661 + void * common;
14662 +} SceKernelThreadEventHandlerInfo;
14664 +enum ThreadEventIds
14666 + THREADEVENT_ALL = 0xFFFFFFFF,
14667 + THREADEVENT_KERN = 0xFFFFFFF8,
14668 + THREADEVENT_USER = 0xFFFFFFF0,
14669 + THREADEVENT_CURRENT = 0
14672 +enum ThreadEvents
14674 + THREAD_CREATE = 1,
14675 + THREAD_START = 2,
14676 + THREAD_EXIT = 4,
14677 + THREAD_DELETE = 8,
14680 +/**
14681 + * Register a thread event handler
14683 + * @param name - Name for the thread event handler
14684 + * @param threadID - Thread ID to monitor
14685 + * @param mask - Bit mask for what events to handle (only lowest 4 bits valid)
14686 + * @param handler - Pointer to a ::SceKernelThreadEventHandler function
14687 + * @param common - Common pointer
14689 + * @return The UID of the create event handler, < 0 on error
14690 + */
14691 +SceUID sceKernelRegisterThreadEventHandler(const char *name, SceUID threadID, int mask, SceKernelThreadEventHandler handler, void *common);
14693 +/**
14694 + * Release a thread event handler.
14696 + * @param uid - The UID of the event handler
14698 + * @return 0 on success, < 0 on error
14699 + */
14700 +int sceKernelReleaseThreadEventHandler(SceUID uid);
14702 +/**
14703 + * Refer the status of an thread event handler
14705 + * @param uid - The UID of the event handler
14706 + * @param info - Pointer to a ::SceKernelThreadEventHandlerInfo structure
14708 + * @return 0 on success, < 0 on error
14709 + */
14710 +int sceKernelReferThreadEventHandlerStatus(SceUID uid, struct SceKernelThreadEventHandlerInfo *info);
14712 +/**
14713 + * Get the thread profiler registers.
14714 + * @return Pointer to the registers, NULL on error
14715 + */
14716 +PspDebugProfilerRegs *sceKernelReferThreadProfiler(void);
14718 +/**
14719 + * Get the globile profiler registers.
14720 + * @return Pointer to the registers, NULL on error
14721 + */
14722 +PspDebugProfilerRegs *sceKernelReferGlobalProfiler(void);
14724 +/**@}*/
14726 +#ifdef __cplusplus
14728 +#endif
14730 +#endif
14731 diff --git a/newlib/psp/include/pspthreadman_kernel.h b/newlib/psp/include/pspthreadman_kernel.h
14732 new file mode 100644
14733 index 0000000..2047b12
14734 --- /dev/null
14735 +++ b/newlib/psp/include/pspthreadman_kernel.h
14736 @@ -0,0 +1,233 @@
14738 + * PSP Software Development Kit - https://github.com/pspdev
14739 + * -----------------------------------------------------------------------
14740 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
14742 + * pspthreadman_kernel.h - Interface to the kernel side of threadman
14744 + * Copyright (c) 2005 James F.
14746 + */
14748 +#ifndef PSPTHREADMANKERNEL_H
14749 +#define PSPTHREADMANKERNEL_H
14751 +#include <pspkerneltypes.h>
14752 +#include <pspthreadman.h>
14754 +/** @defgroup ThreadmanKern Thread Manager kernel functions
14755 + * This module contains routines to threads in the kernel
14756 + */
14758 +/** @addtogroup ThreadmanKern Thread Manager kernel functions */
14759 +/**@{*/
14761 +#ifdef __cplusplus
14762 +extern "C" {
14763 +#endif
14765 +/**
14766 + * Suspend all user mode threads in the system
14768 + * @return 0 on success, < 0 on error
14769 + */
14770 +int sceKernelSuspendAllUserThreads(void);
14772 +/**
14773 + * Checks if the current thread is a usermode thread
14775 + * @return 0 if kernel, 1 if user, < 0 on error
14776 + */
14777 +int sceKernelIsUserModeThread(void);
14779 +/**
14780 + * Get the user level of the current thread
14782 + * @return The user level, < 0 on error
14783 + */
14784 +int sceKernelGetUserLevel(void);
14786 +/**
14787 + * Get the return address of the current thread's syscall
14789 + * @return The RA, 0 on error
14790 + */
14791 +unsigned int sceKernelGetSyscallRA(void);
14793 +/**
14794 + * Get the free stack space on the kernel thread
14796 + * @param thid - The UID of the thread
14798 + * @return The free stack space, < 0 on error
14799 + */
14800 +int sceKernelGetThreadKernelStackFreeSize(SceUID thid);
14802 +/**
14803 + * Check the thread kernel stack
14805 + * @return Unknown
14806 + */
14807 +int sceKernelCheckThreadKernelStack(void);
14809 +/**
14810 + * Extend the kernel thread stack
14812 + * @param type - The type of block allocation. One of ::PspSysMemBlockTypes
14813 + * @param cb - A pointer to a callback function
14814 + * @param arg - A pointer to a user specified argument
14816 + * @return < 0 on error
14817 + */
14818 +int sceKernelExtendKernelStack(int type, void (*cb)(void*), void *arg);
14820 +/**
14821 + * Get the system status flag
14823 + * @return The system status flag
14824 + */
14825 +unsigned int sceKernelGetSystemStatusFlag(void);
14827 +/**
14828 + * Setup the KTLS allocator
14830 + * @param id - The ID of the allocator
14831 + * @param cb - The allocator callback
14832 + * @param arg - User specified arg passed to the callback
14834 + * @return < 0 on error, allocation id on success
14835 + */
14836 +int sceKernelAllocateKTLS(int id, int (*cb)(unsigned int *size, void *arg), void *arg);
14838 +/**
14839 + * Free the KTLS allocator
14841 + * @param id - The allocation id returned from AllocateKTLS
14843 + * @return < 0 on error
14844 + */
14845 +int sceKernelFreeKTLS(int id);
14847 +/**
14848 + * Get the KTLS of the current thread
14850 + * @param id - The allocation id returned from AllocateKTLS
14851 + *
14852 + * @return The current KTLS, NULL on error
14853 + */
14854 +void *sceKernelGetKTLS(int id);
14856 +/**
14857 + * Get the KTLS of a thread
14859 + * @param id - The allocation id returned from AllocateKTLS
14860 + * @param thid - The thread is, 0 for current thread
14861 + * @param mode - Perhaps? Sees to be set to 0 or 1
14863 + * @return The current KTLS, NULL on error
14864 + */
14865 +void *sceKernelGetThreadKTLS(int id, SceUID thid, int mode);
14867 +/** Thread context
14868 + * Structues for the thread context taken from florinsasu's post on the forums */
14869 +struct SceThreadContext {
14870 + unsigned int type;
14871 + unsigned int gpr[31];
14872 + unsigned int fpr[32];
14873 + unsigned int fc31;
14874 + unsigned int hi;
14875 + unsigned int lo;
14876 + unsigned int SR;
14877 + unsigned int EPC;
14878 + unsigned int field_114;
14879 + unsigned int field_118;
14880 +};
14882 +struct SceSCContext
14884 + unsigned int status;
14885 + unsigned int epc;
14886 + unsigned int sp;
14887 + unsigned int ra;
14888 + unsigned int k1;
14889 + unsigned int unk[3];
14892 +/** Structure to hold the status information for a thread (kernel form)
14893 + * 1.5 form
14894 + */
14895 +typedef struct SceKernelThreadKInfo {
14896 + /** Size of the structure */
14897 + SceSize size;
14898 + /** Nul terminated name of the thread */
14899 + char name[32];
14900 + /** Thread attributes */
14901 + SceUInt attr;
14902 + /** Thread status */
14903 + int status;
14904 + /** Thread entry point */
14905 + SceKernelThreadEntry entry;
14906 + /** Thread stack pointer */
14907 + void * stack;
14908 + /** Thread stack size */
14909 + int stackSize;
14910 + /** Kernel stack pointer */
14911 + void * kstack;
14912 + /** Kernel stack size */
14913 + void * kstackSize;
14914 + /** Pointer to the gp */
14915 + void * gpReg;
14916 + /** Size of args */
14917 + SceSize args;
14918 + /** Pointer to args */
14919 + void * argp;
14920 + /** Initial priority */
14921 + int initPriority;
14922 + /** Current priority */
14923 + int currentPriority;
14924 + /** Wait type */
14925 + int waitType;
14926 + /** Wait id */
14927 + SceUID waitId;
14928 + /** Wakeup count */
14929 + int wakeupCount;
14930 + /** Number of clock cycles run */
14931 + SceKernelSysClock runClocks;
14932 +#if _PSP_FW_VERSION >= 200
14933 + SceUInt unk3; /* Unknown extra field on later firmwares */
14934 +#endif
14935 + /** Interrupt preemption count */
14936 + SceUInt intrPreemptCount;
14937 + /** Thread preemption count */
14938 + SceUInt threadPreemptCount;
14939 + /** Release count */
14940 + SceUInt releaseCount;
14941 + /** Thread Context */
14942 + struct SceThreadContext *thContext;
14943 + /** VFPU Context */
14944 + float * vfpuContext;
14945 + /** Return address from syscall */
14946 + void * retAddr;
14947 + /** Unknown, possibly size of SC context */
14948 + SceUInt unknown1;
14949 + /** Syscall Context */
14950 + struct SceSCContext *scContext;
14951 +} SceKernelThreadKInfo;
14953 +/**
14954 + * Refer kernel version of thread information
14956 + * @param uid - UID to find
14957 + * @param info - Pointer to info structure, ensure size is set before calling
14959 + * @return 0 on success
14960 + */
14961 +int ThreadManForKernel_2D69D086(SceUID uid, SceKernelThreadKInfo *info);
14963 +#ifdef __cplusplus
14965 +#endif
14967 +/**@}*/
14969 +#endif /* PSPTHREADMANKERNEL_H */
14970 diff --git a/newlib/psp/include/psptypes.h b/newlib/psp/include/psptypes.h
14971 new file mode 100644
14972 index 0000000..fb93b8e
14973 --- /dev/null
14974 +++ b/newlib/psp/include/psptypes.h
14975 @@ -0,0 +1,433 @@
14977 + * PSP Software Development Kit - https://github.com/pspdev
14978 + * -----------------------------------------------------------------------
14979 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
14981 + * psptypes.h - Commonly used typedefs.
14983 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
14984 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
14985 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
14987 + */
14989 +/* Note: Some of the structures, types, and definitions in this file were
14990 + extrapolated from symbolic debugging information found in the Japanese
14991 + version of Puzzle Bobble. */
14993 +#ifndef _PSPTYPES_H_
14994 +#define _PSPTYPES_H_ 1
14996 +#include <stdint.h>
14998 +#ifdef __cplusplus
14999 +extern "C" {
15000 +#endif
15002 +#ifndef NULL
15003 +#ifdef __cplusplus
15004 +#define NULL 0
15005 +#else
15006 +#define NULL ((void *) 0)
15007 +#endif /* __cplusplus */
15008 +#endif
15010 +/* Legacy ps2dev types. */
15011 +#ifndef PSP_LEGACY_TYPES_DEFINED
15012 +#define PSP_LEGACY_TYPES_DEFINED
15013 +typedef uint8_t u8;
15014 +typedef uint16_t u16;
15016 +typedef uint32_t u32;
15017 +typedef uint64_t u64;
15019 +typedef int8_t s8;
15020 +typedef int16_t s16;
15022 +typedef int32_t s32;
15023 +typedef int64_t s64;
15024 +#endif
15026 +#ifndef PSP_LEGACY_VOLATILE_TYPES_DEFINED
15027 +#define PSP_LEGACY_VOLATILE_TYPES_DEFINED
15028 +typedef volatile uint8_t vu8;
15029 +typedef volatile uint16_t vu16;
15031 +typedef volatile uint32_t vu32;
15032 +typedef volatile uint64_t vu64;
15034 +typedef volatile int8_t vs8;
15035 +typedef volatile int16_t vs16;
15037 +typedef volatile int32_t vs32;
15038 +typedef volatile int64_t vs64;
15039 +#endif
15041 +/* MIPS-like accessor macros. */
15042 +static __inline__ u8 _lb(u32 addr) { return *(vu8 *)addr; }
15043 +static __inline__ u16 _lh(u32 addr) { return *(vu16 *)addr; }
15044 +static __inline__ u32 _lw(u32 addr) { return *(vu32 *)addr; }
15045 +static __inline__ u64 _ld(u32 addr) { return *(vu64 *)addr; }
15047 +static __inline__ void _sb(u8 val, u32 addr) { *(vu8 *)addr = val; }
15048 +static __inline__ void _sh(u16 val, u32 addr) { *(vu16 *)addr = val; }
15049 +static __inline__ void _sw(u32 val, u32 addr) { *(vu32 *)addr = val; }
15050 +static __inline__ void _sd(u64 val, u32 addr) { *(vu64 *)addr = val; }
15052 +/* SCE types. */
15053 +typedef unsigned char SceUChar8;
15054 +typedef uint16_t SceUShort16;
15055 +typedef uint32_t SceUInt32;
15056 +typedef uint64_t SceUInt64;
15057 +typedef uint64_t SceULong64;
15058 +/*typedef unsigned int SceULong128 __attribute__((mode(TI)));*/
15060 +typedef char SceChar8;
15061 +typedef int16_t SceShort16;
15062 +typedef int32_t SceInt32;
15063 +typedef int64_t SceInt64;
15064 +typedef int64_t SceLong64;
15065 +/*typedef int SceLong128 __attribute__((mode(TI)));*/
15067 +typedef float SceFloat;
15068 +typedef float SceFloat32;
15070 +typedef short unsigned int SceWChar16;
15071 +typedef unsigned int SceWChar32;
15073 +typedef int SceBool;
15075 +typedef void SceVoid;
15076 +typedef void * ScePVoid;
15079 +/* PSP types. */
15081 +/* Rectangles. */
15082 +typedef struct ScePspSRect {
15083 + short int x;
15084 + short int y;
15085 + short int w;
15086 + short int h;
15087 +} ScePspSRect;
15089 +typedef struct ScePspIRect {
15090 + int x;
15091 + int y;
15092 + int w;
15093 + int h;
15094 +} ScePspIRect;
15096 +typedef struct ScePspL64Rect {
15097 + SceLong64 x;
15098 + SceLong64 y;
15099 + SceLong64 w;
15100 + SceLong64 h;
15101 +} ScePspL64Rect;
15103 +typedef struct ScePspFRect {
15104 + float x;
15105 + float y;
15106 + float w;
15107 + float h;
15108 +} ScePspFRect;
15110 +/* 2D vectors. */
15111 +typedef struct ScePspSVector2 {
15112 + short int x;
15113 + short int y;
15114 +} ScePspSVector2;
15116 +typedef struct ScePspIVector2 {
15117 + int x;
15118 + int y;
15119 +} ScePspIVector2;
15121 +typedef struct ScePspL64Vector2 {
15122 + SceLong64 x;
15123 + SceLong64 y;
15124 +} ScePspL64Vector2;
15126 +typedef struct ScePspFVector2 {
15127 + float x;
15128 + float y;
15129 +} ScePspFVector2;
15131 +typedef union ScePspVector2 {
15132 + ScePspFVector2 fv;
15133 + ScePspIVector2 iv;
15134 + float f[2];
15135 + int i[2];
15136 +} ScePspVector2;
15138 +/* 3D vectors. */
15139 +typedef struct ScePspSVector3 {
15140 + short int x;
15141 + short int y;
15142 + short int z;
15143 +} ScePspSVector3;
15145 +typedef struct ScePspIVector3 {
15146 + int x;
15147 + int y;
15148 + int z;
15149 +} ScePspIVector3;
15151 +typedef struct ScePspL64Vector3 {
15152 + SceLong64 x;
15153 + SceLong64 y;
15154 + SceLong64 z;
15155 +} ScePspL64Vector3;
15157 +typedef struct ScePspFVector3 {
15158 + float x;
15159 + float y;
15160 + float z;
15161 +} ScePspFVector3;
15163 +typedef union ScePspVector3 {
15164 + ScePspFVector3 fv;
15165 + ScePspIVector3 iv;
15166 + float f[3];
15167 + int i[3];
15168 +} ScePspVector3;
15170 +/* 4D vectors. */
15171 +typedef struct ScePspSVector4 {
15172 + short int x;
15173 + short int y;
15174 + short int z;
15175 + short int w;
15176 +} ScePspSVector4;
15178 +typedef struct ScePspIVector4 {
15179 + int x;
15180 + int y;
15181 + int z;
15182 + int w;
15183 +} ScePspIVector4;
15185 +typedef struct ScePspL64Vector4 {
15186 + SceLong64 x;
15187 + SceLong64 y;
15188 + SceLong64 z;
15189 + SceLong64 w;
15190 +} ScePspL64Vector4;
15192 +typedef struct ScePspFVector4 {
15193 + float x;
15194 + float y;
15195 + float z;
15196 + float w;
15197 +} ScePspFVector4 __attribute__((aligned(16)));
15199 +typedef struct ScePspFVector4Unaligned {
15200 + float x;
15201 + float y;
15202 + float z;
15203 + float w;
15204 +} ScePspFVector4Unaligned;
15206 +typedef union ScePspVector4 {
15207 + ScePspFVector4 fv;
15208 + ScePspIVector4 iv;
15209 +/* SceULong128 qw;*/ /* Missing compiler support. */
15210 + float f[4];
15211 + int i[4];
15212 +} ScePspVector4 __attribute__((aligned(16)));
15214 +/* 2D matrix types. */
15215 +typedef struct ScePspIMatrix2 {
15216 + ScePspIVector2 x;
15217 + ScePspIVector2 y;
15218 +} ScePspIMatrix2;
15220 +typedef struct ScePspFMatrix2 {
15221 + ScePspFVector2 x;
15222 + ScePspFVector2 y;
15223 +} ScePspFMatrix2;
15225 +typedef union ScePspMatrix2 {
15226 + ScePspFMatrix2 fm;
15227 + ScePspIMatrix2 im;
15228 + ScePspFVector2 fv[2];
15229 + ScePspIVector2 iv[2];
15230 + ScePspVector2 v[2];
15231 +/* SceULong128 qw[2];*/ /* Missing compiler support. */
15232 + float f[2][2];
15233 + int i[2][2];
15234 +} ScePspMatrix2;
15236 +/* 3D matrix types. */
15237 +typedef struct ScePspIMatrix3 {
15238 + ScePspIVector3 x;
15239 + ScePspIVector3 y;
15240 + ScePspIVector3 z;
15241 +} ScePspIMatrix3;
15243 +typedef struct ScePspFMatrix3 {
15244 + ScePspFVector3 x;
15245 + ScePspFVector3 y;
15246 + ScePspFVector3 z;
15247 +} ScePspFMatrix3;
15249 +typedef union ScePspMatrix3 {
15250 + ScePspFMatrix3 fm;
15251 + ScePspIMatrix3 im;
15252 + ScePspFVector3 fv[3];
15253 + ScePspIVector3 iv[3];
15254 + ScePspVector3 v[3];
15255 +/* SceULong128 qw[3];*/ /* Missing compiler support. */
15256 + float f[3][3];
15257 + int i[3][3];
15258 +} ScePspMatrix3;
15260 +/* 4D matrix types. */
15261 +typedef struct ScePspIMatrix4 {
15262 + ScePspIVector4 x;
15263 + ScePspIVector4 y;
15264 + ScePspIVector4 z;
15265 + ScePspIVector4 w;
15266 +} ScePspIMatrix4 __attribute__((aligned(16)));
15268 +typedef struct ScePspIMatrix4Unaligned {
15269 + ScePspIVector4 x;
15270 + ScePspIVector4 y;
15271 + ScePspIVector4 z;
15272 + ScePspIVector4 w;
15273 +} ScePspIMatrix4Unaligned;
15275 +typedef struct ScePspFMatrix4 {
15276 + ScePspFVector4 x;
15277 + ScePspFVector4 y;
15278 + ScePspFVector4 z;
15279 + ScePspFVector4 w;
15280 +} ScePspFMatrix4 __attribute__((aligned(16)));
15282 +typedef struct ScePspFMatrix4Unaligned {
15283 + ScePspFVector4 x;
15284 + ScePspFVector4 y;
15285 + ScePspFVector4 z;
15286 + ScePspFVector4 w;
15287 +} ScePspFMatrix4Unaligned;
15289 +typedef union ScePspMatrix4 {
15290 + ScePspFMatrix4 fm;
15291 + ScePspIMatrix4 im;
15292 + ScePspFVector4 fv[4];
15293 + ScePspIVector4 iv[4];
15294 + ScePspVector4 v[4];
15295 +/* SceULong128 qw[4];*/ /* Missing compiler support. */
15296 + float f[4][4];
15297 + int i[4][4];
15298 +} ScePspMatrix4;
15300 +/* Quaternions. */
15301 +typedef struct ScePspFQuaternion {
15302 + float x;
15303 + float y;
15304 + float z;
15305 + float w;
15306 +} ScePspFQuaternion __attribute__((aligned(16)));
15308 +typedef struct ScePspFQuaternionUnaligned {
15309 + float x;
15310 + float y;
15311 + float z;
15312 + float w;
15313 +} ScePspFQuaternionUnaligned;
15315 +/* Colors and pixel formats. */
15316 +typedef struct ScePspFColor {
15317 + float r;
15318 + float g;
15319 + float b;
15320 + float a;
15321 +} ScePspFColor __attribute__((aligned(16)));
15323 +typedef struct ScePspFColorUnaligned {
15324 + float r;
15325 + float g;
15326 + float b;
15327 + float a;
15328 +} ScePspFColorUnaligned;
15330 +typedef unsigned int ScePspRGBA8888;
15331 +typedef unsigned short ScePspRGBA4444;
15332 +typedef unsigned short ScePspRGBA5551;
15333 +typedef unsigned short ScePspRGB565;
15335 +/* Unions for converting between types. */
15336 +typedef union ScePspUnion32 {
15337 + unsigned int ui;
15338 + int i;
15339 + unsigned short us[2];
15340 + short int s[2];
15341 + unsigned char uc[4];
15342 + char c[4];
15343 + float f;
15344 + ScePspRGBA8888 rgba8888;
15345 + ScePspRGBA4444 rgba4444[2];
15346 + ScePspRGBA5551 rgba5551[2];
15347 + ScePspRGB565 rgb565[2];
15348 +} ScePspUnion32;
15350 +typedef union ScePspUnion64 {
15351 + SceULong64 ul;
15352 + SceLong64 l;
15353 + unsigned int ui[2];
15354 + int i[2];
15355 + unsigned short us[4];
15356 + short int s[4];
15357 + unsigned char uc[8];
15358 + char c[8];
15359 + float f[2];
15360 + ScePspSRect sr;
15361 + ScePspSVector4 sv;
15362 + ScePspRGBA8888 rgba8888[2];
15363 + ScePspRGBA4444 rgba4444[4];
15364 + ScePspRGBA5551 rgba5551[4];
15365 + ScePspRGB565 rgb565[4];
15366 +} ScePspUnion64;
15368 +typedef union ScePspUnion128 {
15369 +/* SceULong128 qw;*/ /* Missing compiler support. */
15370 +/* SceULong128 uq;*/
15371 +/* SceLong128 q;*/
15372 + SceULong64 ul[2];
15373 + SceLong64 l[2];
15374 + unsigned int ui[4];
15375 + int i[4];
15376 + unsigned short us[8];
15377 + short int s[8];
15378 + unsigned char uc[16];
15379 + char c[16];
15380 + float f[4];
15381 + ScePspFRect fr;
15382 + ScePspIRect ir;
15383 + ScePspFVector4 fv;
15384 + ScePspIVector4 iv;
15385 + ScePspFQuaternion fq;
15386 + ScePspFColor fc;
15387 + ScePspRGBA8888 rgba8888[4];
15388 + ScePspRGBA4444 rgba4444[8];
15389 + ScePspRGBA5551 rgba5551[8];
15390 + ScePspRGB565 rgb565[8];
15391 +} ScePspUnion128 __attribute__((aligned(16)));
15393 +/* Date and time. */
15394 +typedef struct ScePspDateTime {
15395 + unsigned short year;
15396 + unsigned short month;
15397 + unsigned short day;
15398 + unsigned short hour;
15399 + unsigned short minute;
15400 + unsigned short second;
15401 + unsigned int microsecond;
15402 +} ScePspDateTime;
15404 +#ifdef __cplusplus
15406 +#endif
15408 +#endif /* _PSPTYPES_H_ */
15409 diff --git a/newlib/psp/include/pspumd.h b/newlib/psp/include/pspumd.h
15410 new file mode 100644
15411 index 0000000..e64e32c
15412 --- /dev/null
15413 +++ b/newlib/psp/include/pspumd.h
15414 @@ -0,0 +1,215 @@
15416 + * PSP Software Development Kit - https://github.com/pspdev
15417 + * -----------------------------------------------------------------------
15418 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
15420 + * pspumd.h - Prototypes for the sceUmd library.
15422 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
15423 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
15424 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
15426 + */
15427 +#ifndef __UMD_H__
15428 +#define __UMD_H__
15430 +#ifdef __cplusplus
15431 +extern "C" {
15432 +#endif
15434 +/** @addtogroup UMD UMD Kernel Library */
15435 +/**@{*/
15437 +/** UMD Info struct */
15438 +typedef struct pspUmdInfo
15440 + /** Set to sizeof(pspUmdInfo) */
15441 + unsigned int size;
15442 + /** One or more of ::pspUmdTypes */
15443 + unsigned int type;
15445 +} pspUmdInfo;
15447 +/** Enumeration for UMD types */
15448 +enum pspUmdTypes
15450 + PSP_UMD_TYPE_GAME = 0x10,
15451 + PSP_UMD_TYPE_VIDEO = 0x20,
15452 + PSP_UMD_TYPE_AUDIO = 0x40
15455 +/** Enumeration for UMD drive state */
15456 +enum pspUmdState
15458 + PSP_UMD_NOT_PRESENT = 0x01,
15459 + PSP_UMD_PRESENT = 0x02,
15460 + PSP_UMD_CHANGED = 0x04,
15461 + PSP_UMD_INITING = 0x08,
15462 + PSP_UMD_INITED = 0x10,
15463 + PSP_UMD_READY = 0x20
15466 +/** Enumeration for UMD stats (legacy) */
15467 +enum UmdDriveStat
15469 + /** Wait for disc to be inserted */
15470 + UMD_WAITFORDISC = PSP_UMD_PRESENT,
15471 + /** Wait for the UMD to be initialised so it can be accessed from the mapped drive */
15472 + UMD_WAITFORINIT = PSP_UMD_READY
15475 +/** UMD Callback function */
15476 +typedef int (*UmdCallback)(int unknown, int event);
15478 +/**
15479 + * Check whether there is a disc in the UMD drive
15481 + * @return 0 if no disc present, anything else indicates a disc is inserted.
15482 + */
15483 +int sceUmdCheckMedium(void);
15485 +/**
15486 + * Get the disc info
15488 + * @param info - A pointer to a ::pspUmdInfo struct
15490 + * @return < 0 on error
15491 + */
15492 +int sceUmdGetDiscInfo(pspUmdInfo *info);
15494 +/**
15495 + * Activates the UMD drive
15496 + *
15497 + * @param unit - The unit to initialise (probably). Should be set to 1.
15499 + * @param drive - A prefix string for the fs device to mount the UMD on (e.g. "disc0:")
15501 + * @return < 0 on error
15503 + * @par Example:
15504 + * @code
15505 + * // Wait for disc and mount to filesystem
15506 + * int i;
15507 + * i = sceUmdCheckMedium();
15508 + * if(i == 0)
15509 + * {
15510 + * sceUmdWaitDriveStat(PSP_UMD_PRESENT);
15511 + * }
15512 + * sceUmdActivate(1, "disc0:"); // Mount UMD to disc0: file system
15513 + * sceUmdWaitDriveStat(PSP_UMD_READY);
15514 + * // Now you can access the UMD using standard sceIo functions
15515 + * @endcode
15516 + */
15517 +int sceUmdActivate(int unit, const char *drive);
15519 +/**
15520 + * Deativates the UMD drive
15521 + *
15522 + * @param unit - The unit to initialise (probably). Should be set to 1.
15524 + * @param drive - A prefix string for the fs device to mount the UMD on (e.g. "disc0:")
15526 + * @return < 0 on error
15527 + */
15528 +int sceUmdDeactivate(int unit, const char *drive);
15530 +/**
15531 + * Wait for the UMD drive to reach a certain state
15533 + * @param stat - One or more of ::pspUmdState
15535 + * @return < 0 on error
15536 + */
15537 +int sceUmdWaitDriveStat(int stat);
15539 +/**
15540 + * Wait for the UMD drive to reach a certain state
15542 + * @param stat - One or more of ::pspUmdState
15544 + * @param timeout - Timeout value in microseconds
15546 + * @return < 0 on error
15547 + */
15548 +int sceUmdWaitDriveStatWithTimer(int stat, unsigned int timeout);
15550 +/**
15551 + * Wait for the UMD drive to reach a certain state (plus callback)
15553 + * @param stat - One or more of ::pspUmdState
15555 + * @param timeout - Timeout value in microseconds
15557 + * @return < 0 on error
15558 + */
15559 +int sceUmdWaitDriveStatCB(int stat, unsigned int timeout);
15561 +/**
15562 + * Cancel a sceUmdWait* call
15564 + * @return < 0 on error
15565 + */
15566 +int sceUmdCancelWaitDriveStat(void);
15568 +/**
15569 + * Get (poll) the current state of the UMD drive
15571 + * @return < 0 on error, one or more of ::pspUmdState on success
15572 + */
15573 +int sceUmdGetDriveStat(void);
15575 +/**
15576 + * Get the error code associated with a failed event
15578 + * @return < 0 on error, the error code on success
15579 + */
15580 +int sceUmdGetErrorStat(void);
15582 +/**
15583 + * Register a callback for the UMD drive
15584 + * @note Callback is of type UmdCallback
15586 + * @param cbid - A callback ID created from sceKernelCreateCallback
15587 + * @return < 0 on error
15588 + * @par Example:
15589 + * @code
15590 + * int umd_callback(int unknown, int event)
15591 + * {
15592 + * //do something
15593 + * }
15594 + * int cbid = sceKernelCreateCallback("UMD Callback", umd_callback, NULL);
15595 + * sceUmdRegisterUMDCallBack(cbid);
15596 + * @endcode
15597 + */
15598 +int sceUmdRegisterUMDCallBack(int cbid);
15600 +/**
15601 + * Un-register a callback for the UMD drive
15603 + * @param cbid - A callback ID created from sceKernelCreateCallback
15605 + * @return < 0 on error
15606 + */
15607 +int sceUmdUnRegisterUMDCallBack(int cbid);
15609 +/**
15610 + * Permit UMD disc being replaced
15612 + * @return < 0 on error
15613 + */
15614 +int sceUmdReplacePermit(void);
15616 +/**
15617 + * Prohibit UMD disc being replaced
15619 + * @return < 0 on error
15620 + */
15621 +int sceUmdReplaceProhibit(void);
15623 +/**@}*/
15625 +#ifdef __cplusplus
15627 +#endif
15629 +#endif
15630 diff --git a/newlib/psp/include/pspusb.h b/newlib/psp/include/pspusb.h
15631 new file mode 100644
15632 index 0000000..45cbfa6
15633 --- /dev/null
15634 +++ b/newlib/psp/include/pspusb.h
15635 @@ -0,0 +1,91 @@
15637 + * PSP Software Development Kit - https://github.com/pspdev
15638 + * -----------------------------------------------------------------------
15639 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
15641 + * pspusb.h - Prototypes for the sceUsb library
15643 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
15645 + */
15646 +#ifndef __PSPUSB_H__
15647 +#define __PSPUSB_H__
15649 +#ifdef __cplusplus
15650 +extern "C" {
15651 +#endif
15653 +#define PSP_USBBUS_DRIVERNAME "USBBusDriver"
15655 +//Defines for use with status function return values
15656 +#define PSP_USB_ACTIVATED 0x200
15657 +#define PSP_USB_CABLE_CONNECTED 0x020
15658 +#define PSP_USB_CONNECTION_ESTABLISHED 0x002
15660 +/**
15661 + * Start a USB driver.
15662 + *
15663 + * @param driverName - name of the USB driver to start
15664 + * @param size - Size of arguments to pass to USB driver start
15665 + * @param args - Arguments to pass to USB driver start
15667 + * @return 0 on success
15668 + */
15669 +int sceUsbStart(const char* driverName, int size, void *args);
15671 +/**
15672 + * Stop a USB driver.
15673 + *
15674 + * @param driverName - name of the USB driver to stop
15675 + * @param size - Size of arguments to pass to USB driver stop
15676 + * @param args - Arguments to pass to USB driver stop
15678 + * @return 0 on success
15679 + */
15680 +int sceUsbStop(const char* driverName, int size, void *args);
15682 +/**
15683 + * Activate a USB driver.
15684 + *
15685 + * @param pid - Product ID for the default USB Driver
15687 + * @return 0 on success
15688 + */
15689 +int sceUsbActivate(u32 pid);
15691 +/**
15692 + * Deactivate USB driver.
15694 + * @param pid - Product ID for the default USB driver
15695 + *
15696 + * @return 0 on success
15697 + */
15698 +int sceUsbDeactivate(u32 pid);
15700 +/**
15701 + * Get USB state
15702 + *
15703 + * @return OR'd PSP_USB_* constants
15704 + */
15705 +int sceUsbGetState(void);
15707 +/**
15708 + * Get state of a specific USB driver
15709 + *
15710 + * @param driverName - name of USB driver to get status from
15712 + * @return 1 if the driver has been started, 2 if it is stopped
15713 + */
15714 +int sceUsbGetDrvState(const char* driverName);
15716 +#if 0
15717 +int sceUsbGetDrvList(u32 r4one, u32* r5ret, u32 r6one);
15718 +int sceUsbWaitState(u32 state, s32 waitmode, u32 *timeout);
15719 +int sceUsbWaitCancel(void);
15720 +#endif
15722 +#ifdef __cplusplus
15724 +#endif
15726 +#endif
15727 diff --git a/newlib/psp/include/pspusbacc.h b/newlib/psp/include/pspusbacc.h
15728 new file mode 100644
15729 index 0000000..29a7a5b
15730 --- /dev/null
15731 +++ b/newlib/psp/include/pspusbacc.h
15732 @@ -0,0 +1,25 @@
15734 + * PSP Software Development Kit - https://github.com/pspdev
15735 + * -----------------------------------------------------------------------
15736 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
15738 + * pspusbacc.h - Prototypes for the sceUsbAcc library
15740 + * Copyright (c) 2007 dot_blank
15742 + */
15743 +#ifndef __PSPUSBACC_H__
15744 +#define __PSPUSBACC_H__
15746 +#ifdef __cplusplus
15747 +extern "C" {
15748 +#endif
15750 +#define PSP_USBACC_DRIVERNAME "USBAccBaseDriver"
15752 +#ifdef __cplusplus
15754 +#endif
15756 +#endif
15758 diff --git a/newlib/psp/include/pspusbbus.h b/newlib/psp/include/pspusbbus.h
15759 new file mode 100644
15760 index 0000000..533ac92
15761 --- /dev/null
15762 +++ b/newlib/psp/include/pspusbbus.h
15763 @@ -0,0 +1,307 @@
15765 + * PSP Software Development Kit - https://github.com/pspdev
15766 + * -----------------------------------------------------------------------
15767 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
15769 + * pspusbbus.h - Prototypes for the sceUsbBus_driver library
15771 + * Copyright (c) 2006 James F
15773 + */
15774 +#ifndef __PSPUSBBUS_H__
15775 +#define __PSPUSBBUS_H__
15777 +#ifdef __cplusplus
15778 +extern "C" {
15779 +#endif
15781 +/** USB driver interface */
15782 +struct UsbInterface
15784 + /** Expectant interface (0 or -1) */
15785 + int expect_interface;
15786 + /** Unknown */
15787 + int unk8;
15788 + /** Number of interfaces */
15789 + int num_interface;
15792 +/** USB driver endpoint */
15793 +struct UsbEndpoint
15795 + /** Endpoint number (must be filled in sequentially) */
15796 + int endpnum;
15797 + /** Filled in by the bus driver */
15798 + int unk2;
15799 + /** Filled in by the bus driver */
15800 + int unk3;
15803 +/** USB string descriptor */
15804 +struct StringDescriptor
15806 + unsigned char bLength;
15807 + unsigned char bDescriptorType;
15808 + short bString[32];
15809 +} __attribute__((packed));
15811 +/** USB device descriptor */
15812 +struct DeviceDescriptor
15814 + unsigned char bLength;
15815 + unsigned char bDescriptorType;
15816 + unsigned short bcdUSB;
15817 + unsigned char bDeviceClass;
15818 + unsigned char bDeviceSubClass;
15819 + unsigned char bDeviceProtocol;
15820 + unsigned char bMaxPacketSize;
15821 + unsigned short idVendor;
15822 + unsigned short idProduct;
15823 + unsigned short bcdDevice;
15824 + unsigned char iManufacturer;
15825 + unsigned char iProduct;
15826 + unsigned char iSerialNumber;
15827 + unsigned char bNumConfigurations;
15828 +} __attribute__((packed));
15830 +/** USB configuration descriptor */
15831 +struct ConfigDescriptor
15833 + unsigned char bLength;
15834 + unsigned char bDescriptorType;
15835 + unsigned short wTotalLength;
15836 + unsigned char bNumInterfaces;
15837 + unsigned char bConfigurationValue;
15838 + unsigned char iConfiguration;
15839 + unsigned char bmAttributes;
15840 + unsigned char bMaxPower;
15841 +} __attribute__((packed));
15843 +/** USB Interface descriptor */
15844 +struct InterfaceDescriptor
15846 + unsigned char bLength;
15847 + unsigned char bDescriptorType;
15848 + unsigned char bInterfaceNumber;
15849 + unsigned char bAlternateSetting;
15850 + unsigned char bNumEndpoints;
15851 + unsigned char bInterfaceClass;
15852 + unsigned char bInterfaceSubClass;
15853 + unsigned char bInterfaceProtocol;
15854 + unsigned char iInterface;
15855 +} __attribute__((packed));
15857 +/** USB endpoint descriptor */
15858 +struct EndpointDescriptor
15860 + unsigned char bLength;
15861 + unsigned char bDescriptorType;
15862 + unsigned char bEndpointAddress;
15863 + unsigned char bmAttributes;
15864 + unsigned short wMaxPacketSize;
15865 + unsigned char bInterval;
15866 +} __attribute__((packed));
15868 +/** USB driver interfaces structure */
15869 +struct UsbInterfaces
15871 + /** Pointers to the individual interface descriptors */
15872 + struct InterfaceDescriptor *infp[2];
15873 + /** Number of interface descriptors */
15874 + unsigned int num;
15877 +/** USB driver configuration */
15878 +struct UsbConfiguration
15880 + /** Pointer to the configuration descriptors */
15881 + struct ConfigDescriptor *confp;
15882 + /** USB driver interfaces pointer */
15883 + struct UsbInterfaces *infs;
15884 + /** Pointer to the first interface descriptor */
15885 + struct InterfaceDescriptor *infp;
15886 + /** Pointer to the first endpoint descriptor (each should be 16byte aligned) */
15887 + struct EndpointDescriptor *endp;
15890 +/** Padded data structure, padding is required otherwise the USB hardware crashes */
15891 +struct UsbData
15893 + unsigned char devdesc[20];
15895 + struct Config
15897 + void *pconfdesc;
15898 + void *pinterfaces;
15899 + void *pinterdesc;
15900 + void *pendp;
15901 + } config;
15903 + struct ConfDesc
15905 + unsigned char desc[12];
15906 + void *pinterfaces;
15907 + } confdesc;
15909 + unsigned char pad1[8];
15910 + struct Interfaces
15912 + void *pinterdesc[2];
15913 + unsigned int intcount;
15914 + } interfaces;
15916 + struct InterDesc
15918 + unsigned char desc[12];
15919 + void *pendp;
15920 + unsigned char pad[32];
15921 + } interdesc;
15923 + struct Endp
15925 + unsigned char desc[16];
15926 + } endp[4];
15927 +} __attribute__((packed));
15929 +/** USB EP0 Device Request */
15930 +struct DeviceRequest
15932 + unsigned char bmRequestType;
15933 + unsigned char bRequest;
15934 + unsigned short wValue;
15935 + unsigned short wIndex;
15936 + unsigned short wLength;
15937 +} __attribute__((packed));
15939 +/** USB driver structure used by ::sceUsbbdRegister and ::sceUsbbdUnregister */
15940 +struct UsbDriver
15942 + /** Name of the USB driver */
15943 + const char *name;
15944 + /** Number of endpoints in this driver (including default control) */
15945 + int endpoints;
15946 + /** List of endpoint structures (used when calling other functions) */
15947 + struct UsbEndpoint *endp;
15948 + /** Interface list */
15949 + struct UsbInterface *intp;
15950 + /** Pointer to hi-speed device descriptor */
15951 + void *devp_hi;
15952 + /** Pointer to hi-speed device configuration */
15953 + void *confp_hi;
15954 + /** Pointer to full-speed device descriptor */
15955 + void *devp;
15956 + /** Pointer to full-speed device configuration */
15957 + void *confp;
15958 + /** Default String descriptor */
15959 + struct StringDescriptor *str;
15960 + /** Received a control request arg0 is endpoint, arg1 is possibly data arg2 is data buffer */
15961 + int (*recvctl)(int arg1, int arg2, struct DeviceRequest *req);
15962 + /** Unknown */
15963 + int (*func28)(int arg1, int arg2, int arg3);
15964 + /** Configuration set (attach) function */
15965 + int (*attach)(int speed, void *arg2, void *arg3);
15966 + /** Configuration unset (detach) function */
15967 + int (*detach)(int arg1, int arg2, int arg3);
15968 + /** Unknown set to 0 */
15969 + int unk34;
15970 + /** Function called when the driver is started */
15971 + int (*start_func)(int size, void *args);
15972 + /** Function called when the driver is stopped */
15973 + int (*stop_func)(int size, void *args);
15974 + /** Link to next USB driver in the chain, set to NULL */
15975 + struct UsbDriver *link;
15978 +/** USB device request, used by ::sceUsbbdReqSend and ::sceUsbbdReqRecv. */
15979 +struct UsbdDeviceReq
15981 + /** Pointer to the endpoint to queue request on */
15982 + struct UsbEndpoint *endp;
15983 + /** Pointer to the data buffer to use in the request */
15984 + void *data;
15985 + /** Size of the data buffer (send == size of data, recv == size of max receive) */
15986 + int size;
15987 + /** Unknown */
15988 + int unkc;
15989 + /** Pointer to the function to call on completion */
15990 + void *func;
15991 + /** Resultant size (send == size of data sent, recv == size of data received) */
15992 + int recvsize;
15993 + /** Return code of the request, 0 == success, -3 == cancelled */
15994 + int retcode;
15995 + /** Unknown */
15996 + int unk1c;
15997 + /** A user specified pointer for the device request */
15998 + void *arg;
15999 + /** Link pointer to next request used by the driver, set it to NULL */
16000 + void *link;
16003 +/**
16004 + * Register a USB driver.
16006 + * @param drv - Pointer to a filled out USB driver
16008 + * @return 0 on success, < 0 on error
16009 + */
16010 +int sceUsbbdRegister(struct UsbDriver *drv);
16012 +/**
16013 + * Unregister a USB driver
16015 + * @param drv - Pointer to a filled out USB driver
16017 + * @return 0 on success, < 0 on error
16018 + */
16019 +int sceUsbbdUnregister(struct UsbDriver *drv);
16021 +/**
16022 + * Clear the FIFO on an endpoint
16024 + * @param endp - The endpoint to clear
16026 + * @return 0 on success, < 0 on error
16027 + */
16028 +int sceUsbbdClearFIFO(struct UsbEndpoint *endp);
16030 +/**
16031 + * Cancel any pending requests on an endpoint.
16033 + * @param endp - The endpoint to cancel
16035 + * @return 0 on success, < 0 on error
16036 + */
16037 +int sceUsbbdReqCancelAll(struct UsbEndpoint *endp);
16039 +/**
16040 + * Stall an endpoint
16042 + * @param endp - The endpoint to stall
16044 + * @return 0 on success, < 0 on error
16045 + */
16046 +int sceUsbbdStall(struct UsbEndpoint *endp);
16048 +/**
16049 + * Queue a send request (IN from host pov)
16051 + * @param req - Pointer to a filled out UsbdDeviceReq structure.
16053 + * @return 0 on success, < 0 on error
16054 + */
16055 +int sceUsbbdReqSend(struct UsbdDeviceReq *req);
16057 +/**
16058 + * Queue a receive request (OUT from host pov)
16060 + * @param req - Pointer to a filled out UsbdDeviceReq structure
16062 + * @return 0 on success, < 0 on error
16063 + */
16064 +int sceUsbbdReqRecv(struct UsbdDeviceReq *req);
16066 +#ifdef __cplusplus
16068 +#endif
16070 +#endif
16071 diff --git a/newlib/psp/include/pspusbcam.h b/newlib/psp/include/pspusbcam.h
16072 new file mode 100644
16073 index 0000000..c834ce8
16074 --- /dev/null
16075 +++ b/newlib/psp/include/pspusbcam.h
16076 @@ -0,0 +1,575 @@
16078 + * PSP Software Development Kit - https://github.com/pspdev
16079 + * -----------------------------------------------------------------------
16080 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16082 + * pspusbcam.h - Prototypes for the sceUsbCam library
16084 + * Copyright (c) 2007 dot_blank
16086 + */
16087 +#ifndef __PSPUSBCAM_H__
16088 +#define __PSPUSBCAM_H__
16090 +#ifdef __cplusplus
16091 +extern "C" {
16092 +#endif
16094 +#define PSP_USBCAM_PID (0x282)
16095 +#define PSP_USBCAM_DRIVERNAME "USBCamDriver"
16096 +#define PSP_USBCAMMIC_DRIVERNAME "USBCamMicDriver"
16098 +/** Resolutions for sceUsbCamSetupStill &
16099 + sceUsbCamSetupVideo
16100 + ** DO NOT use on sceUsbCamSetupStillEx & sceUsbCamSetupVideoEx */
16101 +enum PspUsbCamResolution
16103 + PSP_USBCAM_RESOLUTION_160_120 = 0,
16104 + PSP_USBCAM_RESOLUTION_176_144 = 1,
16105 + PSP_USBCAM_RESOLUTION_320_240 = 2,
16106 + PSP_USBCAM_RESOLUTION_352_288 = 3,
16107 + PSP_USBCAM_RESOLUTION_640_480 = 4,
16108 + PSP_USBCAM_RESOLUTION_1024_768 = 5,
16109 + PSP_USBCAM_RESOLUTION_1280_960 = 6,
16110 + PSP_USBCAM_RESOLUTION_480_272 = 7,
16111 + PSP_USBCAM_RESOLUTION_360_272 = 8,
16114 +/** Resolutions for sceUsbCamSetupStillEx &
16115 + sceUsbCamSetupVideoEx
16116 + ** DO NOT use on sceUsbCamSetupStill & sceUsbCamSetupVideo */
16117 +enum PspUsbCamResolutionEx
16119 + PSP_USBCAM_RESOLUTION_EX_160_120 = 0,
16120 + PSP_USBCAM_RESOLUTION_EX_176_144 = 1,
16121 + PSP_USBCAM_RESOLUTION_EX_320_240 = 2,
16122 + PSP_USBCAM_RESOLUTION_EX_352_288 = 3,
16123 + PSP_USBCAM_RESOLUTION_EX_360_272 = 4,
16124 + PSP_USBCAM_RESOLUTION_EX_480_272 = 5,
16125 + PSP_USBCAM_RESOLUTION_EX_640_480 = 6,
16126 + PSP_USBCAM_RESOLUTION_EX_1024_768 = 7,
16127 + PSP_USBCAM_RESOLUTION_EX_1280_960 = 8,
16130 +/** Flags for reverse effects. */
16131 +enum PspUsbCamReverseFlags
16133 + PSP_USBCAM_FLIP = 1,
16134 + PSP_USBCAM_MIRROR = 0x100,
16137 +/** Delay to take pictures */
16138 +enum PspUsbCamDelay
16140 + PSP_USBCAM_NODELAY = 0,
16141 + PSP_USBCAM_DELAY_10SEC = 1,
16142 + PSP_USBCAM_DELAY_20SEC = 2,
16143 + PSP_USBCAM_DELAY_30SEC = 3,
16146 +/** Usbcam framerates */
16147 +enum PspUsbCamFrameRate
16149 + PSP_USBCAM_FRAMERATE_3_75_FPS = 0, /* 3.75 fps */
16150 + PSP_USBCAM_FRAMERATE_5_FPS = 1,
16151 + PSP_USBCAM_FRAMERATE_7_5_FPS = 2, /* 7.5 fps */
16152 + PSP_USBCAM_FRAMERATE_10_FPS = 3,
16153 + PSP_USBCAM_FRAMERATE_15_FPS = 4,
16154 + PSP_USBCAM_FRAMERATE_20_FPS = 5,
16155 + PSP_USBCAM_FRAMERATE_30_FPS = 6,
16156 + PSP_USBCAM_FRAMERATE_60_FPS = 7,
16159 +/** White balance values */
16160 +enum PspUsbCamWB
16162 + PSP_USBCAM_WB_AUTO = 0,
16163 + PSP_USBCAM_WB_DAYLIGHT = 1,
16164 + PSP_USBCAM_WB_FLUORESCENT = 2,
16165 + PSP_USBCAM_WB_INCADESCENT = 3,
16168 +/** Effect modes */
16169 +enum PspUsbCamEffectMode
16171 + PSP_USBCAM_EFFECTMODE_NORMAL = 0,
16172 + PSP_USBCAM_EFFECTMODE_NEGATIVE = 1,
16173 + PSP_USBCAM_EFFECTMODE_BLACKWHITE = 2,
16174 + PSP_USBCAM_EFFECTMODE_SEPIA = 3,
16175 + PSP_USBCAM_EFFECTMODE_BLUE = 4,
16176 + PSP_USBCAM_EFFECTMODE_RED = 5,
16177 + PSP_USBCAM_EFFECTMODE_GREEN = 6,
16180 +/** Exposure levels */
16181 +enum PspUsbCamEVLevel
16183 + PSP_USBCAM_EVLEVEL_2_0_POSITIVE = 0, // +2.0
16184 + PSP_USBCAM_EVLEVEL_1_7_POSITIVE = 1, // +1.7
16185 + PSP_USBCAM_EVLEVEL_1_5_POSITIVE = 2, // +1.5
16186 + PSP_USBCAM_EVLEVEL_1_3_POSITIVE = 3, // +1.3
16187 + PSP_USBCAM_EVLEVEL_1_0_POSITIVE = 4, // +1.0
16188 + PSP_USBCAM_EVLEVEL_0_7_POSITIVE = 5, // +0.7
16189 + PSP_USBCAM_EVLEVEL_0_5_POSITIVE = 6, // +0.5
16190 + PSP_USBCAM_EVLEVEL_0_3_POSITIVE = 7, // +0.3
16191 + PSP_USBCAM_EVLEVEL_0_0 = 8, // 0.0
16192 + PSP_USBCAM_EVLEVEL_0_3_NEGATIVE = 9, // -0.3
16193 + PSP_USBCAM_EVLEVEL_0_5_NEGATIVE = 10, // -0.5
16194 + PSP_USBCAM_EVLEVEL_0_7_NEGATIVE = 11, // -0.7
16195 + PSP_USBCAM_EVLEVEL_1_0_NEGATIVE = 12, // -1.0
16196 + PSP_USBCAM_EVLEVEL_1_3_NEGATIVE = 13, // -1.3
16197 + PSP_USBCAM_EVLEVEL_1_5_NEGATIVE = 14, // -1.5
16198 + PSP_USBCAM_EVLEVEL_1_7_NEGATIVE = 15, // -1.7
16199 + PSP_USBCAM_EVLEVEL_2_0_NEGATIVE = 16, // -2.0
16204 +/** Structure for sceUsbCamSetupStill */
16205 +typedef struct PspUsbCamSetupStillParam {
16206 +/** Size of the ::PspUsbCamSetupStillParam structure */
16207 + int size;
16208 +/** Resolution. One of ::PspUsbCamResolution */
16209 + int resolution;
16210 +/** Size of the jpeg image */
16211 + int jpegsize;
16212 +/** Reverse effect to apply. Zero or more of ::PspUsbCamReverseFlags */
16213 + int reverseflags;
16214 +/** Delay to apply to take the picture. One of ::PspUsbCamDelay */
16215 + int delay;
16216 +/** JPEG compression level, a value from 1-63.
16217 + 1 -> less compression, better quality; 63 -> max compression, worse quality */
16218 + int complevel;
16219 +} PspUsbCamSetupStillParam;
16221 +/** Structure for sceUsbCamSetupStillEx */
16222 +typedef struct PspUsbCamSetupStillExParam {
16223 +/** Size of the ::PspUsbCamSetupStillExParam structure */
16224 + int size;
16225 +/** Unknown, set it to 9 at the moment. */
16226 + u32 unk;
16227 +/** Resolution. One of ::PspUsbCamResolutionEx */
16228 + int resolution;
16229 +/** Size of the jpeg image */
16230 + int jpegsize;
16231 +/** JPEG compression level, a value from 1-63.
16232 + 1 -> less compression, better quality; 63 -> max compression, worse quality */
16233 + int complevel;
16234 +/** Unknown, set it to 0 at the moment */
16235 + u32 unk2;
16236 +/** Unknown, set it to 1 at the moment */
16237 + u32 unk3;
16238 +/** Flag that indicates whether to flip the image */
16239 + int flip;
16240 +/** Flag that indicates whether to mirror the image */
16241 + int mirror;
16242 +/** Delay to apply to take the picture. One of ::PspUsbCamDelay */
16243 + int delay;
16244 +/** Unknown, set it to 0 at the moment */
16245 + u32 unk4[5];
16246 +} PspUsbCamSetupStillExParam;
16248 +typedef struct PspUsbCamSetupVideoParam {
16249 +/** Size of the ::PspUsbCamSetupVideoParam structure */
16250 + int size;
16251 +/** Resolution. One of ::PspUsbCamResolution */
16252 + int resolution;
16253 +/** Framerate. One of ::PspUsbCamFrameRate */
16254 + int framerate;
16255 +/** White balance. One of ::PspUsbCamWB */
16256 + int wb;
16257 +/** Saturarion (0-255) */
16258 + int saturation;
16259 +/** Brightness (0-255) */
16260 + int brightness;
16261 +/** Contrast (0-255) */
16262 + int contrast;
16263 +/** Sharpness (0-255) */
16264 + int sharpness;
16265 +/** Effect mode. One of ::PspUsbCamEffectMode */
16266 + int effectmode;
16267 +/** Size of jpeg video frame */
16268 + int framesize;
16269 +/** Unknown. Set it to 0 at the moment. */
16270 + u32 unk;
16271 +/** Exposure value. One of ::PspUsbCamEVLevel */
16272 + int evlevel;
16273 +} PspUsbCamSetupVideoParam;
16275 +typedef struct PspUsbCamSetupVideoExParam {
16276 +/** Size of the ::PspUsbCamSetupVideoParam structure */
16277 + int size;
16278 +/* Unknown. Set it to 9 at the moment. */
16279 + u32 unk;
16280 +/** Resolution. One of ::PspUsbCamResolutionEx */
16281 + int resolution;
16282 +/** Framerate. One of ::PspUsbCamFrameRate */
16283 + int framerate;
16284 +/** Unknown. Set it to 2 at the moment */
16285 + u32 unk2;
16286 +/** Unknown. Set it to 3 at the moment */
16287 + u32 unk3;
16288 +/** White balance. One of ::PspUsbCamWB */
16289 + int wb;
16290 +/** Saturarion (0-255) */
16291 + int saturation;
16292 +/** Brightness (0-255) */
16293 + int brightness;
16294 +/** Contrast (0-255) */
16295 + int contrast;
16296 +/** Sharpness (0-255) */
16297 + int sharpness;
16298 +/** Unknown. Set it to 0 at the moment */
16299 + u32 unk4;
16300 +/** Unknown. Set it to 1 at the moment */
16301 + u32 unk5;
16302 +/** Unknown. Set it to 0 at the moment */
16303 + u32 unk6[3];
16304 +/** Effect mode. One of ::PspUsbCamEffectMode */
16305 + int effectmode;
16306 +/** Unknown. Set it to 1 at the moment */
16307 + u32 unk7;
16308 +/** Unknown. Set it to 10 at the moment */
16309 + u32 unk8;
16310 +/** Unknown. Set it to 2 at the moment */
16311 + u32 unk9;
16312 +/** Unknown. Set it to 500 at the moment */
16313 + u32 unk10;
16314 +/** Unknown. Set it to 1000 at the moment */
16315 + u32 unk11;
16316 +/** Size of jpeg video frame */
16317 + int framesize;
16318 +/** Unknown. Set it to 0 at the moment */
16319 + u32 unk12;
16320 +/** Exposure value. One of ::PspUsbCamEVLevel */
16321 + int evlevel;
16322 +} PspUsbCamSetupVideoExParam;
16324 +/**
16325 + * Setups the parameters to take a still image.
16327 + * @param param - pointer to a ::PspUsbCamSetupStillParam
16329 + * @return 0 on success, < 0 on error
16331 +int sceUsbCamSetupStill(PspUsbCamSetupStillParam *param);
16333 +/**
16334 + * Setups the parameters to take a still image (with more options)
16336 + * @param param - pointer to a ::PspUsbCamSetupStillExParam
16338 + * @return 0 on success, < 0 on error
16340 +int sceUsbCamSetupStillEx(PspUsbCamSetupStillExParam *param);
16342 +/**
16343 + * Gets a still image. The function doesn't return until the image
16344 + * has been acquired.
16346 + * @param buf - The buffer that receives the image jpeg data
16347 + * @param size - The size of the buffer.
16349 + * @return size of acquired image on success, < 0 on error
16351 +int sceUsbCamStillInputBlocking(u8 *buf, SceSize size);
16353 +/**
16354 + * Gets a still image. The function returns inmediately, and
16355 + * the completion has to be handled by calling ::sceUsbCamStillWaitInputEnd
16356 + * or ::sceUsbCamStillPollInputEnd.
16358 + * @param buf - The buffer that receives the image jpeg data
16359 + * @param size - The size of the buffer.
16361 + * @return 0 on success, < 0 on error
16363 +int sceUsbCamStillInput(u8 *buf, SceSize size);
16365 +/**
16366 + * Waits untils still input has been finished.
16368 + * @return the size of the acquired image on sucess, < 0 on error
16370 +int sceUsbCamStillWaitInputEnd(void);
16372 +/**
16373 + * Polls the status of still input completion.
16375 + * @return the size of the acquired image if still input has ended,
16376 + * 0 if the input has not ended, < 0 on error.
16378 +int sceUsbCamStillPollInputEnd(void);
16380 +/**
16381 + * Cancels the still input.
16383 + * @return 0 on success, < 0 on error
16385 +int sceUsbCamStillCancelInput(void);
16387 +/**
16388 + * Gets the size of the acquired still image.
16390 + * @return the size of the acquired image on success, < 0 on error
16392 +int sceUsbCamStillGetInputLength(void);
16394 +/**
16395 + * Set ups the parameters for video capture.
16397 + * @param param - Pointer to a ::PspUsbCamSetupVideoParam structure.
16398 + * @param workarea - Pointer to a buffer used as work area by the driver.
16399 + * @param wasize - Size of the work area.
16401 + * @return 0 on success, < 0 on error
16403 +int sceUsbCamSetupVideo(PspUsbCamSetupVideoParam *param, void *workarea, int wasize);
16405 +/**
16406 + * Set ups the parameters for video capture (with more options)
16408 + * @param param - Pointer to a ::PspUsbCamSetupVideoExParam structure.
16409 + * @param workarea - Pointer to a buffer used as work area by the driver.
16410 + * @param wasize - Size of the work area.
16412 + * @return 0 on success, < 0 on error
16414 +int sceUsbCamSetupVideoEx(PspUsbCamSetupVideoExParam *param, void *workarea, int wasize);
16416 +/**
16417 + * Starts video input from the camera.
16419 + * @return 0 on success, < 0 on error
16421 +int sceUsbCamStartVideo(void);
16423 +/**
16424 + * Stops video input from the camera.
16426 + * @return 0 on success, < 0 on error
16428 +int sceUsbCamStopVideo(void);
16430 +/**
16431 + * Reads a video frame. The function doesn't return until the frame
16432 + * has been acquired.
16434 + * @param buf - The buffer that receives the frame jpeg data
16435 + * @param size - The size of the buffer.
16437 + * @return size of acquired frame on success, < 0 on error
16439 +int sceUsbCamReadVideoFrameBlocking(u8 *buf, SceSize size);
16441 +/**
16442 + * Reads a video frame. The function returns inmediately, and
16443 + * the completion has to be handled by calling ::sceUsbCamWaitReadVideoFrameEnd
16444 + * or ::sceUsbCamPollReadVideoFrameEnd.
16446 + * @param buf - The buffer that receives the frame jpeg data
16447 + * @param size - The size of the buffer.
16449 + * @return 0 on success, < 0 on error
16451 +int sceUsbCamReadVideoFrame(u8 *buf, SceSize size);
16453 +/**
16454 + * Waits untils the current frame has been read.
16456 + * @return the size of the acquired frame on sucess, < 0 on error
16458 +int sceUsbCamWaitReadVideoFrameEnd(void);
16460 +/**
16461 + * Polls the status of video frame read completion.
16463 + * @return the size of the acquired frame if it has been read,
16464 + * 0 if the frame has not yet been read, < 0 on error.
16466 +int sceUsbCamPollReadVideoFrameEnd(void);
16468 +/**
16469 + * Gets the size of the acquired frame.
16471 + * @return the size of the acquired frame on success, < 0 on error
16473 +int sceUsbCamGetReadVideoFrameSize(void);
16475 +/**
16476 + * Sets the saturation
16478 + * @param saturation - The saturation (0-255)
16480 + * @return 0 on success, < 0 on error
16482 +int sceUsbCamSetSaturation(int saturation);
16484 +/**
16485 + * Sets the brightness
16487 + * @param brightness - The brightness (0-255)
16489 + * @return 0 on success, < 0 on error
16491 +int sceUsbCamSetBrightness(int brightness);
16493 +/**
16494 + * Sets the contrast
16496 + * @param contrast - The contrast (0-255)
16498 + * @return 0 on success, < 0 on error
16500 +int sceUsbCamSetContrast(int contrast);
16502 +/**
16503 + * Sets the sharpness
16505 + * @param sharpness - The sharpness (0-255)
16507 + * @return 0 on success, < 0 on error
16509 +int sceUsbCamSetSharpness(int sharpness);
16511 +/**
16512 + * Sets the image effect mode
16514 + * @param effectmode - The effect mode, one of ::PspUsbCamEffectMode
16516 + * @return 0 on success, < 0 on error
16518 +int sceUsbCamSetImageEffectMode(int effectmode);
16520 +/**
16521 + * Sets the exposure level
16523 + * @param ev - The exposure level, one of ::PspUsbCamEVLevel
16525 + * @return 0 on success, < 0 on error
16527 +int sceUsbCamSetEvLevel(int ev);
16529 +/**
16530 + * Sets the reverse mode
16532 + * @param reverseflags - The reverse flags, zero or more of ::PspUsbCamReverseFlags
16534 + * @return 0 on success, < 0 on error
16536 +int sceUsbCamSetReverseMode(int reverseflags);
16538 +/**
16539 + * Sets the zoom.
16541 + * @param zoom - The zoom level starting by 10. (10 = 1X, 11 = 1.1X, etc)
16543 + * @returns 0 on success, < 0 on error
16545 +int sceUsbCamSetZoom(int zoom);
16547 +/**
16548 + * Gets the current saturation
16550 + * @param saturation - pointer to a variable that receives the current saturation
16552 + * @return 0 on success, < 0 on error
16554 +int sceUsbCamGetSaturation(int *saturation);
16556 +/**
16557 + * Gets the current brightness
16559 + * @param brightness - pointer to a variable that receives the current brightness
16561 + * @return 0 on success, < 0 on error
16563 +int sceUsbCamGetBrightness(int *brightness);
16565 +/**
16566 + * Gets the current contrast
16568 + * @param contrast - pointer to a variable that receives the current contrast
16570 + * @return 0 on success, < 0 on error
16572 +int sceUsbCamGetContrast(int *contrast);
16574 +/**
16575 + * Gets the current sharpness
16577 + * @param sharpness - pointer to a variable that receives the current sharpness
16579 + * @return 0 on success, < 0 on error
16581 +int sceUsbCamGetSharpness(int *sharpness);
16583 +/**
16584 + * Gets the current image efect mode
16586 + * @param effectmode - pointer to a variable that receives the current effect mode
16588 + * @return 0 on success, < 0 on error
16590 +int sceUsbCamGetImageEffectMode(int *effectmode);
16592 +/**
16593 + * Gets the current exposure level.
16595 + * @param ev - pointer to a variable that receives the current exposure level
16597 + * @return 0 on success, < 0 on error
16599 +int sceUsbCamGetEvLevel(int *ev);
16601 +/**
16602 + * Gets the current reverse mode.
16604 + * @param reverseflags - pointer to a variable that receives the current reverse mode flags
16606 + * @return 0 on success, < 0 on error
16608 +int sceUsbCamGetReverseMode(int *reverseflags);
16610 +/**
16611 + * Gets the current zoom.
16613 + * @param zoom - pointer to a variable that receives the current zoom
16615 + * @return 0 on success, < 0 on error
16617 +int sceUsbCamGetZoom(int *zoom);
16619 +/**
16620 + * Sets if the image should be automatically reversed, depending of the position
16621 + * of the camera.
16623 + * @param on - 1 to set the automatical reversal of the image, 0 to set it off
16625 + * @return 0 on success, < 0 on error
16627 +int sceUsbCamAutoImageReverseSW(int on);
16629 +/**
16630 + * Gets the state of the autoreversal of the image.
16632 + * @return 1 if it is set to automatic, 0 otherwise
16634 +int sceUsbCamGetAutoImageReverseState(void);
16636 +/**
16637 + * Gets the direction of the camera lens
16639 + * @return 1 if the camera is "looking to you", 0 if the camera
16640 + * is "looking to the other side".
16642 +int sceUsbCamGetLensDirection(void);
16644 +#ifdef __cplusplus
16646 +#endif
16648 +#endif
16652 diff --git a/newlib/psp/include/pspusbstor.h b/newlib/psp/include/pspusbstor.h
16653 new file mode 100644
16654 index 0000000..d5d97eb
16655 --- /dev/null
16656 +++ b/newlib/psp/include/pspusbstor.h
16657 @@ -0,0 +1,63 @@
16659 + * PSP Software Development Kit - https://github.com/pspdev
16660 + * -----------------------------------------------------------------------
16661 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16663 + * pspusbstor.h - Prototypes for the sceUsbStor and sceUsbStorBoot libraries
16665 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
16667 + */
16668 +#ifndef __PSPUSBSTOR_H__
16669 +#define __PSPUSBSTOR_H__
16671 +#ifdef __cplusplus
16672 +extern "C" {
16673 +#endif
16675 +#define PSP_USBSTOR_DRIVERNAME "USBStor_Driver"
16677 +/**
16678 + * Register an eventFlag to send notifications to.
16679 + *
16680 + * @param eventFlag - eventFlag created with sceKernelCreateEventFlag
16682 + * @return 0 on success
16683 + */
16684 +int sceUsbstorBootRegisterNotify(u32 eventFlag);
16686 +/**
16687 + * Unregister a previously registered eventFlag.
16688 + *
16689 + * @param eventFlag - eventFlag created with sceKernelCreateEventFlag
16691 + * @return 0 on success
16692 + */
16693 +int sceUsbstorBootUnregisterNotify(u32 eventFlag);
16695 +/**
16696 + * Tell the USBstorBoot driver the size of MS
16698 + * @note I'm not sure if this is the actual size of the media or not
16699 + * as it seems to have no bearing on what size windows detects.
16700 + * PSPPET passes 0x800000
16701 + *
16702 + * @param size - capacity of memory stick
16704 + * @return 0 on success
16705 + */
16706 +int sceUsbstorBootSetCapacity(u32 size);
16708 +// the following are disabled until more testing is done
16709 +#if 0
16710 +int sceUsbstorBootGetDataSize(void); // what for ?
16711 +int sceUsbstorBootSetLoadAddr(u32 addr); // ?
16712 +int sceUsbstorBootSetStatus(u32 status); // 1=?
16713 +int sceUsbstorGetStatus(?)
16714 +#endif
16716 +#ifdef __cplusplus
16718 +#endif
16720 +#endif
16721 diff --git a/newlib/psp/include/pspuser.h b/newlib/psp/include/pspuser.h
16722 new file mode 100644
16723 index 0000000..3c9651b
16724 --- /dev/null
16725 +++ b/newlib/psp/include/pspuser.h
16726 @@ -0,0 +1,30 @@
16728 + * PSP Software Development Kit - https://github.com/pspdev
16729 + * -----------------------------------------------------------------------
16730 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16732 + * pspuser.h - Main include file for the user interface to the PSP kernel.
16734 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
16735 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
16736 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
16738 + */
16740 +#ifndef PSPUSER_H
16741 +#define PSPUSER_H
16743 +#include <psptypes.h>
16744 +#include <pspkerneltypes.h>
16745 +#include <pspiofilemgr.h>
16746 +#include <psploadexec.h>
16747 +#include <pspmoduleinfo.h>
16748 +#include <pspmodulemgr.h>
16749 +#include <pspsysmem.h>
16750 +#include <pspthreadman.h>
16751 +#include <psputils.h>
16752 +#include <pspkerror.h>
16753 +#include <pspstdio.h>
16754 +#include <pspintrman.h>
16756 +#endif /* PSPUSER_H */
16757 diff --git a/newlib/psp/include/psputility.h b/newlib/psp/include/psputility.h
16758 new file mode 100644
16759 index 0000000..3d60e25
16760 --- /dev/null
16761 +++ b/newlib/psp/include/psputility.h
16762 @@ -0,0 +1,57 @@
16764 + * PSP Software Development Kit - https://github.com/pspdev
16765 + * -----------------------------------------------------------------------
16766 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16768 + * psputility.h - Master include for the pspUtility library
16770 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
16772 + */
16773 +#ifndef __PSPUTILITY_H__
16774 +#define __PSPUTILITY_H__
16776 +typedef struct
16778 + unsigned int size; /** Size of the structure */
16779 + int language; /** Language */
16780 + int buttonSwap; /** Set to 1 for X/O button swap */
16781 + int graphicsThread; /** Graphics thread priority */
16782 + int accessThread; /** Access/fileio thread priority (SceJobThread) */
16783 + int fontThread; /** Font thread priority (ScePafThread) */
16784 + int soundThread; /** Sound thread priority */
16785 + int result; /** Result */
16786 + int reserved[4]; /** Set to 0 */
16788 +} pspUtilityDialogCommon;
16790 +#include <psputility_msgdialog.h>
16791 +#include <psputility_netconf.h>
16792 +#include <psputility_netparam.h>
16793 +#include <psputility_savedata.h>
16794 +#include <psputility_gamesharing.h>
16795 +#include <psputility_htmlviewer.h>
16796 +#include <psputility_sysparam.h>
16797 +#include <psputility_osk.h>
16798 +#include <psputility_netmodules.h>
16799 +#include <psputility_avmodules.h>
16800 +#include <psputility_usbmodules.h>
16801 +#include <psputility_modules.h>
16803 +#define PSP_UTILITY_ACCEPT_CIRCLE 0
16804 +#define PSP_UTILITY_ACCEPT_CROSS 1
16806 +/**
16807 + * Return-values for the various sceUtility***GetStatus() functions
16808 +**/
16809 +typedef enum
16811 + PSP_UTILITY_DIALOG_NONE = 0, /**< No dialog is currently active */
16812 + PSP_UTILITY_DIALOG_INIT, /**< The dialog is currently being initialized */
16813 + PSP_UTILITY_DIALOG_VISIBLE, /**< The dialog is visible and ready for use */
16814 + PSP_UTILITY_DIALOG_QUIT, /**< The dialog has been canceled and should be shut down */
16815 + PSP_UTILITY_DIALOG_FINISHED /**< The dialog has successfully shut down */
16817 +} pspUtilityDialogState;
16819 +#endif
16820 diff --git a/newlib/psp/include/psputility_avmodules.h b/newlib/psp/include/psputility_avmodules.h
16821 new file mode 100644
16822 index 0000000..01fb928
16823 --- /dev/null
16824 +++ b/newlib/psp/include/psputility_avmodules.h
16825 @@ -0,0 +1,52 @@
16827 + * PSP Software Development Kit - https://github.com/pspdev
16828 + * -----------------------------------------------------------------------
16829 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16831 + * psputility_avmodules.h - Load audio/video modules from user mode on 2.xx+
16833 + * Copyright (c) 2007 David Perry <tias_dp@hotmail.com>
16835 + */
16836 +#ifndef __PSPUTILITY_AVMODULES_H__
16837 +#define __PSPUTILITY_AVMODULES_H__
16839 +#ifdef __cplusplus
16840 +extern "C" {
16841 +#endif
16843 +#include <psptypes.h>
16845 +#define PSP_AV_MODULE_AVCODEC 0
16846 +#define PSP_AV_MODULE_SASCORE 1
16847 +#define PSP_AV_MODULE_ATRAC3PLUS 2 // Requires PSP_AV_MODULE_AVCODEC loading first
16848 +#define PSP_AV_MODULE_MPEGBASE 3 // Requires PSP_AV_MODULE_AVCODEC loading first
16849 +#define PSP_AV_MODULE_MP3 4
16850 +#define PSP_AV_MODULE_VAUDIO 5
16851 +#define PSP_AV_MODULE_AAC 6
16852 +#define PSP_AV_MODULE_G729 7
16854 +/**
16855 + * Load an audio/video module (PRX) from user mode.
16857 + * Available on firmware 2.00 and higher only.
16859 + * @param module - module number to load (PSP_AV_MODULE_xxx)
16860 + * @return 0 on success, < 0 on error
16861 + */
16862 +int sceUtilityLoadAvModule(int module);
16864 +/**
16865 + * Unload an audio/video module (PRX) from user mode.
16866 + * Available on firmware 2.00 and higher only.
16868 + * @param module - module number to be unloaded
16869 + * @return 0 on success, < 0 on error
16870 + */
16871 +int sceUtilityUnloadAvModule(int module);
16873 +#ifdef __cplusplus
16875 +#endif
16877 +#endif
16878 diff --git a/newlib/psp/include/psputility_gamesharing.h b/newlib/psp/include/psputility_gamesharing.h
16879 new file mode 100644
16880 index 0000000..28b91fe
16881 --- /dev/null
16882 +++ b/newlib/psp/include/psputility_gamesharing.h
16883 @@ -0,0 +1,86 @@
16885 + * PSP Software Development Kit - https://github.com/pspdev
16886 + * -----------------------------------------------------------------------
16887 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16889 + * psputility_gamesharing.h - Game Sharing utility library
16891 + * Copyright (c) 2008 InsertWittyName <tias_dp@hotmail.com>
16893 + */
16894 +#ifndef __PSPUTILITY_GAMESHARING_H__
16895 +#define __PSPUTILITY_GAMESHARING_H__
16897 +#ifdef __cplusplus
16898 +extern "C" {
16899 +#endif
16901 +typedef enum
16903 + PSP_UTILITY_GAMESHARING_MODE_SINGLE = 1, /* Single send */
16904 + PSP_UTILITY_GAMESHARING_MODE_MULTIPLE = 2 /* Up to 4 simultaneous sends */
16906 +} pspUtilityGameSharingMode;
16908 +typedef enum
16910 + PSP_UTILITY_GAMESHARING_DATA_TYPE_FILE = 1, /* EBOOT is a file */
16911 + PSP_UTILITY_GAMESHARING_DATA_TYPE_MEMORY = 2, /* EBOOT is in memory */
16913 +} pspUtilityGameSharingDataType;
16915 +/**
16916 + * Structure to hold the parameters for Game Sharing
16917 +**/
16918 +typedef struct _pspUtilityGameSharingParams
16920 + pspUtilityDialogCommon base;
16921 + int unknown1; /* Set to 0 */
16922 + int unknown2; /* Set to 0 */
16923 + char name[8];
16924 + int unknown3; /* Set to 0 */
16925 + int unknown4; /* Set to 0 */
16926 + int unknown5; /* Set to 0 */
16927 + int result; /* Return value */
16928 + char *filepath; /* File path if PSP_UTILITY_GAMESHARING_DATA_TYPE_FILE specified */
16929 + pspUtilityGameSharingMode mode; /* Send mode. One of ::pspUtilityGameSharingMode */
16930 + pspUtilityGameSharingDataType datatype; /* Data type. One of ::pspUtilityGameSharingDataType */
16931 + void *data; /* Pointer to the EBOOT data in memory */
16932 + unsigned int datasize; /* Size of the EBOOT data in memory */
16934 +} pspUtilityGameSharingParams;
16936 +/**
16937 + * Init the game sharing
16939 + * @param params - game sharing parameters
16940 + * @return 0 on success, < 0 on error.
16941 + */
16942 +int sceUtilityGameSharingInitStart(pspUtilityGameSharingParams *params);
16944 +/**
16945 + * Shutdown game sharing.
16946 + */
16947 +void sceUtilityGameSharingShutdownStart(void);
16949 +/**
16950 + * Get the current status of game sharing.
16952 + * @return 2 if the GUI is visible (you need to call sceUtilityGameSharingGetStatus).
16953 + * 3 if the user cancelled the dialog, and you need to call sceUtilityGameSharingShutdownStart.
16954 + * 4 if the dialog has been successfully shut down.
16955 + */
16956 +int sceUtilityGameSharingGetStatus(void);
16958 +/**
16959 + * Refresh the GUI for game sharing
16961 + * @param n - unknown, pass 1
16962 + */
16963 +void sceUtilityGameSharingUpdate(int n);
16965 +#ifdef __cplusplus
16967 +#endif
16969 +#endif
16970 diff --git a/newlib/psp/include/psputility_htmlviewer.h b/newlib/psp/include/psputility_htmlviewer.h
16971 new file mode 100644
16972 index 0000000..5e36def
16973 --- /dev/null
16974 +++ b/newlib/psp/include/psputility_htmlviewer.h
16975 @@ -0,0 +1,192 @@
16977 + * PSP Software Development Kit - https://github.com/pspdev
16978 + * -----------------------------------------------------------------------
16979 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
16981 + * psputility_htmlviewer.h - html viewer utility library.
16983 + * Copyright (c) 2008 David Perry (InsertWittyName)
16984 + * Copyright (c) 2008 moonlight
16986 + */
16988 +#ifndef __PSPUTILITY_HTMLVIEWER_H__
16989 +#define __PSPUTILITY_HTMLVIEWER_H__
16991 +#ifdef __cplusplus
16992 +extern "C" {
16993 +#endif
16995 +enum pspUtilityHtmlViewerDisconnectModes
16997 + /** Enable automatic disconnect */
16998 + PSP_UTILITY_HTMLVIEWER_DISCONNECTMODE_ENABLE = 0,
16999 + /** Disable automatic disconnect */
17000 + PSP_UTILITY_HTMLVIEWER_DISCONNECTMODE_DISABLE,
17001 + /** Confirm disconnection */
17002 + PSP_UTILITY_HTMLVIEWER_DISCONNECTMODE_CONFIRM
17005 +enum pspUtilityHtmlViewerInterfaceModes
17007 + /** Full user interface */
17008 + PSP_UTILITY_HTMLVIEWER_INTERFACEMODE_FULL = 0,
17009 + /** Limited user interface */
17010 + PSP_UTILITY_HTMLVIEWER_INTERFACEMODE_LIMITED,
17011 + /** No user interface */
17012 + PSP_UTILITY_HTMLVIEWER_INTERFACEMODE_NONE
17015 +enum pspUtilityHtmlViewerCookieModes
17017 + /** Disable accepting cookies */
17018 + PSP_UTILITY_HTMLVIEWER_COOKIEMODE_DISABLED = 0,
17019 + /** Enable accepting cookies */
17020 + PSP_UTILITY_HTMLVIEWER_COOKIEMODE_ENABLED,
17021 + /** Confirm accepting a cookie every time */
17022 + PSP_UTILITY_HTMLVIEWER_COOKIEMODE_CONFIRM,
17023 + /** Use the system default for accepting cookies */
17024 + PSP_UTILITY_HTMLVIEWER_COOKIEMODE_DEFAULT
17027 +enum pspUtilityHtmlViewerTextSizes
17029 + /** Large text size */
17030 + PSP_UTILITY_HTMLVIEWER_TEXTSIZE_LARGE = 0,
17031 + /** Normal text size */
17032 + PSP_UTILITY_HTMLVIEWER_TEXTSIZE_NORMAL,
17033 + /** Small text size */
17034 + PSP_UTILITY_HTMLVIEWER_TEXTSIZE_SMALL
17037 +enum pspUtilityHtmlViewerDisplayModes
17039 + /** Normal display */
17040 + PSP_UTILITY_HTMLVIEWER_DISPLAYMODE_NORMAL = 0,
17041 + /** Fit display */
17042 + PSP_UTILITY_HTMLVIEWER_DISPLAYMODE_FIT,
17043 + /** Smart fit display */
17044 + PSP_UTILITY_HTMLVIEWER_DISPLAYMODE_SMART_FIT
17047 +enum pspUtilityHtmlViewerConnectModes
17049 + /** Auto connect to last used connection */
17050 + PSP_UTILITY_HTMLVIEWER_CONNECTMODE_LAST = 0,
17051 + /** Manually select the connection (once) */
17052 + PSP_UTILITY_HTMLVIEWER_CONNECTMODE_MANUAL_ONCE,
17053 + /** Manually select the connection (every time) */
17054 + PSP_UTILITY_HTMLVIEWER_CONNECTMODE_MANUAL_ALL
17057 +enum pspUtilityHtmlViewerOptions
17059 + /** Open SCE net start page */
17060 + PSP_UTILITY_HTMLVIEWER_OPEN_SCE_START_PAGE = 0x000001,
17061 + /** Disable startup limitations */
17062 + PSP_UTILITY_HTMLVIEWER_DISABLE_STARTUP_LIMITS = 0x000002,
17063 + /** Disable exit confirmation dialog */
17064 + PSP_UTILITY_HTMLVIEWER_DISABLE_EXIT_DIALOG = 0x000004,
17065 + /** Disable cursor */
17066 + PSP_UTILITY_HTMLVIEWER_DISABLE_CURSOR = 0x000008,
17067 + /** Disable download completion confirmation dialog */
17068 + PSP_UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_COMPLETE_DIALOG = 0x000010,
17069 + /** Disable download confirmation dialog */
17070 + PSP_UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_START_DIALOG = 0x000020,
17071 + /** Disable save destination confirmation dialog */
17072 + PSP_UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_DESTINATION_DIALOG = 0x000040,
17073 + /** Disable modification of the download destination */
17074 + PSP_UTILITY_HTMLVIEWER_LOCK_DOWNLOAD_DESTINATION_DIALOG = 0x000080,
17075 + /** Disable tab display */
17076 + PSP_UTILITY_HTMLVIEWER_DISABLE_TAB_DISPLAY = 0x000100,
17077 + /** Hold analog controller when HOLD button is down */
17078 + PSP_UTILITY_HTMLVIEWER_ENABLE_ANALOG_HOLD = 0x000200,
17079 + /** Enable Flash Player */
17080 + PSP_UTILITY_HTMLVIEWER_ENABLE_FLASH = 0x000400,
17081 + /** Disable L/R triggers for back/forward */
17082 + PSP_UTILITY_HTMLVIEWER_DISABLE_LRTRIGGER = 0x000800
17085 +typedef struct pspUtilityHtmlViewerParam
17087 + pspUtilityDialogCommon base;
17088 + /** Pointer to the memory pool to be used */
17089 + void* memaddr;
17090 + /** Size of the memory pool */
17091 + unsigned int memsize;
17092 + /** Unknown. Pass 0 */
17093 + int unknown1;
17094 + /** Unknown. Pass 0 */
17095 + int unknown2;
17096 + /** URL to be opened initially */
17097 + char* initialurl;
17098 + /** Number of tabs (maximum of 3) */
17099 + unsigned int numtabs;
17100 + /** One of ::pspUtilityHtmlViewerInterfaceModes */
17101 + unsigned int interfacemode;
17102 + /** Values from ::pspUtilityHtmlViewerOptions. Bitwise OR together */
17103 + unsigned int options;
17104 + /** Directory to be used for downloading */
17105 + char* dldirname;
17106 + /** Filename to be used for downloading */
17107 + char* dlfilename;
17108 + /** Directory to be used for uploading */
17109 + char* uldirname;
17110 + /** Filename to be used for uploading */
17111 + char* ulfilename;
17112 + /** One of ::pspUtilityHtmlViewerCookieModes */
17113 + unsigned int cookiemode;
17114 + /** Unknown. Pass 0 */
17115 + unsigned int unknown3;
17116 + /** URL to set the home page to */
17117 + char* homeurl;
17118 + /** One of ::pspUtilityHtmlViewerTextSizes */
17119 + unsigned int textsize;
17120 + /** One of ::pspUtilityHtmlViewerDisplayModes */
17121 + unsigned int displaymode;
17122 + /** One of ::pspUtilityHtmlViewerConnectModes */
17123 + unsigned int connectmode;
17124 + /** One of ::pspUtilityHtmlViewerDisconnectModes */
17125 + unsigned int disconnectmode;
17126 + /** The maximum amount of memory the browser used */
17127 + unsigned int memused;
17128 + /** Unknown. Pass 0 */
17129 + int unknown4[10];
17131 +} pspUtilityHtmlViewerParam;
17133 +/**
17134 + * Init the html viewer
17136 + * @param params - html viewer parameters
17138 + * @return 0 on success, < 0 on error.
17139 + */
17140 +int sceUtilityHtmlViewerInitStart(pspUtilityHtmlViewerParam *params);
17142 +/**
17143 + * Shutdown html viewer.
17144 + */
17145 +int sceUtilityHtmlViewerShutdownStart(void);
17147 +/**
17148 + * Refresh the GUI for html viewer
17150 + * @param n - unknown, pass 1
17151 + */
17152 +int sceUtilityHtmlViewerUpdate(int n);
17154 +/**
17155 + * Get the current status of the html viewer.
17157 + * @return 2 if the GUI is visible (you need to call sceUtilityHtmlViewerGetStatus).
17158 + * 3 if the user cancelled the dialog, and you need to call sceUtilityHtmlViewerShutdownStart.
17159 + * 4 if the dialog has been successfully shut down.
17160 + */
17161 +int sceUtilityHtmlViewerGetStatus(void);
17163 +#ifdef __cplusplus
17165 +#endif
17167 +#endif
17168 diff --git a/newlib/psp/include/psputility_modules.h b/newlib/psp/include/psputility_modules.h
17169 new file mode 100644
17170 index 0000000..e9824cb
17171 --- /dev/null
17172 +++ b/newlib/psp/include/psputility_modules.h
17173 @@ -0,0 +1,80 @@
17175 + * PSP Software Development Kit - https://github.com/pspdev
17176 + * -----------------------------------------------------------------------
17177 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17179 + * psputility_modules.h - Load modules from user mode
17181 + * Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
17183 + */
17184 +#ifndef __PSPUTILITY_MODULES_H__
17185 +#define __PSPUTILITY_MODULES_H__
17187 +#ifdef __cplusplus
17188 +extern "C" {
17189 +#endif
17191 +#include <psptypes.h>
17193 +/* Net Modules */
17194 +#define PSP_MODULE_NET_COMMON 0x0100
17195 +#define PSP_MODULE_NET_ADHOC 0x0101
17196 +#define PSP_MODULE_NET_INET 0x0102
17197 +#define PSP_MODULE_NET_PARSEURI 0x0103
17198 +#define PSP_MODULE_NET_PARSEHTTP 0x0104
17199 +#define PSP_MODULE_NET_HTTP 0x0105
17200 +#define PSP_MODULE_NET_SSL 0x0106
17202 +/* USB Modules */
17203 +#define PSP_MODULE_USB_PSPCM 0x0200
17204 +#define PSP_MODULE_USB_MIC 0x0201
17205 +#define PSP_MODULE_USB_CAM 0x0202
17206 +#define PSP_MODULE_USB_GPS 0x0203
17208 +/* Audio/video Modules */
17209 +#define PSP_MODULE_AV_AVCODEC 0x0300
17210 +#define PSP_MODULE_AV_SASCORE 0x0301
17211 +#define PSP_MODULE_AV_ATRAC3PLUS 0x0302
17212 +#define PSP_MODULE_AV_MPEGBASE 0x0303
17213 +#define PSP_MODULE_AV_MP3 0x0304
17214 +#define PSP_MODULE_AV_VAUDIO 0x0305
17215 +#define PSP_MODULE_AV_AAC 0x0306
17216 +#define PSP_MODULE_AV_G729 0x0307
17218 +/* NP */
17219 +#define PSP_MODULE_NP_COMMON 0x0400
17220 +#define PSP_MODULE_NP_SERVICE 0x0401
17221 +#define PSP_MODULE_NP_MATCHING2 0x0402
17223 +#define PSP_MODULE_NP_DRM 0x0500
17225 +/* IrDA */
17226 +#define PSP_MODULE_IRDA 0x0600
17228 +/** An error code used as a return value */
17229 +#define SCE_ERROR_MODULE_ALREADY_LOADED (0x80111102)
17231 +/**
17232 + * Load a module (PRX) from user mode.
17234 + * @param module - module to load (PSP_MODULE_xxx)
17236 + * @return 0 on success, < 0 on error
17237 + */
17238 +int sceUtilityLoadModule(int module);
17240 +/**
17241 + * Unload a module (PRX) from user mode.
17243 + * @param module - module to unload (PSP_MODULE_xxx)
17245 + * @return 0 on success, < 0 on error
17246 + */
17247 +int sceUtilityUnloadModule(int module);
17249 +#ifdef __cplusplus
17251 +#endif
17253 +#endif
17254 diff --git a/newlib/psp/include/psputility_msgdialog.h b/newlib/psp/include/psputility_msgdialog.h
17255 new file mode 100644
17256 index 0000000..6279572
17257 --- /dev/null
17258 +++ b/newlib/psp/include/psputility_msgdialog.h
17259 @@ -0,0 +1,101 @@
17261 + * PSP Software Development Kit - https://github.com/pspdev
17262 + * -----------------------------------------------------------------------
17263 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17265 + * psputility_msdialog.h - Definitions and Functions for Dialogs
17266 + * section of the pspUtility library
17268 + * Copyright (c) 2005 Marcus Comstedt <marcus@mc.pp.se>
17269 + * (c) 2008 InsertWittyName <tias_dp@hotmail.com>
17271 + */
17272 +#ifndef __PSPUTILITY_DIALOGS_H__
17273 +#define __PSPUTILITY_DIALOGS_H__
17275 +#ifdef __cplusplus
17276 +extern "C" {
17277 +#endif
17279 +typedef enum
17281 + PSP_UTILITY_MSGDIALOG_MODE_ERROR = 0, /* Error message */
17282 + PSP_UTILITY_MSGDIALOG_MODE_TEXT /* String message */
17284 +} pspUtilityMsgDialogMode;
17286 +typedef enum
17288 + PSP_UTILITY_MSGDIALOG_OPTION_ERROR = 0, /* Error message (why two flags?) */
17289 + PSP_UTILITY_MSGDIALOG_OPTION_TEXT = 0x00000001, /* Text message (why two flags?) */
17290 + PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS = 0x00000010, /* Yes/No buttons instead of 'Cancel' */
17291 + PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO = 0x00000100 /* Default position 'No', if not set will default to 'Yes' */
17293 +} pspUtilityMsgDialogOption;
17295 +typedef enum
17297 + PSP_UTILITY_MSGDIALOG_RESULT_UNKNOWN1 = 0,
17298 + PSP_UTILITY_MSGDIALOG_RESULT_YES,
17299 + PSP_UTILITY_MSGDIALOG_RESULT_NO,
17300 + PSP_UTILITY_MSGDIALOG_RESULT_BACK
17302 +} pspUtilityMsgDialogPressed;
17304 +/**
17305 + * Structure to hold the parameters for a message dialog
17306 +**/
17307 +typedef struct _pspUtilityMsgDialogParams
17309 + pspUtilityDialogCommon base;
17310 + int unknown;
17311 + pspUtilityMsgDialogMode mode;
17312 + unsigned int errorValue;
17313 + /** The message to display (may contain embedded linefeeds) */
17314 + char message[512];
17315 + int options; /* OR ::pspUtilityMsgDialogOption together for multiple options */
17316 + pspUtilityMsgDialogPressed buttonPressed;
17318 +} pspUtilityMsgDialogParams;
17320 +/**
17321 + * Create a message dialog
17323 + * @param params - dialog parameters
17324 + * @return 0 on success
17325 + */
17326 +int sceUtilityMsgDialogInitStart(pspUtilityMsgDialogParams *params);
17328 +/**
17329 + * Remove a message dialog currently active. After calling this
17330 + * function you need to keep calling GetStatus and Update until
17331 + * you get a status of 4.
17332 + */
17333 +void sceUtilityMsgDialogShutdownStart(void);
17335 +/**
17336 + * Get the current status of a message dialog currently active.
17338 + * @return 2 if the GUI is visible (you need to call sceUtilityMsgDialogGetStatus).
17339 + * 3 if the user cancelled the dialog, and you need to call sceUtilityMsgDialogShutdownStart.
17340 + * 4 if the dialog has been successfully shut down.
17341 + */
17342 +int sceUtilityMsgDialogGetStatus(void);
17344 +/**
17345 + * Refresh the GUI for a message dialog currently active
17347 + * @param n - unknown, pass 1
17348 + */
17349 +void sceUtilityMsgDialogUpdate(int n);
17351 +/**
17352 + * Abort a message dialog currently active
17353 + */
17354 +int sceUtilityMsgDialogAbort(void);
17356 +#ifdef __cplusplus
17358 +#endif
17360 +#endif
17361 diff --git a/newlib/psp/include/psputility_netconf.h b/newlib/psp/include/psputility_netconf.h
17362 new file mode 100644
17363 index 0000000..460f851
17364 --- /dev/null
17365 +++ b/newlib/psp/include/psputility_netconf.h
17366 @@ -0,0 +1,79 @@
17368 + * PSP Software Development Kit - https://github.com/pspdev
17369 + * -----------------------------------------------------------------------
17370 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17372 + * psputility_netconf.h - Definitions and Functions for Network Configuration
17373 + * section of the pspUtility library
17375 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
17377 + */
17378 +#ifndef __PSPUTILITY_NETCONF_H__
17379 +#define __PSPUTILITY_NETCONF_H__
17381 +#ifdef __cplusplus
17382 +extern "C" {
17383 +#endif
17385 +#include <psptypes.h>
17387 +enum pspUtilityNetconfActions
17389 + PSP_NETCONF_ACTION_CONNECTAP,
17390 + PSP_NETCONF_ACTION_DISPLAYSTATUS,
17391 + PSP_NETCONF_ACTION_CONNECT_ADHOC
17394 +struct pspUtilityNetconfAdhoc
17396 + unsigned char name[8];
17397 + unsigned int timeout;
17400 +typedef struct _pspUtilityNetconfData
17402 + pspUtilityDialogCommon base;
17403 + int action; /** One of pspUtilityNetconfActions */
17404 + struct pspUtilityNetconfAdhoc *adhocparam; //* Adhoc connection params */
17405 + int hotspot; /** Set to 1 to allow connections with the 'Internet Browser' option set to 'Start' (ie. hotspot connection) */
17406 + int hotspot_connected; /** Will be set to 1 when connected to a hotspot style connection */
17407 + int wifisp; /** Set to 1 to allow connections to Wifi service providers (WISP) */
17409 +} pspUtilityNetconfData;
17411 +/**
17412 + * Init the Network Configuration Dialog Utility
17414 + * @param data - pointer to pspUtilityNetconfData to be initialized
17415 + * @return 0 on success, < 0 on error
17416 + */
17417 +int sceUtilityNetconfInitStart (pspUtilityNetconfData *data);
17419 +/**
17420 + * Shutdown the Network Configuration Dialog Utility
17422 + * @return 0 on success, < 0 on error
17423 + */
17424 +int sceUtilityNetconfShutdownStart (void);
17426 +/**
17427 + * Update the Network Configuration Dialog GUI
17428 + *
17429 + * @param unknown - unknown; set to 1
17430 + * @return 0 on success, < 0 on error
17431 + */
17432 +int sceUtilityNetconfUpdate (int unknown);
17434 +/**
17435 + * Get the status of a running Network Configuration Dialog
17437 + * @return one of pspUtilityDialogState on success, < 0 on error
17438 + */
17439 +int sceUtilityNetconfGetStatus (void);
17441 +#ifdef __cplusplus
17443 +#endif
17445 +#endif
17446 diff --git a/newlib/psp/include/psputility_netmodules.h b/newlib/psp/include/psputility_netmodules.h
17447 new file mode 100644
17448 index 0000000..4135699
17449 --- /dev/null
17450 +++ b/newlib/psp/include/psputility_netmodules.h
17451 @@ -0,0 +1,55 @@
17453 + * PSP Software Development Kit - https://github.com/pspdev
17454 + * -----------------------------------------------------------------------
17455 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17457 + * psputility_netmodules.h - Load network modules from user mode on 2.xx+
17459 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
17461 + */
17462 +#ifndef __PSPUTILITY_NETMODULES_H__
17463 +#define __PSPUTILITY_NETMODULES_H__
17465 +#ifdef __cplusplus
17466 +extern "C" {
17467 +#endif
17469 +#include <psptypes.h>
17471 +#define PSP_NET_MODULE_COMMON 1
17472 +#define PSP_NET_MODULE_ADHOC 2
17473 +#define PSP_NET_MODULE_INET 3
17474 +#define PSP_NET_MODULE_PARSEURI 4
17475 +#define PSP_NET_MODULE_PARSEHTTP 5
17476 +#define PSP_NET_MODULE_HTTP 6
17477 +#define PSP_NET_MODULE_SSL 7
17479 +/** An error code used as a return value */
17480 +#define SCE_ERROR_NET_MODULE_NOT_LOADED (0x80110803)
17482 +/**
17483 + * Load a network module (PRX) from user mode.
17484 + * Load PSP_NET_MODULE_COMMON and PSP_NET_MODULE_INET
17485 + * to use infrastructure WifI (via an access point).
17486 + * Available on firmware 2.00 and higher only.
17488 + * @param module - module number to load (PSP_NET_MODULE_xxx)
17489 + * @return 0 on success, < 0 on error
17490 + */
17491 +int sceUtilityLoadNetModule(int module);
17493 +/**
17494 + * Unload a network module (PRX) from user mode.
17495 + * Available on firmware 2.00 and higher only.
17497 + * @param module - module number be unloaded
17498 + * @return 0 on success, < 0 on error
17499 + */
17500 +int sceUtilityUnloadNetModule(int module);
17502 +#ifdef __cplusplus
17504 +#endif
17506 +#endif
17507 diff --git a/newlib/psp/include/psputility_netparam.h b/newlib/psp/include/psputility_netparam.h
17508 new file mode 100644
17509 index 0000000..d45405b
17510 --- /dev/null
17511 +++ b/newlib/psp/include/psputility_netparam.h
17512 @@ -0,0 +1,116 @@
17514 + * PSP Software Development Kit - https://github.com/pspdev
17515 + * -----------------------------------------------------------------------
17516 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17518 + * psputility_netparam.h - Definitions and Functions to manage Network
17519 + * parameters.
17521 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
17523 + */
17524 +#ifndef __PSPUTILITY_NETPARAM_H__
17525 +#define __PSPUTILITY_NETPARAM_H__
17527 +#ifdef __cplusplus
17528 +extern "C" {
17529 +#endif
17531 +#include <psptypes.h>
17533 +/**
17534 + * Datatype for sceUtilityGetNetParam
17535 + * since it can return a u32 or a string
17536 + * we use a union to avoid ugly casting
17537 + */
17538 +typedef union {
17539 + u32 asUint;
17540 + char asString[128];
17541 +} netData;
17543 +#define PSP_NETPARAM_NAME 0 // string
17544 +#define PSP_NETPARAM_SSID 1 // string
17545 +#define PSP_NETPARAM_SECURE 2 // int
17546 +#define PSP_NETPARAM_WEPKEY 3 // string
17547 +#define PSP_NETPARAM_IS_STATIC_IP 4 // int
17548 +#define PSP_NETPARAM_IP 5 // string
17549 +#define PSP_NETPARAM_NETMASK 6 // string
17550 +#define PSP_NETPARAM_ROUTE 7 // string
17551 +#define PSP_NETPARAM_MANUAL_DNS 8 // int
17552 +#define PSP_NETPARAM_PRIMARYDNS 9 // string
17553 +#define PSP_NETPARAM_SECONDARYDNS 10 // string
17554 +#define PSP_NETPARAM_PROXY_USER 11 // string
17555 +#define PSP_NETPARAM_PROXY_PASS 12 // string
17556 +#define PSP_NETPARAM_USE_PROXY 13 // int
17557 +#define PSP_NETPARAM_PROXY_SERVER 14 // string
17558 +#define PSP_NETPARAM_PROXY_PORT 15 // int
17559 +#define PSP_NETPARAM_UNKNOWN1 16 // int
17560 +#define PSP_NETPARAM_UNKNOWN2 17 // int
17562 +#define PSP_NETPARAM_ERROR_BAD_NETCONF 0x80110601
17563 +#define PSP_NETPARAM_ERROR_BAD_PARAM 0x80110604
17565 +/**
17566 + * Check existance of a Net Configuration
17568 + * @param id - id of net Configuration (1 to n)
17569 + * @return 0 on success,
17570 + */
17571 +int sceUtilityCheckNetParam(int id);
17573 +/**
17574 + * Get Net Configuration Parameter
17576 + * @param conf - Net Configuration number (1 to n)
17577 + * (0 returns valid but seems to be a copy of the last config requested)
17578 + * @param param - which parameter to get
17579 + * @param data - parameter data
17580 + * @return 0 on success,
17581 + */
17582 +int sceUtilityGetNetParam(int conf, int param, netData *data);
17584 +/**
17585 + * Create a new Network Configuration
17586 + * @note This creates a new configuration at conf and clears 0
17588 + * @param conf - Net Configuration number (1 to n)
17590 + * @return 0 on success
17591 + */
17592 +int sceUtilityCreateNetParam(int conf);
17594 +/**
17595 + * Sets a network parameter
17596 + * @note This sets only to configuration 0
17598 + * @param param - Which parameter to set
17599 + * @param val - Pointer to the the data to set
17601 + * @return 0 on success
17602 + */
17603 +int sceUtilitySetNetParam(int param, const void *val);
17605 +/**
17606 + * Copies a Network Configuration to another
17608 + * @param src - Source Net Configuration number (0 to n)
17609 + * @param dest - Destination Net Configuration number (0 to n)
17611 + * @return 0 on success
17612 + */
17613 +int sceUtilityCopyNetParam(int src, int dest);
17615 +/**
17616 + * Deletes a Network Configuration
17618 + * @param conf - Net Configuration number (1 to n)
17620 + * @return 0 on success
17621 + */
17622 +int sceUtilityDeleteNetParam(int conf);
17624 +#ifdef __cplusplus
17626 +#endif
17628 +#endif
17629 diff --git a/newlib/psp/include/psputility_osk.h b/newlib/psp/include/psputility_osk.h
17630 new file mode 100644
17631 index 0000000..7a6e6e3
17632 --- /dev/null
17633 +++ b/newlib/psp/include/psputility_osk.h
17634 @@ -0,0 +1,180 @@
17636 + * PSP Software Development Kit - https://github.com/pspdev
17637 + * -----------------------------------------------------------------------
17638 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17640 + * psputility_osk.h - Definitions and Functions for OSK section of
17641 + * the pspUtility library
17643 + * Copyright (c) 2006 McZonk
17644 + * Copyright (c) 2008 InsertWittyName <tias_dp@hotmail.com>
17646 + */
17647 +#ifndef PSPOSK_H
17648 +#define PSPOSK_H
17650 +#ifdef __cplusplus
17651 +extern "C" {
17652 +#endif
17654 +#include <psptypes.h>
17656 +/**
17657 + * Enumeration for input language
17658 + */
17659 +enum SceUtilityOskInputLanguage
17661 + PSP_UTILITY_OSK_LANGUAGE_DEFAULT = 0x00,
17662 + PSP_UTILITY_OSK_LANGUAGE_JAPANESE = 0x01,
17663 + PSP_UTILITY_OSK_LANGUAGE_ENGLISH = 0x02,
17664 + PSP_UTILITY_OSK_LANGUAGE_FRENCH = 0x03,
17665 + PSP_UTILITY_OSK_LANGUAGE_SPANISH = 0x04,
17666 + PSP_UTILITY_OSK_LANGUAGE_GERMAN = 0x05,
17667 + PSP_UTILITY_OSK_LANGUAGE_ITALIAN = 0x06,
17668 + PSP_UTILITY_OSK_LANGUAGE_DUTCH = 0x07,
17669 + PSP_UTILITY_OSK_LANGUAGE_PORTUGESE = 0x08,
17670 + PSP_UTILITY_OSK_LANGUAGE_RUSSIAN = 0x09,
17671 + PSP_UTILITY_OSK_LANGUAGE_KOREAN = 0x0a
17674 +/**
17675 + * Enumeration for OSK internal state
17676 + */
17677 +enum SceUtilityOskState
17679 + PSP_UTILITY_OSK_DIALOG_NONE = 0, /**< No OSK is currently active */
17680 + PSP_UTILITY_OSK_DIALOG_INITING, /**< The OSK is currently being initialized */
17681 + PSP_UTILITY_OSK_DIALOG_INITED, /**< The OSK is initialised */
17682 + PSP_UTILITY_OSK_DIALOG_VISIBLE, /**< The OSK is visible and ready for use */
17683 + PSP_UTILITY_OSK_DIALOG_QUIT, /**< The OSK has been cancelled and should be shut down */
17684 + PSP_UTILITY_OSK_DIALOG_FINISHED /**< The OSK has successfully shut down */
17687 +/**
17688 + * Enumeration for OSK field results
17689 + */
17690 +enum SceUtilityOskResult
17692 + PSP_UTILITY_OSK_RESULT_UNCHANGED = 0,
17693 + PSP_UTILITY_OSK_RESULT_CANCELLED,
17694 + PSP_UTILITY_OSK_RESULT_CHANGED
17697 +/**
17698 + * Enumeration for input types (these are limited by initial choice of language)
17699 + */
17700 +enum SceUtilityOskInputType
17702 + PSP_UTILITY_OSK_INPUTTYPE_ALL = 0x00000000,
17703 + PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT = 0x00000001,
17704 + PSP_UTILITY_OSK_INPUTTYPE_LATIN_SYMBOL = 0x00000002,
17705 + PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE = 0x00000004,
17706 + PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE = 0x00000008,
17707 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_DIGIT = 0x00000100,
17708 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_SYMBOL = 0x00000200,
17709 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_LOWERCASE = 0x00000400,
17710 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_UPPERCASE = 0x00000800,
17711 + // http://en.wikipedia.org/wiki/Hiragana
17712 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HIRAGANA = 0x00001000,
17713 + // http://en.wikipedia.org/wiki/Katakana
17714 + // Half-width Katakana
17715 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_HALF_KATAKANA = 0x00002000,
17716 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KATAKANA = 0x00004000,
17717 + // http://en.wikipedia.org/wiki/Kanji
17718 + PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_KANJI = 0x00008000,
17719 + PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_LOWERCASE = 0x00010000,
17720 + PSP_UTILITY_OSK_INPUTTYPE_RUSSIAN_UPPERCASE = 0x00020000,
17721 + PSP_UTILITY_OSK_INPUTTYPE_KOREAN = 0x00040000,
17722 + PSP_UTILITY_OSK_INPUTTYPE_URL = 0x00080000
17725 +/**
17726 + * OSK Field data
17727 + */
17728 +typedef struct _SceUtilityOskData
17730 + /** Unknown. Pass 0. */
17731 + int unk_00;
17732 + /** Unknown. Pass 0. */
17733 + int unk_04;
17734 + /** One of ::SceUtilityOskInputLanguage */
17735 + int language;
17736 + /** Unknown. Pass 0. */
17737 + int unk_12;
17738 + /** One or more of ::SceUtilityOskInputType (types that are selectable by pressing SELECT) */
17739 + int inputtype;
17740 + /** Number of lines */
17741 + int lines;
17742 + /** Unknown. Pass 0. */
17743 + int unk_24;
17744 + /** Description text */
17745 + unsigned short* desc;
17746 + /** Initial text */
17747 + unsigned short* intext;
17748 + /** Length of output text */
17749 + int outtextlength;
17750 + /** Pointer to the output text */
17751 + unsigned short* outtext;
17752 + /** Result. One of ::SceUtilityOskResult */
17753 + int result;
17754 + /** The max text that can be input */
17755 + int outtextlimit;
17757 +} SceUtilityOskData;
17759 +/**
17760 + * OSK parameters
17761 + */
17762 +typedef struct _SceUtilityOskParams
17764 + pspUtilityDialogCommon base;
17765 + /** Number of input fields */
17766 + int datacount;
17767 + /** Pointer to the start of the data for the input fields */
17768 + SceUtilityOskData* data;
17769 + /** The local OSK state, one of ::SceUtilityOskState */
17770 + int state;
17771 + /** Unknown. Pass 0 */
17772 + int unk_60;
17774 +} SceUtilityOskParams;
17776 +/**
17777 + * Create an on-screen keyboard
17779 + * @param params - OSK parameters.
17781 + * @return < 0 on error.
17782 + */
17783 +int sceUtilityOskInitStart(SceUtilityOskParams* params);
17785 +/**
17786 + * Remove a currently active keyboard. After calling this function you must
17788 + * poll sceUtilityOskGetStatus() until it returns PSP_UTILITY_DIALOG_NONE.
17790 + * @return < 0 on error.
17791 + */
17792 +int sceUtilityOskShutdownStart(void);
17794 +/**
17795 + * Refresh the GUI for a keyboard currently active
17797 + * @param n - Unknown, pass 1.
17799 + * @return < 0 on error.
17800 + */
17801 +int sceUtilityOskUpdate(int n);
17803 +/**
17804 + * Get the status of a on-screen keyboard currently active.
17806 + * @return the current status of the keyboard. See ::pspUtilityDialogState for details.
17807 + */
17808 +int sceUtilityOskGetStatus(void);
17810 +#ifdef __cplusplus
17812 +#endif
17814 +#endif
17815 diff --git a/newlib/psp/include/psputility_savedata.h b/newlib/psp/include/psputility_savedata.h
17816 new file mode 100644
17817 index 0000000..3d4ff03
17818 --- /dev/null
17819 +++ b/newlib/psp/include/psputility_savedata.h
17820 @@ -0,0 +1,182 @@
17822 + * PSP Software Development Kit - https://github.com/pspdev
17823 + * -----------------------------------------------------------------------
17824 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
17826 + * psputility_savedata.h - Definitions and Functions for savedata part of
17827 + * pspUtility library
17829 + * Copyright (c) 2005 Shine
17830 + * weltall <weltall@consoleworld.org>
17831 + * Marcus R. Brown <mrbrown@ocgnet.org>
17832 + * InsertWittyName <tias_dp@hotmail.com>
17834 + */
17836 +#ifndef __PSPUTILITY_SAVEDATA_H__
17837 +#define __PSPUTILITY_SAVEDATA_H__
17839 +#include <psptypes.h>
17841 +#ifdef __cplusplus
17842 +extern "C" {
17843 +#endif
17845 +/** Save data utility modes */
17846 +typedef enum
17848 + PSP_UTILITY_SAVEDATA_AUTOLOAD = 0,
17849 + PSP_UTILITY_SAVEDATA_AUTOSAVE,
17850 + PSP_UTILITY_SAVEDATA_LOAD,
17851 + PSP_UTILITY_SAVEDATA_SAVE,
17852 + PSP_UTILITY_SAVEDATA_LISTLOAD,
17853 + PSP_UTILITY_SAVEDATA_LISTSAVE,
17854 + PSP_UTILITY_SAVEDATA_LISTDELETE,
17855 + PSP_UTILITY_SAVEDATADELETE,
17857 +} PspUtilitySavedataMode;
17859 +/** Initial focus position for list selection types */
17860 +typedef enum
17862 + PSP_UTILITY_SAVEDATA_FOCUS_UNKNOWN = 0,
17863 + PSP_UTILITY_SAVEDATA_FOCUS_FIRSTLIST, /* First in list */
17864 + PSP_UTILITY_SAVEDATA_FOCUS_LASTLIST, /* Last in list */
17865 + PSP_UTILITY_SAVEDATA_FOCUS_LATEST, /* Most recent date */
17866 + PSP_UTILITY_SAVEDATA_FOCUS_OLDEST, /* Oldest date */
17867 + PSP_UTILITY_SAVEDATA_FOCUS_UNKNOWN2,
17868 + PSP_UTILITY_SAVEDATA_FOCUS_UNKNOWN3,
17869 + PSP_UTILITY_SAVEDATA_FOCUS_FIRSTEMPTY, /* First empty slot */
17870 + PSP_UTILITY_SAVEDATA_FOCUS_LASTEMPTY, /*Last empty slot */
17872 +} PspUtilitySavedataFocus;
17875 +/** title, savedataTitle, detail: parts of the unencrypted SFO
17876 + data, it contains what the VSH and standard load screen shows */
17877 +typedef struct PspUtilitySavedataSFOParam
17879 + char title[0x80];
17880 + char savedataTitle[0x80];
17881 + char detail[0x400];
17882 + unsigned char parentalLevel;
17883 + unsigned char unknown[3];
17885 +} PspUtilitySavedataSFOParam;
17887 +typedef struct PspUtilitySavedataFileData {
17888 + void *buf;
17889 + SceSize bufSize;
17890 + SceSize size; /* ??? - why are there two sizes? */
17891 + int unknown;
17893 +} PspUtilitySavedataFileData;
17895 +typedef struct PspUtilitySavedataListSaveNewData
17897 + PspUtilitySavedataFileData icon0;
17898 + char *title;
17900 +} PspUtilitySavedataListSaveNewData;
17902 +/** Structure to hold the parameters for the ::sceUtilitySavedataInitStart function. */
17903 +typedef struct SceUtilitySavedataParam
17905 + pspUtilityDialogCommon base;
17907 + PspUtilitySavedataMode mode;
17909 + int unknown1;
17911 + int overwrite;
17913 + /** gameName: name used from the game for saves, equal for all saves */
17914 + char gameName[13];
17915 + char reserved[3];
17916 + /** saveName: name of the particular save, normally a number */
17917 + char saveName[20];
17919 + /** saveNameList: used by multiple modes */
17920 + char (*saveNameList)[20];
17922 + /** fileName: name of the data file of the game for example DATA.BIN */
17923 + char fileName[13];
17924 + char reserved1[3];
17926 + /** pointer to a buffer that will contain data file unencrypted data */
17927 + void *dataBuf;
17928 + /** size of allocated space to dataBuf */
17929 + SceSize dataBufSize;
17930 + SceSize dataSize;
17932 + PspUtilitySavedataSFOParam sfoParam;
17934 + PspUtilitySavedataFileData icon0FileData;
17935 + PspUtilitySavedataFileData icon1FileData;
17936 + PspUtilitySavedataFileData pic1FileData;
17937 + PspUtilitySavedataFileData snd0FileData;
17939 + /** Pointer to an PspUtilitySavedataListSaveNewData structure */
17940 + PspUtilitySavedataListSaveNewData *newData;
17942 + /** Initial focus for lists */
17943 + PspUtilitySavedataFocus focus;
17945 + /** unknown2: ? */
17946 + int unknown2[4];
17948 +#if _PSP_FW_VERSION >= 200
17950 + /** key: encrypt/decrypt key for save with firmware >= 2.00 */
17951 + char key[16];
17953 + /** unknown3: ? */
17954 + char unknown3[20];
17956 +#endif
17958 +} SceUtilitySavedataParam;
17961 +/**
17962 + * Saves or Load savedata to/from the passed structure
17963 + * After having called this continue calling sceUtilitySavedataGetStatus to
17964 + * check if the operation is completed
17966 + * @param params - savedata parameters
17967 + * @return 0 on success
17968 + */
17969 +int sceUtilitySavedataInitStart(SceUtilitySavedataParam * params);
17971 +/**
17972 + * Check the current status of the saving/loading/shutdown process
17973 + * Continue calling this to check current status of the process
17974 + * before calling this call also sceUtilitySavedataUpdate
17975 + * @return 2 if the process is still being processed.
17976 + * 3 on save/load success, then you can call sceUtilitySavedataShutdownStart.
17977 + * 4 on complete shutdown.
17978 + */
17979 +int sceUtilitySavedataGetStatus(void);
17982 +/**
17983 + * Shutdown the savedata utility. after calling this continue calling
17984 + * ::sceUtilitySavedataGetStatus to check when it has shutdown
17986 + * @return 0 on success
17988 + */
17989 +int sceUtilitySavedataShutdownStart(void);
17991 +/**
17992 + * Refresh status of the savedata function
17994 + * @param unknown - unknown, pass 1
17995 + */
17996 +void sceUtilitySavedataUpdate(int unknown);
17998 +#ifdef __cplusplus
18000 +#endif
18002 +#endif
18003 diff --git a/newlib/psp/include/psputility_sysparam.h b/newlib/psp/include/psputility_sysparam.h
18004 new file mode 100644
18005 index 0000000..84f2465
18006 --- /dev/null
18007 +++ b/newlib/psp/include/psputility_sysparam.h
18008 @@ -0,0 +1,140 @@
18010 + * PSP Software Development Kit - https://github.com/pspdev
18011 + * -----------------------------------------------------------------------
18012 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18014 + * psputility_sysparam.h - Definitions and Functions for System Paramters
18015 + * section of the pspUtility library
18017 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
18019 + */
18020 +#ifndef __PSPUTILITY_SYSPARAM_H__
18021 +#define __PSPUTILITY_SYSPARAM_H__
18023 +#ifdef __cplusplus
18024 +extern "C" {
18025 +#endif
18027 +#include <psptypes.h>
18029 +/**
18030 + * IDs for use inSystemParam functions
18031 + * PSP_SYSTEMPARAM_ID_INT are for use with SystemParamInt funcs
18032 + * PSP_SYSTEMPARAM_ID_STRING are for use with SystemParamString funcs
18033 + */
18034 +#define PSP_SYSTEMPARAM_ID_STRING_NICKNAME 1
18035 +#define PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL 2
18036 +#define PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE 3
18037 +#define PSP_SYSTEMPARAM_ID_INT_DATE_FORMAT 4
18038 +#define PSP_SYSTEMPARAM_ID_INT_TIME_FORMAT 5
18039 +//Timezone offset from UTC in minutes, (EST = -300 = -5 * 60)
18040 +#define PSP_SYSTEMPARAM_ID_INT_TIMEZONE 6
18041 +#define PSP_SYSTEMPARAM_ID_INT_DAYLIGHTSAVINGS 7
18042 +#define PSP_SYSTEMPARAM_ID_INT_LANGUAGE 8
18043 +/**
18044 + * #9 seems to be Region or maybe X/O button swap.
18045 + * It doesn't exist on JAP v1.0
18046 + * is 1 on NA v1.5s
18047 + * is 0 on JAP v1.5s
18048 + * is read-only
18049 + */
18050 +#define PSP_SYSTEMPARAM_ID_INT_UNKNOWN 9
18052 +/**
18053 + * Return values for the SystemParam functions
18054 + */
18055 +#define PSP_SYSTEMPARAM_RETVAL_OK 0
18056 +#define PSP_SYSTEMPARAM_RETVAL_FAIL 0x80110103
18058 +/**
18059 + * Valid values for PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL
18060 + */
18061 +#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC 0
18062 +#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_1 1
18063 +#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_6 6
18064 +#define PSP_SYSTEMPARAM_ADHOC_CHANNEL_11 11
18066 +/**
18067 + * Valid values for PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE
18068 + */
18069 +#define PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF 0
18070 +#define PSP_SYSTEMPARAM_WLAN_POWERSAVE_ON 1
18072 +/**
18073 + * Valid values for PSP_SYSTEMPARAM_ID_INT_DATE_FORMAT
18074 + */
18075 +#define PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD 0
18076 +#define PSP_SYSTEMPARAM_DATE_FORMAT_MMDDYYYY 1
18077 +#define PSP_SYSTEMPARAM_DATE_FORMAT_DDMMYYYY 2
18079 +/**
18080 + * Valid values for PSP_SYSTEMPARAM_ID_INT_TIME_FORMAT
18081 + */
18082 +#define PSP_SYSTEMPARAM_TIME_FORMAT_24HR 0
18083 +#define PSP_SYSTEMPARAM_TIME_FORMAT_12HR 1
18085 +/**
18086 + * Valid values for PSP_SYSTEMPARAM_ID_INT_DAYLIGHTSAVINGS
18087 + */
18088 +#define PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD 0
18089 +#define PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_SAVING 1
18091 +/**
18092 + * Valid values for PSP_SYSTEMPARAM_ID_INT_LANGUAGE
18093 + */
18094 +#define PSP_SYSTEMPARAM_LANGUAGE_JAPANESE 0
18095 +#define PSP_SYSTEMPARAM_LANGUAGE_ENGLISH 1
18096 +#define PSP_SYSTEMPARAM_LANGUAGE_FRENCH 2
18097 +#define PSP_SYSTEMPARAM_LANGUAGE_SPANISH 3
18098 +#define PSP_SYSTEMPARAM_LANGUAGE_GERMAN 4
18099 +#define PSP_SYSTEMPARAM_LANGUAGE_ITALIAN 5
18100 +#define PSP_SYSTEMPARAM_LANGUAGE_DUTCH 6
18101 +#define PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE 7
18102 +#define PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN 8
18103 +#define PSP_SYSTEMPARAM_LANGUAGE_KOREAN 9
18104 +#define PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL 10
18105 +#define PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED 11
18107 +/**
18108 + * Set Integer System Parameter
18110 + * @param id - which parameter to set
18111 + * @param value - integer value to set
18112 + * @return 0 on success, PSP_SYSTEMPARAM_RETVAL_FAIL on failure
18113 + */
18114 +int sceUtilitySetSystemParamInt(int id, int value);
18116 +/**
18117 + * Set String System Parameter
18119 + * @param id - which parameter to set
18120 + * @param str - char * value to set
18121 + * @return 0 on success, PSP_SYSTEMPARAM_RETVAL_FAIL on failure
18122 + */
18123 +int sceUtilitySetSystemParamString(int id, const char *str);
18125 +/**
18126 + * Get Integer System Parameter
18128 + * @param id - which parameter to get
18129 + * @param value - pointer to integer value to place result in
18130 + * @return 0 on success, PSP_SYSTEMPARAM_RETVAL_FAIL on failure
18131 + */
18132 +int sceUtilityGetSystemParamInt( int id, int *value );
18134 +/**
18135 + * Get String System Parameter
18137 + * @param id - which parameter to get
18138 + * @param str - char * buffer to place result in
18139 + * @param len - length of str buffer
18140 + * @return 0 on success, PSP_SYSTEMPARAM_RETVAL_FAIL on failure
18141 + */
18142 +int sceUtilityGetSystemParamString(int id, char *str, int len);
18144 +#ifdef __cplusplus
18146 +#endif
18148 +#endif
18149 diff --git a/newlib/psp/include/psputility_usbmodules.h b/newlib/psp/include/psputility_usbmodules.h
18150 new file mode 100644
18151 index 0000000..cae5aaf
18152 --- /dev/null
18153 +++ b/newlib/psp/include/psputility_usbmodules.h
18154 @@ -0,0 +1,48 @@
18156 + * PSP Software Development Kit - https://github.com/pspdev
18157 + * -----------------------------------------------------------------------
18158 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18160 + * psputility_usbmodules.h - Load usb modules from user mode on 2.70 and higher
18162 + * Copyright (c) 2007 David Perry <tias_dp@hotmail.com>
18164 + */
18165 +#ifndef __PSPUTILITY_USBMODULES_H__
18166 +#define __PSPUTILITY_USBMODULES_H__
18168 +#ifdef __cplusplus
18169 +extern "C" {
18170 +#endif
18172 +#include <psptypes.h>
18174 +#define PSP_USB_MODULE_PSPCM 1
18175 +#define PSP_USB_MODULE_ACC 2
18176 +#define PSP_USB_MODULE_MIC 3 // Requires PSP_USB_MODULE_ACC loading first
18177 +#define PSP_USB_MODULE_CAM 4 // Requires PSP_USB_MODULE_ACC loading first
18178 +#define PSP_USB_MODULE_GPS 5 // Requires PSP_USB_MODULE_ACC loading first
18180 +/**
18181 + * Load a usb module (PRX) from user mode.
18182 + * Available on firmware 2.70 and higher only.
18184 + * @param module - module number to load (PSP_USB_MODULE_xxx)
18185 + * @return 0 on success, < 0 on error
18187 +int sceUtilityLoadUsbModule(int module);
18189 +/**
18190 + * Unload a usb module (PRX) from user mode.
18191 + * Available on firmware 2.70 and higher only.
18193 + * @param module - module number to be unloaded
18194 + * @return 0 on success, < 0 on error
18196 +int sceUtilityUnloadUsbModule(int module);
18198 +#ifdef __cplusplus
18200 +#endif
18202 +#endif
18203 diff --git a/newlib/psp/include/psputils.h b/newlib/psp/include/psputils.h
18204 new file mode 100644
18205 index 0000000..3f77f33
18206 --- /dev/null
18207 +++ b/newlib/psp/include/psputils.h
18208 @@ -0,0 +1,248 @@
18210 + * PSP Software Development Kit - https://github.com/pspdev
18211 + * -----------------------------------------------------------------------
18212 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18214 + * psputils.h - Prototypes for the sceUtils library.
18216 + * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
18217 + * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
18218 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
18220 + */
18221 +#ifndef __UTILS_H__
18222 +#define __UTILS_H__
18224 +#include <psptypes.h>
18226 +#ifdef __cplusplus
18227 +extern "C" {
18228 +#endif
18230 +/* Some of the structures and definitions in this file were extracted from the japanese
18231 + puzzle bobble main executable */
18233 +/** @defgroup Utils Utils Library */
18235 +/** @addtogroup Utils */
18237 +/**@{*/
18239 +#include <sys/time.h>
18241 +/**
18242 + * This struct is needed because tv_sec size is different from what newlib expect
18243 + * Newlib expects 64bits for seconds and PSP expects 32bits
18244 + */
18245 +typedef struct SceKernelTimeval {
18246 + uint32_t tv_sec;
18247 + uint32_t tv_usec;
18248 +} SceKernelTimeval;
18250 +/**
18251 + * Get the time in seconds since the epoc (1st Jan 1970)
18253 + */
18254 +time_t sceKernelLibcTime(time_t *t);
18256 +/**
18257 + * Get the processor clock used since the start of the process
18258 + */
18259 +clock_t sceKernelLibcClock(void);
18261 +/**
18262 + * Get the current time of time and time zone information
18263 + */
18264 +int sceKernelLibcGettimeofday(struct SceKernelTimeval *tp, struct timezone *tzp);
18266 +/**
18267 + * Write back the data cache to memory
18268 + */
18269 +void sceKernelDcacheWritebackAll(void);
18271 +/**
18272 + * Write back and invalidate the data cache
18273 + */
18274 +void sceKernelDcacheWritebackInvalidateAll(void);
18276 +/**
18277 + * Write back a range of addresses from the data cache to memory
18278 + */
18279 +void sceKernelDcacheWritebackRange(const void *p, unsigned int size);
18281 +/**
18282 + * Write back and invalidate a range of addresses in the data cache
18283 + */
18284 +void sceKernelDcacheWritebackInvalidateRange(const void *p, unsigned int size);
18286 +/**
18287 + * Invalidate a range of addresses in data cache
18288 + */
18289 +void sceKernelDcacheInvalidateRange(const void *p, unsigned int size);
18291 +/**
18292 + * Invalidate the instruction cache
18293 + */
18294 +void sceKernelIcacheInvalidateAll(void);
18296 +/**
18297 + * Invalidate a range of addresses in the instruction cache
18298 + */
18299 +void sceKernelIcacheInvalidateRange(const void *p, unsigned int size);
18301 +/** Structure for holding a mersenne twister context */
18302 +typedef struct _SceKernelUtilsMt19937Context {
18303 + unsigned int count;
18304 + unsigned int state[624];
18305 +} SceKernelUtilsMt19937Context;
18307 +/**
18308 + * Function to initialise a mersenne twister context.
18310 + * @param ctx - Pointer to a context
18311 + * @param seed - A seed for the random function.
18313 + * @par Example:
18314 + * @code
18315 + * SceKernelUtilsMt19937Context ctx;
18316 + * sceKernelUtilsMt19937Init(&ctx, time(NULL));
18317 + * u23 rand_val = sceKernelUtilsMt19937UInt(&ctx);
18318 + * @endcode
18320 + * @return < 0 on error.
18321 + */
18322 +int sceKernelUtilsMt19937Init(SceKernelUtilsMt19937Context *ctx, u32 seed);
18324 +/**
18325 + * Function to return a new psuedo random number.
18327 + * @param ctx - Pointer to a pre-initialised context.
18328 + * @return A pseudo random number (between 0 and MAX_INT).
18329 + */
18330 +u32 sceKernelUtilsMt19937UInt(SceKernelUtilsMt19937Context *ctx);
18332 +/** Structure to hold the MD5 context */
18333 +typedef struct _SceKernelUtilsMd5Context {
18334 + unsigned int h[4];
18335 + unsigned int pad;
18336 + SceUShort16 usRemains;
18337 + SceUShort16 usComputed;
18338 + SceULong64 ullTotalLen;
18339 + unsigned char buf[64];
18340 +} SceKernelUtilsMd5Context;
18342 +/**
18343 + * Function to perform an MD5 digest of a data block.
18345 + * @param data - Pointer to a data block to make a digest of.
18346 + * @param size - Size of the data block.
18347 + * @param digest - Pointer to a 16byte buffer to store the resulting digest
18349 + * @return < 0 on error.
18350 + */
18351 +int sceKernelUtilsMd5Digest(u8 *data, u32 size, u8 *digest);
18353 +/**
18354 + * Function to initialise a MD5 digest context
18356 + * @param ctx - A context block to initialise
18358 + * @return < 0 on error.
18359 + * @par Example:
18360 + * @code
18361 + * SceKernelUtilsMd5Context ctx;
18362 + * u8 digest[16];
18363 + * sceKernelUtilsMd5BlockInit(&ctx);
18364 + * sceKernelUtilsMd5BlockUpdate(&ctx, (u8*) "Hello", 5);
18365 + * sceKernelUtilsMd5BlockResult(&ctx, digest);
18366 + * @endcode
18367 + */
18368 +int sceKernelUtilsMd5BlockInit(SceKernelUtilsMd5Context *ctx);
18370 +/**
18371 + * Function to update the MD5 digest with a block of data.
18373 + * @param ctx - A filled in context block.
18374 + * @param data - The data block to hash.
18375 + * @param size - The size of the data to hash
18377 + * @return < 0 on error.
18378 + */
18379 +int sceKernelUtilsMd5BlockUpdate(SceKernelUtilsMd5Context *ctx, u8 *data, u32 size);
18381 +/**
18382 + * Function to get the digest result of the MD5 hash.
18384 + * @param ctx - A filled in context block.
18385 + * @param digest - A 16 byte array to hold the digest.
18387 + * @return < 0 on error.
18388 + */
18389 +int sceKernelUtilsMd5BlockResult(SceKernelUtilsMd5Context *ctx, u8 *digest);
18391 +/** Type to hold a sha1 context */
18392 +typedef struct _SceKernelUtilsSha1Context {
18393 + unsigned int h[5];
18394 + SceUShort16 usRemains;
18395 + SceUShort16 usComputed;
18396 + SceULong64 ullTotalLen;
18397 + unsigned char buf[64];
18398 +} SceKernelUtilsSha1Context;
18400 +/**
18401 + * Function to SHA1 hash a data block.
18403 + * @param data - The data to hash.
18404 + * @param size - The size of the data.
18405 + * @param digest - Pointer to a 20 byte array for storing the digest
18407 + * @return < 0 on error.
18408 + */
18409 +int sceKernelUtilsSha1Digest(u8 *data, u32 size, u8 *digest);
18411 +/**
18412 + * Function to initialise a context for SHA1 hashing.
18414 + * @param ctx - Pointer to a context.
18416 + * @return < 0 on error.
18418 + * @par Example:
18419 + * @code
18420 + * SceKernelUtilsSha1Context ctx;
18421 + * u8 digest[20];
18422 + * sceKernelUtilsSha1BlockInit(&ctx);
18423 + * sceKernelUtilsSha1BlockUpdate(&ctx, (u8*) "Hello", 5);
18424 + * sceKernelUtilsSha1BlockResult(&ctx, digest);
18425 + * @endcode
18426 + */
18427 +int sceKernelUtilsSha1BlockInit(SceKernelUtilsSha1Context *ctx);
18429 +/**
18430 + * Function to update the current hash.
18432 + * @param ctx - Pointer to a prefilled context.
18433 + * @param data - The data block to hash.
18434 + * @param size - The size of the data block
18436 + * @return < 0 on error.
18437 + */
18438 +int sceKernelUtilsSha1BlockUpdate(SceKernelUtilsSha1Context *ctx, u8 *data, u32 size);
18440 +/**
18441 + * Function to get the result of the SHA1 hash.
18443 + * @param ctx - Pointer to a prefilled context.
18444 + * @param digest - A pointer to a 20 byte array to contain the digest.
18446 + * @return < 0 on error.
18447 + */
18448 +int sceKernelUtilsSha1BlockResult(SceKernelUtilsSha1Context *ctx, u8 *digest);
18450 +/**@}*/
18452 +#ifdef __cplusplus
18454 +#endif
18456 +#endif
18457 diff --git a/newlib/psp/include/psputilsforkernel.h b/newlib/psp/include/psputilsforkernel.h
18458 new file mode 100644
18459 index 0000000..4063c02
18460 --- /dev/null
18461 +++ b/newlib/psp/include/psputilsforkernel.h
18462 @@ -0,0 +1,79 @@
18464 + * PSP Software Development Kit - https://github.com/pspdev
18465 + * -----------------------------------------------------------------------
18466 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18468 + * psputilsforkernel.h - Include file for UtilsForKernel
18470 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
18471 + * Copyright (c) 2005 adresd
18473 + */
18475 +#ifndef __PSPUTILSFORKERNEL_H__
18476 +#define __PSPUTILSFORKERNEL_H__
18478 +#ifdef __cplusplus
18479 +extern "C" {
18480 +#endif
18482 +/**
18483 + * Decompress gzip'd data (requires kernel mode)
18485 + * @param dest - pointer to destination buffer
18486 + * @param destSize - size of destination buffer
18487 + * @param src - pointer to source (compressed) data
18488 + * @param unknown - unknown, pass NULL
18489 + * @return size decompressed on success, < 0 on error
18490 + */
18491 +int sceKernelGzipDecompress(u8 *dest, u32 destSize, const u8 *src, u32 unknown);
18493 +/**
18494 + * Decompress deflate'd data (requires kernel mode)
18496 + * @param dest - pointer to destination buffer
18497 + * @param destSize - size of destination buffer
18498 + * @param src - pointer to source (compressed) data
18499 + * @param unknown - unknown, pass NULL
18500 + * @return size decompressed on success, < 0 on error
18501 + */
18502 +int sceKernelDeflateDecompress(u8 *dest, u32 destSize, const u8 *src, u32 unknown);
18504 +/**
18505 + * Invalidate the entire data cache
18506 + */
18507 +void sceKernelDcacheInvalidateAll(void);
18509 +/**
18510 + * Check whether the specified address is in the data cache
18511 + * @param addr - The address to check
18513 + * @return 0 = not cached, 1 = cache
18514 + */
18515 +int sceKernelDcacheProbe(void *addr);
18517 +/**
18518 + * Invalidate the entire instruction cache
18519 + */
18520 +void sceKernelIcacheInvalidateAll(void);
18522 +/**
18523 + * Invalidate a instruction cache range.
18524 + * @param addr - The start address of the range.
18525 + * @param size - The size in bytes
18526 + */
18527 +void sceKernelIcacheInvalidateRange(const void *addr, unsigned int size);
18529 +/**
18530 + * Check whether the specified address is in the instruction cache
18531 + * @param addr - The address to check
18533 + * @return 0 = not cached, 1 = cache
18534 + */
18535 +int sceKernelIcacheProbe(const void *addr);
18537 +#ifdef __cplusplus
18539 +#endif
18541 +#endif
18542 diff --git a/newlib/psp/include/pspvfpu.h b/newlib/psp/include/pspvfpu.h
18543 new file mode 100644
18544 index 0000000..6b81393
18545 --- /dev/null
18546 +++ b/newlib/psp/include/pspvfpu.h
18547 @@ -0,0 +1,75 @@
18549 + * PSP Software Development Kit - https://github.com/pspdev
18550 + * -----------------------------------------------------------------------
18551 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18553 + * pspvfpu.h - Prototypes for the VFPU library
18555 + * Copyright (c) 2005 Jeremy Fitzhardinge <jeremy@goop.org>
18557 + */
18558 +#ifndef __PSPVFPU_H__
18559 +#define __PSPVFPU_H__
18562 +#ifdef __cplusplus
18563 +extern "C" {
18564 +#endif
18566 +struct pspvfpu_context;
18567 +typedef unsigned char vfpumatrixset_t;
18569 +#define VMAT0 (1<<0)
18570 +#define VMAT1 (1<<1)
18571 +#define VMAT2 (1<<2)
18572 +#define VMAT3 (1<<3)
18573 +#define VMAT4 (1<<4)
18574 +#define VMAT5 (1<<5)
18575 +#define VMAT6 (1<<6)
18576 +#define VMAT7 (1<<7)
18578 +#define VFPU_ALIGNMENT (sizeof(float) * 4) /* alignment required for VFPU matrix loads and stores */
18580 +/**
18581 + Prepare to use the VFPU. This set's the calling thread's VFPU
18582 + attribute, and returns a pointer to some VFPU state storage.
18583 + The initial value all all VFPU matrix registers is undefined.
18585 + @return A VFPU context
18586 + */
18587 +struct pspvfpu_context *pspvfpu_initcontext(void);
18589 +/**
18590 + Delete a VFPU context. This frees the resources used by the VFPU
18591 + context.
18593 + @param context The VFPU context to be deleted.
18594 + */
18595 +void pspvfpu_deletecontext(struct pspvfpu_context *context);
18597 +/**
18598 + Use a set of VFPU matrices. This restores the parts of the VFPU
18599 + state the caller wants restored (if necessary). If the caller was
18600 + the previous user of the the matrix set, then this call is
18601 + effectively a no-op. If a matrix has never been used by this
18602 + context before, then it will initially have an undefined value.
18604 + @param context The VFPU context the caller wants to restore
18605 + from. It is valid to pass NULL as a context. This means the caller
18606 + wants to reserve a temporary matrix without affecting other VFPU
18607 + users, but doesn't want any long-term matrices itself.
18609 + @param keepset The set of matrices the caller wants to use, and
18610 + keep the values persistently.
18612 + @param tempset A set of matrices the callers wants to use
18613 + temporarily, but doesn't care about the values in the long-term.
18614 + */
18615 +void pspvfpu_use_matrices(struct pspvfpu_context *context,
18616 + vfpumatrixset_t keepset, vfpumatrixset_t tempset);
18618 +#ifdef __cplusplus
18620 +#endif
18622 +#endif /* __PSPVFPU_H__ */
18623 diff --git a/newlib/psp/include/pspvideocodec.h b/newlib/psp/include/pspvideocodec.h
18624 new file mode 100644
18625 index 0000000..eb1f180
18626 --- /dev/null
18627 +++ b/newlib/psp/include/pspvideocodec.h
18628 @@ -0,0 +1,35 @@
18630 + * PSP Software Development Kit - https://github.com/pspdev
18631 + * -----------------------------------------------------------------------
18632 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18634 + * pspvideocodec.h - Prototypes for the sceVideocodec library.
18636 + * Copyright (c) 2007 cooleyes
18638 + */
18640 +#ifndef __SCELIBVIDEOCODEC_H__
18641 +#define __SCELIBVIDEOCODEC_H__
18643 +#ifdef __cplusplus
18644 +extern "C" {
18645 +#endif
18647 +int sceVideocodecOpen(unsigned long *Buffer, int Type);
18648 +int sceVideocodecGetEDRAM(unsigned long *Buffer, int Type);
18649 +int sceVideocodecInit(unsigned long *Buffer, int Type);
18650 +int sceVideocodecDecode(unsigned long *Buffer, int Type);
18651 +int sceVideocodecReleaseEDRAM(unsigned long *Buffer);
18653 +// sceVideocodecGetVersion
18654 +// sceVideocodecScanHeader
18655 +// sceVideocodecDelete
18656 +// sceVideocodecSetMemory
18657 +// sceVideocodecStop
18659 +#ifdef __cplusplus
18661 +#endif
18663 +#endif
18664 \ No newline at end of file
18665 diff --git a/newlib/psp/include/pspwlan.h b/newlib/psp/include/pspwlan.h
18666 new file mode 100644
18667 index 0000000..6ba984f
18668 --- /dev/null
18669 +++ b/newlib/psp/include/pspwlan.h
18670 @@ -0,0 +1,63 @@
18672 + * PSP Software Development Kit - https://github.com/pspdev
18673 + * -----------------------------------------------------------------------
18674 + * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
18676 + * pspwlan.h - Prototypes for the sceWlan library
18678 + * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
18680 + */
18681 +#ifndef __PSPWLAN_H__
18682 +#define __PSPWLAN_H__
18684 +#ifdef __cplusplus
18685 +extern "C" {
18686 +#endif
18688 +/**
18689 + * Determine if the wlan device is currently powered on
18691 + * @return 0 if off, 1 if on
18692 + */
18693 +int sceWlanDevIsPowerOn(void);
18695 +/**
18696 + * Determine the state of the Wlan power switch
18698 + * @return 0 if off, 1 if on
18699 + */
18700 +int sceWlanGetSwitchState(void);
18702 +/**
18703 + * Get the Ethernet Address of the wlan controller
18705 + * @param etherAddr - pointer to a buffer of u8 (NOTE: it only writes to 6 bytes, but
18706 + * requests 8 so pass it 8 bytes just in case)
18707 + * @return 0 on success, < 0 on error
18708 + */
18709 +int sceWlanGetEtherAddr(u8 *etherAddr);
18711 +/**
18712 + * Attach to the wlan device
18714 + * @return 0 on success, < 0 on error.
18715 + */
18716 +int sceWlanDevAttach(void);
18718 +/**
18719 + * Detach from the wlan device
18721 + * @return 0 on success, < 0 on error/
18722 + */
18723 +int sceWlanDevDetach(void);
18726 +int sceWlanGPBindRegError();
18729 +#ifdef __cplusplus
18731 +#endif
18733 +#endif
18734 diff --git a/newlib/psp/include/sys/ioctl.h b/newlib/psp/include/sys/ioctl.h
18735 new file mode 100644
18736 index 0000000..0465938
18737 --- /dev/null
18738 +++ b/newlib/psp/include/sys/ioctl.h
18739 @@ -0,0 +1 @@
18740 +/* Empty file, here for compatibility */
18741 \ No newline at end of file
18742 diff --git a/newlib/psp/include/sys/socket.h b/newlib/psp/include/sys/socket.h
18743 new file mode 100644
18744 index 0000000..aa1036c
18745 --- /dev/null
18746 +++ b/newlib/psp/include/sys/socket.h
18747 @@ -0,0 +1,279 @@
18748 +/* $NetBSD: socket.h,v 1.77 2005/11/29 03:12:16 christos Exp $ */
18751 + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
18752 + * All rights reserved.
18754 + * Redistribution and use in source and binary forms, with or without
18755 + * modification, are permitted provided that the following conditions
18756 + * are met:
18757 + * 1. Redistributions of source code must retain the above copyright
18758 + * notice, this list of conditions and the following disclaimer.
18759 + * 2. Redistributions in binary form must reproduce the above copyright
18760 + * notice, this list of conditions and the following disclaimer in the
18761 + * documentation and/or other materials provided with the distribution.
18762 + * 3. Neither the name of the project nor the names of its contributors
18763 + * may be used to endorse or promote products derived from this software
18764 + * without specific prior written permission.
18766 + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18767 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18768 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18769 + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
18770 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18771 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18772 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18773 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18774 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
18775 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
18776 + * SUCH DAMAGE.
18777 + */
18780 + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
18781 + * The Regents of the University of California. All rights reserved.
18783 + * Redistribution and use in source and binary forms, with or without
18784 + * modification, are permitted provided that the following conditions
18785 + * are met:
18786 + * 1. Redistributions of source code must retain the above copyright
18787 + * notice, this list of conditions and the following disclaimer.
18788 + * 2. Redistributions in binary form must reproduce the above copyright
18789 + * notice, this list of conditions and the following disclaimer in the
18790 + * documentation and/or other materials provided with the distribution.
18791 + * 3. Neither the name of the University nor the names of its contributors
18792 + * may be used to endorse or promote products derived from this software
18793 + * without specific prior written permission.
18795 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18796 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18797 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18798 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
18799 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18800 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18801 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18802 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18803 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
18804 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
18805 + * SUCH DAMAGE.
18807 + * @(#)socket.h 8.6 (Berkeley) 5/3/95
18808 + */
18810 +#ifndef _SYS_SOCKET_H_
18811 +#define _SYS_SOCKET_H_
18813 +#ifdef __cplusplus
18814 +extern "C" {
18815 +#endif
18817 +#include <stdint.h>
18818 +#include <stddef.h>
18819 +#include <sys/types.h>
18821 +typedef uint8_t sa_family_t;
18822 +typedef uint32_t socklen_t;
18825 + * Socket types.
18826 + */
18827 +#define SOCK_STREAM 1 /* stream socket */
18828 +#define SOCK_DGRAM 2 /* datagram socket */
18829 +#define SOCK_RAW 3 /* raw-protocol interface */
18830 +#define SOCK_RDM 4 /* reliably-delivered message */
18831 +#define SOCK_SEQPACKET 5 /* sequenced packet stream */
18834 + * Option flags per-socket.
18835 + */
18836 +#define SO_DEBUG 0x0001 /* turn on debugging info recording */
18837 +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
18838 +#define SO_REUSEADDR 0x0004 /* allow local address reuse */
18839 +#define SO_KEEPALIVE 0x0008 /* keep connections alive */
18840 +#define SO_DONTROUTE 0x0010 /* just use interface addresses */
18841 +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
18842 +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
18843 +#define SO_LINGER 0x0080 /* linger on close if data present */
18844 +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
18845 +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
18846 +#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */
18849 + * Additional options, not kept in so_options.
18850 + */
18851 +#define SO_SNDBUF 0x1001 /* send buffer size */
18852 +#define SO_RCVBUF 0x1002 /* receive buffer size */
18853 +#define SO_SNDLOWAT 0x1003 /* send low-water mark */
18854 +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
18855 +#define SO_SNDTIMEO 0x1005 /* send timeout */
18856 +#define SO_RCVTIMEO 0x1006 /* receive timeout */
18857 +#define SO_ERROR 0x1007 /* get error status and clear */
18858 +#define SO_TYPE 0x1008 /* get socket type */
18859 +#define SO_OVERFLOWED 0x1009 /* datagrams: return packets dropped */
18860 +#define SO_NONBLOCK 0x1009 /* non-blocking I/O */
18863 + * Structure used for manipulating linger option.
18864 + */
18865 +struct linger {
18866 + int l_onoff; /* option on/off */
18867 + int l_linger; /* linger time in seconds */
18871 + * Level number for (get/set)sockopt() to apply to socket itself.
18872 + */
18873 +#define SOL_SOCKET 0xffff /* options for socket level */
18876 + * Address families.
18877 + */
18878 +#define AF_UNSPEC 0 /* unspecified */
18879 +#define AF_LOCAL 1 /* local to host (pipes, portals) */
18880 +#define AF_UNIX AF_LOCAL /* backward compatibility */
18881 +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
18882 +#define AF_IMPLINK 3 /* arpanet imp addresses */
18883 +#define AF_PUP 4 /* pup protocols: e.g. BSP */
18884 +#define AF_CHAOS 5 /* mit CHAOS protocols */
18885 +#define AF_NS 6 /* XEROX NS protocols */
18886 +#define AF_ISO 7 /* ISO protocols */
18887 +#define AF_OSI AF_ISO
18888 +#define AF_ECMA 8 /* european computer manufacturers */
18889 +#define AF_DATAKIT 9 /* datakit protocols */
18890 +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
18891 +#define AF_SNA 11 /* IBM SNA */
18892 +#define AF_DECnet 12 /* DECnet */
18893 +#define AF_DLI 13 /* DEC Direct data link interface */
18894 +#define AF_LAT 14 /* LAT */
18895 +#define AF_HYLINK 15 /* NSC Hyperchannel */
18896 +#define AF_APPLETALK 16 /* Apple Talk */
18897 +#define AF_ROUTE 17 /* Internal Routing Protocol */
18898 +#define AF_LINK 18 /* Link layer interface */
18899 +#define AF_COIP 20 /* connection-oriented IP, aka ST II */
18900 +#define AF_CNT 21 /* Computer Network Technology */
18901 +#define AF_IPX 23 /* Novell Internet Protocol */
18902 +#define AF_INET6 24 /* IP version 6 */
18903 +#define AF_ISDN 26 /* Integrated Services Digital Network*/
18904 +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
18905 +#define AF_NATM 27 /* native ATM access */
18906 +#define AF_ARP 28 /* (rev.) addr. res. prot. (RFC 826) */
18907 +#define AF_MAX 31
18910 + * Structure used by kernel to store most
18911 + * addresses.
18912 + */
18913 +struct sockaddr {
18914 + uint8_t sa_len; /* total length */
18915 + sa_family_t sa_family; /* address family */
18916 + char sa_data[14]; /* actually longer; address value */
18920 + * Protocol families, same as address families for now.
18921 + */
18922 +#define PF_UNSPEC AF_UNSPEC
18923 +#define PF_LOCAL AF_LOCAL
18924 +#define PF_UNIX PF_LOCAL /* backward compatibility */
18925 +#define PF_INET AF_INET
18926 +#define PF_IMPLINK AF_IMPLINK
18927 +#define PF_PUP AF_PUP
18928 +#define PF_CHAOS AF_CHAOS
18929 +#define PF_NS AF_NS
18930 +#define PF_ISO AF_ISO
18931 +#define PF_OSI AF_ISO
18932 +#define PF_ECMA AF_ECMA
18933 +#define PF_DATAKIT AF_DATAKIT
18934 +#define PF_CCITT AF_CCITT
18935 +#define PF_SNA AF_SNA
18936 +#define PF_DECnet AF_DECnet
18937 +#define PF_DLI AF_DLI
18938 +#define PF_LAT AF_LAT
18939 +#define PF_HYLINK AF_HYLINK
18940 +#define PF_APPLETALK AF_APPLETALK
18941 +#define PF_ROUTE AF_ROUTE
18942 +#define PF_LINK AF_LINK
18943 +#if defined(_NETBSD_SOURCE)
18944 +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
18945 +#endif
18946 +#define PF_COIP AF_COIP
18947 +#define PF_CNT AF_CNT
18948 +#define PF_INET6 AF_INET6
18949 +#define PF_IPX AF_IPX /* same format as AF_NS */
18950 +#if defined(_NETBSD_SOURCE)
18951 +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
18952 +#define PF_PIP pseudo_AF_PIP
18953 +#endif
18954 +#define PF_ISDN AF_ISDN /* same as E164 */
18955 +#define PF_E164 AF_E164
18956 +#define PF_NATM AF_NATM
18957 +#define PF_ARP AF_ARP
18958 +#if defined(_NETBSD_SOURCE)
18959 +#define PF_KEY pseudo_AF_KEY /* like PF_ROUTE, only for key mgmt */
18960 +#endif
18962 +#define PF_MAX AF_MAX
18964 +#define MSG_OOB 0x1 /* process out-of-band data */
18965 +#define MSG_PEEK 0x2 /* peek at incoming message */
18966 +#define MSG_DONTROUTE 0x4 /* send without using routing tables */
18967 +#define MSG_EOR 0x8 /* data completes record */
18968 +#define MSG_TRUNC 0x10 /* data discarded before delivery */
18969 +#define MSG_CTRUNC 0x20 /* control data lost before delivery */
18970 +#define MSG_WAITALL 0x40 /* wait for full request or error */
18971 +#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
18972 +#define MSG_BCAST 0x100 /* this message was rcvd using link-level brdcst */
18973 +#define MSG_MCAST 0x200 /* this message was rcvd using link-level mcast */
18976 + * Types of socket shutdown(2).
18977 + */
18978 +#define SHUT_RD 0 /* Disallow further receives. */
18979 +#define SHUT_WR 1 /* Disallow further sends. */
18980 +#define SHUT_RDWR 2 /* Disallow further sends/receives. */
18982 +struct iovec {
18983 + void *iov_base; /* Base address. */
18984 + size_t iov_len; /* Length. */
18988 + * Maximum queue length specifiable by listen.
18989 + */
18990 +#define SOMAXCONN 128
18992 +struct msghdr {
18993 + void *msg_name; /* optional address */
18994 + socklen_t msg_namelen; /* size of address */
18995 + struct iovec *msg_iov; /* scatter/gather array */
18996 + int msg_iovlen; /* # elements in msg_iov */
18997 + void *msg_control; /* ancillary data, see below */
18998 + socklen_t msg_controllen; /* ancillary data buffer len */
18999 + int msg_flags; /* flags on received message */
19002 +/* BSD-compatible socket API. */
19003 +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
19004 +int bind(int, const struct sockaddr *, socklen_t);
19005 +int connect(int, const struct sockaddr *, socklen_t);
19006 +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
19007 +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
19008 +int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
19009 +int listen(int, int);
19010 +ssize_t recv(int, void *, size_t, int);
19011 +ssize_t recvfrom(int, void * __restrict, size_t, int,
19012 + struct sockaddr * __restrict, socklen_t * __restrict);
19013 +ssize_t recvmsg(int s, struct msghdr *msg, int flags);
19014 +ssize_t send(int, const void *, size_t, int);
19015 +ssize_t sendto(int, const void *,
19016 + size_t, int, const struct sockaddr *, socklen_t);
19017 +ssize_t sendmsg(int s, const struct msghdr *msg, int flags);
19018 +int setsockopt(int, int, int, const void *, socklen_t);
19019 +int shutdown(int, int);
19020 +int socket(int, int, int);
19022 +#ifdef __cplusplus
19024 +#endif
19026 +#endif /* !_SYS_SOCKET_H_ */
19028 2.31.1