PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
nprintf.c
Go to the documentation of this file.
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
18#include "types.h"
19#include "stdio.h"
20#include "sysclib.h"
21#include "thbase.h"
22#include "intrman.h"
23#include "sysmem.h"
24#include "sifman.h"
25#include "sifcmd.h"
26
28#define NPM_PUTS 0x01
29#define RPC_NPM_USER 0x014d704e
30
38static void *naplinkRpcHandler(int cmd, void *buffer, int size)
39{
40 (void)cmd;
41 (void)size;
42
43 return buffer;
44}
45
47static SifRpcServerData_t server __attribute((aligned(16)));
48static SifRpcDataQueue_t queue __attribute((aligned(16)));
49static unsigned char rpc_buffer[512] __attribute__((__aligned__(4)));
50
56static void napThread(void *arg)
57{
58 int pid;
59
60 (void)arg;
61
62 SifInitRpc(0);
63 pid = GetThreadId();
64 SifSetRpcQueue(&queue, pid);
65 SifRegisterRpc(&server, RPC_NPM_USER, naplinkRpcHandler,
66 rpc_buffer, 0, 0, &queue);
67 SifRpcLoop(&queue); // Never exits
68 ExitDeleteThread();
69}
70
81{
82 iop_thread_t th_attr;
83 int ret;
84 int pid;
85
86 th_attr.attr = 0x02000000;
87 th_attr.option = 0;
88 th_attr.thread = napThread;
89 th_attr.stacksize = 0x800;
90 th_attr.priority = 0x4f;
91
92 pid = CreateThread(&th_attr);
93 if (pid < 0) {
94 printf("IOP: napRpc createThread failed %d\n", pid);
95 return -1;
96 }
97
98 ret = StartThread(pid, 0);
99 if (ret < 0) {
100 printf("IOP: napRpc startThread failed %d\n", ret);
101 DeleteThread(pid);
102 return -1;
103 }
104 return 0;
105}
static void * naplinkRpcHandler(int cmd, void *buffer, int size)
Definition nprintf.c:38
int naplinkRpcInit(void)
Definition nprintf.c:80
static void napThread(void *arg)
Definition nprintf.c:56