uOFW
Reverse engineered PSP kernel 6.60.
Loading...
Searching...
No Matches
inline.h
1/* Copyright (C) 2011 - 2015 The uOFW team
2 See the file COPYING for copying permission.
3*/
4
5#ifndef COMMON_INCLUDED
6# error "Only include common_imp.h or common_header.h!"
7#endif
8
9inline static s32 pspMax(s32 a, s32 b)
10{
11 s32 ret;
12 asm __volatile__ ("max %0, %1, %2" : "=r" (ret) : "r" (a), "r" (b));
13 return ret;
14}
15
16inline static s32 pspMin(s32 a, s32 b)
17{
18 s32 ret;
19 asm __volatile__ ("min %0, %1, %2" : "=r" (ret) : "r" (a), "r" (b));
20 return ret;
21}
22
23inline static void pspSync(void)
24{
25 asm __volatile__ ("sync");
26}
27
28inline static void pspCache(char op, const void *ptr)
29{
30 asm __volatile__ ("cache %0, 0(%1)" : : "ri" (op), "r" (ptr));
31}
32
33/*
34 * BREAK instruction
35 *
36 * 31 26 25 6 5 0
37 * +------+---------------------+------+
38 * |000000| break code |001101|
39 * +------+---------------------+------+
40 */
41
42/* break codes */
43#define SCE_BREAKCODE_ZERO 0x00000
44#define SCE_BREAKCODE_ONE 0x00001
45#define SCE_BREAKCODE_DIVZERO 0x00007 /* Divide by zero check. */
46
47#define MAKE_BREAKCODE_INSTR(op) ((((op) & 0xFFFFF) << 6) | 0xD)
48
49inline static void pspBreak(s32 op)
50{
51 asm __volatile__ ("break 0,%0" : : "ri" (op));
52}
53
54inline static void pspHalt(void)
55{
56 /* The 'HALT' instruction */
57 asm __volatile__ (".word 0x70000000");
58}
59
60inline static s32 pspMfic(void)
61{
62 s32 ret;
63 asm __volatile__ ("mfic %0, $0" : "=r" (ret));
64 return ret;
65}
66
67inline static s32 pspLl(s32 *ptr)
68{
69 s32 ret;
70 asm __volatile__ ("ll %0, (%1)" : "=r" (ret) : "r" (ptr));
71 return ret;
72}
73
74inline static s32 pspSc(s32 value, s32 *ptr)
75{
76 s32 ret = value;
77 asm __volatile__ ("sc %0, (%1)" : "=r" (ret) : "r" (ptr));
78 return ret;
79}
80
81inline static u32 pspWsbw(u32 value)
82{
83 asm __volatile__ ("wsbw %0, %0" : "=r" (value) : "r" (value));
84 return value;
85}
86