Skip to content

Commit ef78423

Browse files
committed
add: Add xfromserv support to libmc
1 parent 2dfd8e4 commit ef78423

2 files changed

Lines changed: 444 additions & 0 deletions

File tree

ee/rpc/memorycard/include/libmc.h

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,261 @@ extern int mcSync(int mode, int *cmd, int *result);
459459
*/
460460
extern int mcReset(void);
461461

462+
/** init external flash ROM lib
463+
*
464+
* @return 0 = successful; < 0 = error
465+
*/
466+
extern int xfromInit(int type);
467+
468+
/** get external flash ROM state
469+
* xfromSync result: 0 = same external flash ROM as last getInfo call
470+
* -1 = formatted external flash ROM inserted since last getInfo call
471+
* -2 = unformatted external flash ROM inserted since last getInfo call
472+
* < -2 = external flash ROM access error (could be due to accessing psx external flash ROM)
473+
*
474+
* @param port port number
475+
* @param slot slot number
476+
* @param type pointer to get external flash ROM type
477+
* @param free pointer to get number of free clusters
478+
* @param format pointer to get whether or not the external flash ROM is formatted
479+
* @return 0 = successful; < 0 = error
480+
*/
481+
extern int xfromGetInfo(int port, int slot, int* type, int* free, int* format);
482+
483+
/** open a file on external flash ROM
484+
* xfromSync returns: 0 or more = file descriptor (success)
485+
* < 0 = error
486+
*
487+
* @param port port number
488+
* @param slot slot number
489+
* @param name filename to open
490+
* @param mode open file mode (O_RDWR, O_CREAT, etc)
491+
* @return 0 = successful; < 0 = error
492+
*/
493+
extern int xfromOpen(int port, int slot, const char *name, int mode);
494+
495+
/** close an open file on external flash ROM
496+
* xfromSync returns: 0 if closed successfully
497+
* < 0 = error
498+
*
499+
* @param fd file descriptor of open file
500+
* @return 0 successful; < 0 = error
501+
*/
502+
extern int xfromClose(int fd);
503+
504+
/** move external flash ROM file pointer
505+
* xfromSync returns: 0 or more = offset of file pointer from start of file
506+
* < 0 = error
507+
*
508+
* @param fd file descriptor
509+
* @param offset number of bytes from origin
510+
* @param origin initial position for offset
511+
* @return 0 = successful; < 0 = error
512+
*/
513+
extern int xfromSeek(int fd, int offset, int origin);
514+
515+
516+
/** read from file on external flash ROM
517+
* xfromSync returns: 0 or more = number of bytes read from external flash ROM
518+
* < 0 = error
519+
*
520+
* @param fd file descriptor
521+
* @param buffer buffer to read to
522+
* @param size number of bytes to read
523+
* @return 0 = successful; < 0 = error
524+
*/
525+
extern int xfromRead(int fd, void *buffer, int size);
526+
527+
/** write to file on external flash ROM
528+
* xfromSync returns: 0 or more = number of bytes written to external flash ROM
529+
* < 0 = error
530+
*
531+
* @param fd file descriptor
532+
* @param buffer to write from write
533+
* @param size number of bytes to read
534+
* @return 0 = successful; < 0 = error
535+
*/
536+
extern int xfromWrite(int fd, const void *buffer, int size);
537+
538+
/** flush file cache to external flash ROM
539+
* xfromSync returns: 0 if ok
540+
* < 0 if error
541+
*
542+
* @param fd file descriptor
543+
* @return 0 = successful; < 0 = error
544+
*/
545+
extern int xfromFlush(int fd);
546+
547+
/** create a dir
548+
* xfromSync returns: 0 if ok
549+
* < 0 if error
550+
*
551+
* @param port port number
552+
* @param slot slot number
553+
* @param name directory name
554+
* @return 0 = successful; < 0 = error
555+
*/
556+
extern int xfromMkDir(int port, int slot, const char* name);
557+
558+
/** change current dir
559+
* (can also get current dir)
560+
* xfromSync returns: 0 if ok
561+
* < 0 if error
562+
*
563+
* @param port port number
564+
* @param slot slot number
565+
* @param newDir new dir to change to
566+
* @param currentDir buffer to get current dir (use 0 if not needed)
567+
* @return 0 = successful; < 0 = error
568+
*/
569+
extern int xfromChdir(int port, int slot, const char* newDir, char* currentDir);
570+
571+
/** get external flash ROM filelist
572+
* xfromSync result: 0 or more = number of file entries obtained (success)
573+
* -2 = unformatted external flash ROM
574+
* -4 = dirname error
575+
*
576+
* @param port port number of external flash ROM
577+
* @param slot slot number of external flash ROM
578+
* @param name filename to search for (can use wildcard and relative dirs)
579+
* @param mode mode: 0 = first call, otherwise = followup call
580+
* @param maxext maximum number of entries to be written to filetable in 1 call
581+
* @param table external flash ROM table array
582+
* @return 0 = successful; < 0 = error
583+
*/
584+
extern int xfromGetDir(int port, int slot, const char *name, unsigned mode, int maxent, sceMcTblGetDir* table);
585+
586+
/** change file information
587+
* xfromSync returns: 0 if ok
588+
* < 0 if error
589+
*
590+
* @param port port number
591+
* @param slot slot number
592+
* @param name filename to access
593+
* @param info data to be changed
594+
* @param flags flags to show which data is valid
595+
* @return 0 = successful; < 0 = error
596+
*/
597+
extern int xfromSetFileInfo(int port, int slot, const char* name, const sceMcTblGetDir* info, unsigned flags);
598+
599+
/** delete file
600+
* xfromSync returns: 0 if deleted successfully
601+
* < 0 if error
602+
*
603+
* @param port port number to delete from
604+
* @param slot slot number to delete from
605+
* @param name filename to delete
606+
* @return 0 = successful; < 0 = error
607+
*/
608+
extern int xfromDelete(int port, int slot, const char *name);
609+
610+
/** format external flash ROM
611+
* xfromSync returns: 0 if ok
612+
* < 0 if error
613+
*
614+
* @param port port number
615+
* @param slot slot number
616+
* @return 0 = success; -1 = error
617+
*/
618+
extern int xfromFormat(int port, int slot);
619+
620+
/** unformat external flash ROM
621+
* xfromSync returns: 0 if ok
622+
* < 0 if error
623+
*
624+
* @param port port number
625+
* @param slot slot number
626+
* @return 0 = success; -1 = error
627+
*/
628+
extern int xfromUnformat(int port, int slot);
629+
630+
/** get free space info
631+
* xfromSync returns: 0 or more = number of free entries (success)
632+
* < 0 if error
633+
*
634+
* @param port port number
635+
* @param slot slot number
636+
* @param path path to be checked
637+
* @return 0 or more = number of empty entries; -1 = error
638+
*/
639+
extern int xfromGetEntSpace(int port, int slot, const char* path);
640+
641+
/** rename file or dir on external flash ROM
642+
* xfromSync returns: 0 if ok
643+
* < 0 if error
644+
*
645+
* @param port port number
646+
* @param slot slot number
647+
* @param oldName name of file/dir to rename
648+
* @param newName new name to give to file/dir
649+
* @return 1 = success; < 0 = error
650+
*/
651+
extern int xfromRename(int port, int slot, const char* oldName, const char* newName);
652+
653+
/** Erases a block on the external flash ROM.
654+
* Note: The current implementation of xfromserv does not support this.
655+
* xfromSync returns: 0 if ok
656+
* < 0 if error
657+
*
658+
* @param port port number
659+
* @param slot slot number
660+
* @param block Block number of the block to be erased.
661+
* @param mode Mode: -1 to inhibit ECC recalculation of the erased block's pages (useful if xfromWritePage is used to fill in its contents later on), 0 for normal operation.
662+
* @return 0 = success; -1 = error
663+
*/
664+
extern int xfromEraseBlock(int port, int slot, int block, int mode);
665+
666+
/** Reads a page from the external flash ROM.
667+
* Note: The current implementation of xfromserv does not support this.
668+
* xfromSync returns: 0 if ok
669+
* < 0 if error
670+
*
671+
* @param port port number
672+
* @param slot slot number
673+
* @param page Page number of the page to be read.
674+
* @param buffer Pointer to buffer that will contain the read data.
675+
* @return 0 = success; -1 = error
676+
*/
677+
extern int xfromReadPage(int port, int slot, unsigned int page, void *buffer);
678+
679+
/** Writes a page to the external flash ROM. (The block which the page resides on must be erased first!)
680+
* Note: The current implementation of xfromserv does not support this.
681+
* xfromSync returns: 0 if ok
682+
* < 0 if error
683+
*
684+
* @param port port number
685+
* @param slot slot number
686+
* @param page Page number of the page to be written.
687+
* @param buffer Pointer to buffer containing data to be written.
688+
* @return 0 = success; -1 = error
689+
*/
690+
extern int xfromWritePage(int port, int slot, int page, const void *buffer);
691+
692+
/** change xfromserv thread priority
693+
* (I don't think this is implemented properly)
694+
* xfromSync returns: 0 if ok
695+
* < 0 if error
696+
*
697+
* @param level thread priority
698+
* @return 0 = success; -1 = error
699+
*/
700+
extern int xfromChangeThreadPriority(int level);
701+
702+
/** wait for external flash ROM functions to finish or check if they have finished yet
703+
*
704+
* @param mode mode 0=wait till function finishes, 1=check function status
705+
* @param cmd pointer for storing the number of the currenlty processing function
706+
* @param result pointer for storing result of function if it finishes
707+
* @return 0 = function is still executing (mode=1); 1 = function has finished executing; -1 = no function registered
708+
*/
709+
extern int xfromSync(int mode, int *cmd, int *result);
710+
711+
/** Reset (force deinit) of library
712+
*
713+
* @return 0 = success
714+
*/
715+
extern int xfromReset(void);
716+
462717
#ifdef __cplusplus
463718
}
464719
#endif

0 commit comments

Comments
 (0)