Skip to content

Commit

Permalink
Merge pull request #620 from uyjulian/arcade_modules
Browse files Browse the repository at this point in the history
Implementation of arcade modules
  • Loading branch information
fjtrujy authored May 23, 2024
2 parents 2b14de2 + 8b6419f commit 7289725
Show file tree
Hide file tree
Showing 153 changed files with 15,498 additions and 0 deletions.
1 change: 1 addition & 0 deletions iop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Review ps2sdk README & LICENSE files for further details.

SUBDIRS = \
arcade \
cdvd \
debug \
dev9 \
Expand Down
30 changes: 30 additions & 0 deletions iop/arcade/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

SUBDIRS = \
acata \
acatad \
accdvd \
accdvde \
accore \
acdev \
acdev9 \
acflash \
acfpgald \
acjv \
acjvld \
acmem \
acmeme \
acram \
acrtc \
acsram \
actimer \
acuart

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/Rules.make
24 changes: 24 additions & 0 deletions iop/arcade/acata/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

IOP_INCS += \
-I$(PS2SDKSRC)/iop/arcade/accore/include \
-I$(PS2SDKSRC)/iop/arcade/actimer/include

IOP_OBJS = \
acata-entry.o \
ata.o \
atacmd.o \
atapicmd.o \
imports.o \
exports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
include $(PS2SDKSRC)/iop/Rules.make
include $(PS2SDKSRC)/iop/Rules.release
16 changes: 16 additions & 0 deletions iop/arcade/acata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Arcade ATA/ATAPI driver

This module handles the ATA/ATAPI interface \
for Bandai Namco System 246/256 systems.

## Configurations

There are multiple configurations of this library, allowing the choice of
balancing between size, speed, and features.

* `acata` -> The recommended version.

## How to use this module in your program

In order to use this module in your program, use `LoadModule` or \
`LoadModuleBuffer` with no arguments.
109 changes: 109 additions & 0 deletions iop/arcade/acata/include/acata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

#ifndef _ACATA_H
#define _ACATA_H

#include <accore.h>

typedef struct ac_ata acAtaData;
typedef acAtaData *acAtaT;

typedef void (*acAtaDone)(acAtaT ata, void *arg, int ret);

typedef struct ac_ata_ops *acAtaOpsT;

struct ac_ata_h
{
acQueueChainData a_chain;
acAtaOpsT a_ops;
void *a_arg;
void *a_buf;
acUint32 a_size;
acUint32 a_tmout;
acUint16 a_state;
acUint16 a_flag;
};

struct ac_ata_ops
{
int (*ao_command)(struct ac_ata_h *atah, int cmdpri, int pri);
void (*ao_done)(struct ac_ata_h *atah, int result);
int (*ao_error)(struct ac_ata_h *atah, int ret);
};

typedef acUint16 acAtaCommandData;
typedef acAtaCommandData *acAtaCommandT;

struct ac_ata
{
struct ac_ata_h ac_h;
acAtaDone ac_done;
acAtaCommandData ac_command[6];
};

typedef struct ac_atapi acAtapiData;
typedef acAtapiData *acAtapiT;

typedef void (*acAtapiDone)(acAtapiT atapi, void *arg, int ret);

union ac_atapi_pkt
{
acUint8 u_b[12];
acUint16 u_h[6];
acUint32 u_w[3];
};

typedef union ac_atapi_pkt acAtapiPacketData;
typedef acAtapiPacketData *acAtapiPacketT;

struct ac_atapi
{
struct ac_ata_h ap_h;
acAtapiDone ap_done;
acAtapiPacketData ap_packet;
};

typedef volatile acUint16 *acAtaReg;

extern int acAtaModuleRestart(int argc, char **argv);
extern int acAtaModuleStart(int argc, char **argv);
extern int acAtaModuleStatus();
extern int acAtaModuleStop();
extern acAtaT acAtaSetup(acAtaData *ata, acAtaDone done, void *arg, unsigned int tmout);
extern int acAtaRequest(acAtaT ata, int flag, acAtaCommandData *cmd, int item, void *buf, int size);
extern int acAtaRequestI(acAtaT ata, int flag, acAtaCommandData *cmd, int item, void *buf, int size);
extern acAtaCommandData *acAtaReply(acAtaT ata);
extern int acAtaStatus(acAtaT ata);
extern acAtapiT acAtapiSetup(acAtapiData *atapi, acAtapiDone done, void *arg, unsigned int tmout);
extern int acAtapiRequest(acAtapiT atapi, int flag, acAtapiPacketData *pkt, void *buf, int size);
extern int acAtapiRequestI(acAtapiT atapi, int flag, acAtapiPacketData *pkt, void *buf, int size);
extern int acAtapiStatus(acAtapiT atapi);
extern int ata_probe(acAtaReg atareg);

#define acata_IMPORTS_start DECLARE_IMPORT_TABLE(acata, 1, 1)
#define acata_IMPORTS_end END_IMPORT_TABLE

#define I_acAtaModuleRestart DECLARE_IMPORT(4, acAtaModuleRestart)
#define I_acAtaModuleStart DECLARE_IMPORT(5, acAtaModuleStart)
#define I_acAtaModuleStatus DECLARE_IMPORT(6, acAtaModuleStatus)
#define I_acAtaModuleStop DECLARE_IMPORT(7, acAtaModuleStop)
#define I_acAtaSetup DECLARE_IMPORT(8, acAtaSetup)
#define I_acAtaRequest DECLARE_IMPORT(9, acAtaRequest)
#define I_acAtaRequestI DECLARE_IMPORT(10, acAtaRequestI)
#define I_acAtaReply DECLARE_IMPORT(11, acAtaReply)
#define I_acAtaStatus DECLARE_IMPORT(12, acAtaStatus)
#define I_acAtapiSetup DECLARE_IMPORT(13, acAtapiSetup)
#define I_acAtapiRequest DECLARE_IMPORT(14, acAtapiRequest)
#define I_acAtapiRequestI DECLARE_IMPORT(15, acAtapiRequestI)
#define I_acAtapiStatus DECLARE_IMPORT(16, acAtapiStatus)
#define I_ata_probe DECLARE_IMPORT(17, ata_probe)

#endif
40 changes: 40 additions & 0 deletions iop/arcade/acata/src/acata-entry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

#include "acata_internal.h"

#define MODNAME "ATA/ATAPI_driver"
IRX_ID(MODNAME, 1, 1);
// Text section hash:
// b4ae71c954a7435710d4be18af0c2ba0
// Known titles:
// NM00048
// NM00052
// Path strings:
// /home/kyota/psalm2hd/psalm-0.1.3/ata-iop-0.1.8/src/
// /home/kyota/psalm2hd/psalm-0.1.3/core-hdr-0.1.3/src/util/

extern struct irx_export_table _exp_acata;

#define acAtaEntry _start

int acAtaEntry(int argc, char **argv)
{
int ret;

ret = acAtaModuleStart(argc, argv);
if ( ret < 0 )
{
return ret;
}
if ( !RegisterLibraryEntries(&_exp_acata) == 0 )
return -16;
return 0;
}
74 changes: 74 additions & 0 deletions iop/arcade/acata/src/acata_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

#ifndef _ACATA_INTERNAL_H
#define _ACATA_INTERNAL_H

#include <acata.h>
#include <irx_imports.h>

struct ata_softc
{
acQueueHeadData requestq;
acUint32 active;
acInt32 thid;
struct ac_ata_h *atah;
acUint16 cprio;
acUint16 prio;
acTimerData timer;
};

struct ata_dma
{
acDmaData ad_dma;
acAtaT ad_ata;
acInt32 ad_thid;
acInt32 ad_result;
acUint32 ad_state;
};

struct atapi_dma
{
acDmaData ad_dma;
acAtapiT ad_atapi;
acInt32 ad_thid;
acInt32 ad_result;
acUint32 ad_state;
};

struct atapi_sense
{
// cppcheck-suppress unusedStructMember
acUint8 s_valid;
// cppcheck-suppress unusedStructMember
acUint8 s_segnum;
acUint8 s_key;
// cppcheck-suppress unusedStructMember
acUint8 s_info[4];
// cppcheck-suppress unusedStructMember
acUint8 s_aslen;
// cppcheck-suppress unusedStructMember
acUint8 s_csi[4];
acUint8 s_asc;
acUint8 s_ascq;
// cppcheck-suppress unusedStructMember
acUint8 s_fruc;
// cppcheck-suppress unusedStructMember
acUint8 s_sks[3];
};

extern int ata_request(struct ac_ata_h *atah, int (*wakeup)(int thid));
extern int ata_probe(acAtaReg atareg);
extern int acAtaModuleStart(int argc, char **argv);
extern int acAtaModuleStop();
extern int acAtaModuleRestart(int argc, char **argv);
extern int acAtaModuleStatus();

#endif
Loading

0 comments on commit 7289725

Please sign in to comment.