PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ps2sdkapi.h
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#ifndef __PS2SDKAPI_H__
12#define __PS2SDKAPI_H__
13
14#include <dirent.h>
15#include <inttypes.h>
16#include <sys/stat.h>
17#include <timer.h>
18#include <errno.h>
19#include <sys/socket.h>
20
24
25typedef int (*_libcglue_fdman_getfd_cb_t)(void *userdata);
26typedef char *(*_libcglue_fdman_getfilename_cb_t)(void *userdata);
27typedef int (*_libcglue_fdman_close_cb_t)(void *userdata);
28typedef int (*_libcglue_fdman_read_cb_t)(void *userdata, void *buf, int nbytes);
29typedef int (*_libcglue_fdman_lseek_cb_t)(void *userdata, int offset, int whence);
30typedef int64_t (*_libcglue_fdman_lseek64_cb_t)(void *userdata, int64_t offset, int whence);
31typedef int (*_libcglue_fdman_write_cb_t)(void *userdata, const void *buf, int nbytes);
32typedef int (*_libcglue_fdman_ioctl_cb_t)(void *userdata, int request, void *data);
33typedef int (*_libcglue_fdman_ioctl2_cb_t)(void *userdata, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
34typedef int (*_libcglue_fdman_dread_cb_t)(void *userdata, struct dirent *dir);
35typedef int (*_libcglue_fdman_fcntl_f_setfl_cb_t)(void *userdata, int newfl);
36typedef int (*_libcglue_fdman_accept_cb_t)(void *userdata, struct _libcglue_fdman_fd_info_ *info, struct sockaddr *addr, socklen_t *addrlen);
37typedef int (*_libcglue_fdman_bind_cb_t)(void *userdata, const struct sockaddr *my_addr, socklen_t addrlen);
38typedef int (*_libcglue_fdman_connect_cb_t)(void *userdata, const struct sockaddr *serv_addr, socklen_t addrlen);
39typedef int (*_libcglue_fdman_listen_cb_t)(void *userdata, int backlog);
40typedef ssize_t (*_libcglue_fdman_recv_cb_t)(void *userdata, void *buf, size_t len, int flags);
41typedef ssize_t (*_libcglue_fdman_recvfrom_cb_t)(void *userdata, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
42typedef ssize_t (*_libcglue_fdman_recvmsg_cb_t)(void *userdata, struct msghdr *msg, int flags);
43typedef ssize_t (*_libcglue_fdman_send_cb_t)(void *userdata, const void *buf, size_t len, int flags);
44typedef ssize_t (*_libcglue_fdman_sendto_cb_t)(void *userdata, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
45typedef ssize_t (*_libcglue_fdman_sendmsg_cb_t)(void *userdata, const struct msghdr *msg, int flags);
46typedef int (*_libcglue_fdman_getsockopt_cb_t)(void *userdata, int level, int optname, void *optval, socklen_t *optlen);
47typedef int (*_libcglue_fdman_setsockopt_cb_t)(void *userdata, int level, int optname, const void *optval, socklen_t optlen);
48typedef int (*_libcglue_fdman_shutdown_cb_t)(void *userdata, int how);
49typedef int (*_libcglue_fdman_getpeername_cb_t)(void *userdata, struct sockaddr *name, socklen_t *namelen);
50typedef int (*_libcglue_fdman_getsockname_cb_t)(void *userdata, struct sockaddr *name, socklen_t *namelen);
51
53{
54 _libcglue_fdman_getfd_cb_t getfd;
55 _libcglue_fdman_getfilename_cb_t getfilename;
56 _libcglue_fdman_close_cb_t close;
57 _libcglue_fdman_read_cb_t read;
58 _libcglue_fdman_lseek_cb_t lseek;
59 _libcglue_fdman_lseek64_cb_t lseek64;
60 _libcglue_fdman_write_cb_t write;
61 _libcglue_fdman_ioctl_cb_t ioctl;
62 _libcglue_fdman_ioctl2_cb_t ioctl2;
63 _libcglue_fdman_dread_cb_t dread;
64 _libcglue_fdman_fcntl_f_setfl_cb_t fcntl_f_setfl;
65 _libcglue_fdman_accept_cb_t accept;
66 _libcglue_fdman_bind_cb_t bind;
67 _libcglue_fdman_connect_cb_t connect;
68 _libcglue_fdman_listen_cb_t listen;
69 _libcglue_fdman_recv_cb_t recv;
70 _libcglue_fdman_recvfrom_cb_t recvfrom;
71 _libcglue_fdman_recvmsg_cb_t recvmsg;
72 _libcglue_fdman_send_cb_t send;
73 _libcglue_fdman_sendto_cb_t sendto;
74 _libcglue_fdman_sendmsg_cb_t sendmsg;
75 _libcglue_fdman_getsockopt_cb_t getsockopt;
76 _libcglue_fdman_setsockopt_cb_t setsockopt;
77 _libcglue_fdman_shutdown_cb_t shutdown;
78 _libcglue_fdman_getpeername_cb_t getpeername;
79 _libcglue_fdman_getsockname_cb_t getsockname;
81
83{
84 void *userdata;
87
88typedef int (*_libcglue_fdman_open_cb_t)(_libcglue_fdman_fd_info_t *info, const char *buf, int flags, mode_t mode);
89typedef int (*_libcglue_fdman_remove_cb_t)(const char *path);
90typedef int (*_libcglue_fdman_rename_cb_t)(const char *old, const char *new_);
91typedef int (*_libcglue_fdman_mkdir_cb_t)(const char *path, int mode);
92typedef int (*_libcglue_fdman_rmdir_cb_t)(const char *path);
93typedef int (*_libcglue_fdman_stat_cb_t)(const char *path, struct stat *buf);
94typedef int (*_libcglue_fdman_readlink_cb_t)(const char *path, char *buf, size_t bufsiz);
95typedef int (*_libcglue_fdman_symlink_cb_t)(const char *target, const char *linkpath);
96
98{
99 _libcglue_fdman_open_cb_t open;
100 _libcglue_fdman_remove_cb_t remove;
101 _libcglue_fdman_rename_cb_t rename;
102 _libcglue_fdman_mkdir_cb_t mkdir;
103 _libcglue_fdman_rmdir_cb_t rmdir;
104 _libcglue_fdman_stat_cb_t stat;
105 _libcglue_fdman_readlink_cb_t readlink;
106 _libcglue_fdman_symlink_cb_t symlink;
108
109extern _libcglue_fdman_path_ops_t *_libcglue_fdman_path_ops;
110
111typedef int (*_libcglue_fdman_setconfig_cb_t)(const t_ip_info *ip_info);
112typedef int (*_libcglue_fdman_getconfig_cb_t)(char *netif_name, t_ip_info *ip_info);
113typedef void (*_libcglue_fdman_dns_setserver_cb_t)(u8 numdns, const ip_addr_t *dnsserver);
114typedef const ip_addr_t *(*_libcglue_fdman_dns_getserver_cb_t)(u8 numdns);
115typedef int (*_libcglue_fdman_socket_cb_t)(_libcglue_fdman_fd_info_t *info, int domain, int type, int protocol);
116typedef int (*_libcglue_fdman_select_cb_t)(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
117typedef struct hostent *(*_libcglue_fdman_gethostbyaddr_cb_t)(const void *addr, int len, int type);
118typedef struct hostent *(*_libcglue_fdman_gethostbyname_cb_t)(const char *name);
119typedef int (*_libcglue_fdman_gethostbyname_r_cb_t)(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop);
120typedef void (*_libcglue_fdman_freeaddrinfo_cb_t)(struct addrinfo *ai);
121typedef int (*_libcglue_fdman_getaddrinfo_cb_t)(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
122
124{
125 _libcglue_fdman_setconfig_cb_t setconfig;
126 _libcglue_fdman_getconfig_cb_t getconfig;
127 _libcglue_fdman_dns_setserver_cb_t dns_setserver;
128 _libcglue_fdman_dns_getserver_cb_t dns_getserver;
129 _libcglue_fdman_socket_cb_t socket;
130 _libcglue_fdman_select_cb_t select;
131 _libcglue_fdman_gethostbyaddr_cb_t gethostbyaddr;
132 _libcglue_fdman_gethostbyname_cb_t gethostbyname;
133 _libcglue_fdman_gethostbyname_r_cb_t gethostbyname_r;
134 _libcglue_fdman_freeaddrinfo_cb_t freeaddrinfo;
135 _libcglue_fdman_getaddrinfo_cb_t getaddrinfo;
137
138extern _libcglue_fdman_socket_ops_t *_libcglue_fdman_socket_ops;
139
140typedef u32 (*_libcglue_fdman_inet_addr_cb_t)(const char *cp);
141typedef char *(*_libcglue_fdman_inet_ntoa_cb_t)(const ip4_addr_t *addr);
142typedef char *(*_libcglue_fdman_inet_ntoa_r_cb_t)(const ip4_addr_t *addr, char *buf, int buflen);
143typedef int (*_libcglue_fdman_inet_aton_cb_t)(const char *cp, ip4_addr_t *addr);
144
146{
147 _libcglue_fdman_inet_addr_cb_t inet_addr;
148 _libcglue_fdman_inet_ntoa_cb_t inet_ntoa;
149 _libcglue_fdman_inet_ntoa_r_cb_t inet_ntoa_r;
150 _libcglue_fdman_inet_aton_cb_t inet_aton;
152
153extern _libcglue_fdman_inet_ops_t *_libcglue_fdman_inet_ops;
154
155/* Functions from cwd.c */
156extern char __cwd[MAXNAMLEN + 1];
157int __path_absolute(const char *in, char *out, int len);
158
159#define PS2_CLOCKS_PER_SEC kBUSCLKBY256 // 576.000
160#define PS2_CLOCKS_PER_MSEC (PS2_CLOCKS_PER_SEC / 1000) // 576
161
162/* Disable the auto start of pthread on init for reducing binary size if not used. */
163#define PS2_DISABLE_AUTOSTART_PTHREAD() \
164 void __libpthreadglue_init() {} \
165 void __libpthreadglue_deinit() {}
166
167/* Namco system 246/256 dont have CDVDFSV module loaded on iop reboot. therefore, any libcglue code calling CDVDMAN RPCs will freeze*/
168#define LIBCGLUE_SUPPORT_NAMCO_SYSTEM_2x6() \
169 void _libcglue_rtc_update() {}
170
171typedef uint64_t ps2_clock_t;
172static inline ps2_clock_t ps2_clock(void) {
173 // DEPRECATED VERSION USE INSTEAD GetTimerSystemTime
174 return (ps2_clock_t)(GetTimerSystemTime() >> 8);
175}
176
177extern s64 _ps2sdk_rtc_offset_from_busclk;
178extern void _libcglue_rtc_update();
179
180// The newlib port does not support 64bit
181// this should have been defined in unistd.h
182typedef int64_t off64_t;
183off64_t lseek64(int fd, off64_t offset, int whence);
184
185// Functions to be used related to timezone
186extern void _libcglue_timezone_update();
187
188void ps2sdk_setTimezone(int timezone);
189void ps2sdk_setDaylightSaving(int daylightSaving);
190
191_libcglue_fdman_fd_info_t *libcglue_get_fd_info(int fd);
192int __libcglue_init_stdio(_libcglue_fdman_fd_info_t *info, int fd);
193
194/* The fd we provide to final user aren't actually the same than IOP's fd
195* so this function allow you to get actual IOP's fd from public fd
196*/
197extern int ps2sdk_get_iop_fd(int fd);
198extern char *ps2sdk_get_iop_filename(int fd);
199extern int _ps2sdk_close(int fd);
200extern int _ps2sdk_dclose(int fd);
201extern int _ps2sdk_read(int fd, void *buf, int nbytes);
202extern int _ps2sdk_lseek(int fd, int offset, int whence);
203extern int64_t _ps2sdk_lseek64(int fd, int64_t offset, int whence);
204extern int _ps2sdk_write(int fd, const void *buf, int nbytes);
205extern int _ps2sdk_ioctl(int fd, int request, void *data);
206extern int _ps2sdk_ioctl2(int fd, int request, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
207extern int _ps2sdk_dread(int fd, struct dirent *dir);
208
209#endif /* __PS2SDKAPI_H__ */
Definition time.h:29