Skip to content

Commit

Permalink
Adjusted for libogc-rice changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Nov 20, 2024
1 parent 9e7a466 commit eb55030
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 43 deletions.
29 changes: 13 additions & 16 deletions fileBrowser/fileBrowser-libfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ extern int stop;
#ifdef HW_RVL
#include <sdcard/wiisd_io.h>
#include <ogc/usbstorage.h>
const DISC_INTERFACE* frontsd = &__io_wiisd;
const DISC_INTERFACE* usb = &__io_usbstorage;
static DISC_INTERFACE* frontsd = &__io_wiisd;
static DISC_INTERFACE* usb = &__io_usbstorage;
#else
#include <ogc/dvd.h>
const DISC_INTERFACE* gcloader = &__io_gcode;
static DISC_INTERFACE* gcloader = &__io_gcode;
#endif
const DISC_INTERFACE* carda = &__io_gcsda;
const DISC_INTERFACE* cardb = &__io_gcsdb;
const DISC_INTERFACE* cardc = &__io_gcsd2;
const DISC_INTERFACE* ideexia = &__io_ataa;
const DISC_INTERFACE* ideexib = &__io_atab;
const DISC_INTERFACE* ideexic = &__io_ata1;
static DISC_INTERFACE* carda = &__io_gcsda;
static DISC_INTERFACE* cardb = &__io_gcsdb;
static DISC_INTERFACE* cardc = &__io_gcsd2;
static DISC_INTERFACE* ideexia = &__io_ataa;
static DISC_INTERFACE* ideexib = &__io_atab;
static DISC_INTERFACE* ideexic = &__io_ata1;

// Threaded insertion/removal detection
#define THREAD_SLEEP 100
Expand Down Expand Up @@ -149,12 +149,12 @@ static void *removalCallback (void *arg)
{
#ifdef HW_RVL
if(sdMounted==FRONTSD)
if(!frontsd->isInserted()) {
if(!frontsd->isInserted(frontsd)) {
sdNeedsUnmount=FRONTSD;
sdMounted=0;
}
if(fatMounted==USB)
if(!usb->isInserted()) {
if(!usb->isInserted(usb)) {
fatNeedsUnmount=USB;
fatMounted = 0;
}
Expand Down Expand Up @@ -204,15 +204,14 @@ int fileBrowser_libfat_readDir(fileBrowser_file* file, fileBrowser_file** dir){
stat((*dir)[i].name, &fstat);
(*dir)[i].offset = 0;
(*dir)[i].size = fstat.st_size;
(*dir)[i].attr = S_ISDIR(fstat.st_mode) ?
FILE_BROWSER_ATTR_DIR : 0;
(*dir)[i].attr = S_ISDIR(fstat.st_mode) ? FILE_BROWSER_ATTR_DIR : 0;
++i;
}

closedir(dp);
continueRemovalThread();

return num_entries;
return i;
}

int fileBrowser_libfat_seekFile(fileBrowser_file* file, unsigned int where, unsigned int type){
Expand Down Expand Up @@ -266,7 +265,6 @@ int fileBrowser_libfat_init(fileBrowser_file* f){
pauseRemovalThread();
if(sdNeedsUnmount==FRONTSD) {
fatUnmount(f->name);
frontsd->shutdown();
sdNeedsUnmount = 0;
}
if(fatMountSimple("sd", frontsd)) {
Expand All @@ -293,7 +291,6 @@ int fileBrowser_libfat_init(fileBrowser_file* f){
pauseRemovalThread();
if(fatNeedsUnmount==USB) {
fatUnmount(f->name);
usb->shutdown();
fatNeedsUnmount=0;
}
usleep(devsleep);
Expand Down
54 changes: 30 additions & 24 deletions main/ata.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,123 +505,129 @@ int ataShutdown(int chn) {
}


static bool __ataa_startup(void)
static bool __ataa_startup(DISC_INTERFACE *disc)
{
return ataIsInserted(0);
}

static bool __ataa_isInserted(void)
static bool __ataa_isInserted(DISC_INTERFACE *disc)
{
return ataIsInserted(0);
}

static bool __ataa_readSectors(sec_t sector, sec_t numSectors, void *buffer)
static bool __ataa_readSectors(DISC_INTERFACE *disc, sec_t sector, sec_t numSectors, void *buffer)
{
return !ataReadSectors(0, (u64)sector, numSectors, buffer);
}

static bool __ataa_writeSectors(sec_t sector, sec_t numSectors, void *buffer)
static bool __ataa_writeSectors(DISC_INTERFACE *disc, sec_t sector, sec_t numSectors, void *buffer)
{
return !ataWriteSectors(0, (u64)sector, numSectors, buffer);
}

static bool __ataa_clearStatus(void)
static bool __ataa_clearStatus(DISC_INTERFACE *disc)
{
return true;
}

static bool __ataa_shutdown(void)
static bool __ataa_shutdown(DISC_INTERFACE *disc)
{
return true;
}

static bool __atab_startup(void)
static bool __atab_startup(DISC_INTERFACE *disc)
{
return ataIsInserted(1);
}

static bool __atab_isInserted(void)
static bool __atab_isInserted(DISC_INTERFACE *disc)
{
return ataIsInserted(1);
}

static bool __atab_readSectors(sec_t sector, sec_t numSectors, void *buffer)
static bool __atab_readSectors(DISC_INTERFACE *disc, sec_t sector, sec_t numSectors, void *buffer)
{
return !ataReadSectors(1, (u64)sector, numSectors, buffer);
}

static bool __atab_writeSectors(sec_t sector, sec_t numSectors, void *buffer)
static bool __atab_writeSectors(DISC_INTERFACE *disc, sec_t sector, sec_t numSectors, void *buffer)
{
return !ataWriteSectors(1, (u64)sector, numSectors, buffer);
}

static bool __atab_clearStatus(void)
static bool __atab_clearStatus(DISC_INTERFACE *disc)
{
return true;
}

static bool __atab_shutdown(void)
static bool __atab_shutdown(DISC_INTERFACE *disc)
{
return true;
}

static bool __ata1_startup(void)
static bool __ata1_startup(DISC_INTERFACE *disc)
{
return ataIsInserted(2);
}

static bool __ata1_isInserted(void)
static bool __ata1_isInserted(DISC_INTERFACE *disc)
{
return ataIsInserted(2);
}

static bool __ata1_readSectors(sec_t sector, sec_t numSectors, void *buffer)
static bool __ata1_readSectors(DISC_INTERFACE *disc, sec_t sector, sec_t numSectors, void *buffer)
{
return !ataReadSectors(2, (u64)sector, numSectors, buffer);
}

static bool __ata1_writeSectors(sec_t sector, sec_t numSectors, void *buffer)
static bool __ata1_writeSectors(DISC_INTERFACE *disc, sec_t sector, sec_t numSectors, void *buffer)
{
return !ataWriteSectors(2, (u64)sector, numSectors, buffer);
}

static bool __ata1_clearStatus(void)
static bool __ata1_clearStatus(DISC_INTERFACE *disc)
{
return true;
}

static bool __ata1_shutdown(void)
static bool __ata1_shutdown(DISC_INTERFACE *disc)
{
return true;
}

const DISC_INTERFACE __io_ataa = {
DISC_INTERFACE __io_ataa = {
DEVICE_TYPE_GC_ATA,
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_SLOTA,
(FN_MEDIUM_STARTUP)&__ataa_startup,
(FN_MEDIUM_ISINSERTED)&__ataa_isInserted,
(FN_MEDIUM_READSECTORS)&__ataa_readSectors,
(FN_MEDIUM_WRITESECTORS)&__ataa_writeSectors,
(FN_MEDIUM_CLEARSTATUS)&__ataa_clearStatus,
(FN_MEDIUM_SHUTDOWN)&__ataa_shutdown
(FN_MEDIUM_SHUTDOWN)&__ataa_shutdown,
0x1000000000000,
512
} ;
const DISC_INTERFACE __io_atab = {
DISC_INTERFACE __io_atab = {
DEVICE_TYPE_GC_ATA,
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_SLOTB,
(FN_MEDIUM_STARTUP)&__atab_startup,
(FN_MEDIUM_ISINSERTED)&__atab_isInserted,
(FN_MEDIUM_READSECTORS)&__atab_readSectors,
(FN_MEDIUM_WRITESECTORS)&__atab_writeSectors,
(FN_MEDIUM_CLEARSTATUS)&__atab_clearStatus,
(FN_MEDIUM_SHUTDOWN)&__atab_shutdown
(FN_MEDIUM_SHUTDOWN)&__atab_shutdown,
0x1000000000000,
512
} ;
const DISC_INTERFACE __io_ata1 = {
DISC_INTERFACE __io_ata1 = {
DEVICE_TYPE_GC_ATA,
FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_GAMECUBE_PORT1,
(FN_MEDIUM_STARTUP)&__ata1_startup,
(FN_MEDIUM_ISINSERTED)&__ata1_isInserted,
(FN_MEDIUM_READSECTORS)&__ata1_readSectors,
(FN_MEDIUM_WRITESECTORS)&__ata1_writeSectors,
(FN_MEDIUM_CLEARSTATUS)&__ata1_clearStatus,
(FN_MEDIUM_SHUTDOWN)&__ata1_shutdown
(FN_MEDIUM_SHUTDOWN)&__ata1_shutdown,
0x1000000000000,
512
} ;
6 changes: 3 additions & 3 deletions main/ata.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#define DEVICE_TYPE_GC_ATA (('G'<<24)|('A'<<16)|('T'<<8)|'A')

extern const DISC_INTERFACE __io_ataa;
extern const DISC_INTERFACE __io_atab;
extern const DISC_INTERFACE __io_ata1;
extern DISC_INTERFACE __io_ataa;
extern DISC_INTERFACE __io_atab;
extern DISC_INTERFACE __io_ata1;

// ATA status register bits
#define ATA_SR_BSY 0x80
Expand Down

0 comments on commit eb55030

Please sign in to comment.