ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
smem.h File Reference
#include <tamtypes.h>
+ Include dependency graph for smem.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SUB_VIRT_MEM   0xbc000000
 

Functions

u32 smem_read (void *addr, void *buf, u32 size)
 
u32 smem_write (void *addr, void *buf, u32 size)
 

Detailed Description

Sub-CPU memory interface.

Definition in file smem.h.

Macro Definition Documentation

◆ SUB_VIRT_MEM

#define SUB_VIRT_MEM   0xbc000000

IOP RAM is mysteriously mapped into EE HW space at this address. I first noticed it was used by SCE in the PS2/Linux kernel, where it's used in the USB core driver. It's also used in a few places in the EE kernel.

I'm not exactly sure how the mapping looks to the bus, reads and writes to it are extremely fast, and data width hasn't been a problem for me yet (so you can use memcpy(), and obviously 16-byte reads and writes work).

For writes to IOP address space, the data cache MUST be first written back with SyncDCache(). I don't why why it is required, but writes do not always seem to take place properly without it.

For the PlayStation 3, this window does not seem to be correctly emulated. Although its EE kernel appears to still uses it, homebrew software cannot seem to use this window properly.

Definition at line 36 of file smem.h.

Function Documentation

◆ smem_read()

u32 smem_read ( void *  addr,
void *  buf,
u32  size 
)

Definition at line 21 of file smem.c.

22 {
23  DI();
25 
26  memcpy(buf, addr + SUB_VIRT_MEM, size);
27 
28  ee_kmode_exit();
29  EI();
30 
31  return size;
32 }
static int ee_kmode_exit()
Definition: kernel.h:198
static int ee_kmode_enter()
Definition: kernel.h:181
#define DI
Definition: kernel.h:24
#define EI
Definition: kernel.h:25
#define SUB_VIRT_MEM
Definition: smem.h:36

References DI, ee_kmode_enter(), ee_kmode_exit(), EI, and SUB_VIRT_MEM.

◆ smem_write()

u32 smem_write ( void *  addr,
void *  buf,
u32  size 
)

Definition at line 34 of file smem.c.

35 {
36  DI();
38 
39  memcpy(addr + SUB_VIRT_MEM, buf, size);
40 
41  ee_kmode_exit();
42  EI();
43 
44  return size;
45 }

References DI, ee_kmode_enter(), ee_kmode_exit(), EI, and SUB_VIRT_MEM.