summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkipcode66 <egamer1010@gmail.com>2020-09-30 06:30:24 -0400
committerkipcode66 <egamer1010@gmail.com>2020-09-30 06:30:24 -0400
commit1969f57f448472a6a4c1fb53d55e24f12cdf803f (patch)
treea1264df8894aa4727a4dc8554a60667c21bb9391
parent553aa6f2bc78420c9bb501eb6f6f0633dfd7043d (diff)
Create dvd.h
-rw-r--r--include/dvd.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/include/dvd.h b/include/dvd.h
new file mode 100644
index 0000000..e09c65f
--- /dev/null
+++ b/include/dvd.h
@@ -0,0 +1,108 @@
+#ifndef __DVD_H__
+#define __DVD_H__
+
+#include <stdint.h>
+
+/*
+ * DVD state codes
+ */
+#define DVD_STATE_FATAL_ERROR -1
+#define DVD_STATE_END 0
+#define DVD_STATE_BUSY 1
+#define DVD_STATE_WAITING 2
+#define DVD_STATE_COVER_CLOSED 3
+#define DVD_STATE_NO_DISK 4
+#define DVD_STATE_COVER_OPEN 5
+#define DVD_STATE_WRONG_DISK 6
+#define DVD_STATE_MOTOR_STOPPED 7
+#define DVD_STATE_IGNORED 8
+#define DVD_STATE_CANCELED 10
+#define DVD_STATE_RETRY 11
+
+/*
+ * DVD error codes
+ */
+#define DVD_ERROR_OK 0
+#define DVD_ERROR_FATAL -1
+#define DVD_ERROR_IGNORED -2
+#define DVD_ERROR_CANCELED -3
+#define DVD_ERROR_COVER_CLOSED -4
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Forward typedef for struct _DVDCommandBlock
+ */
+typedef struct _DVDCommandBlock DVDCommandBlock;
+
+/*!
+ * \typedef struct _dvdcmdblk dvdcmdblk
+ *
+ * This structure is used internally to control the requested operation.
+ */
+struct _DVDCommandBlock {
+ uint8_t unk1[12];
+ int32_t state;
+ uint8_t unk2[36];
+};
+
+typedef struct _DVDFileInfo DVDFileInfo;
+
+/**
+ * @brief function pointer typedef for the user's DVD operation callback
+ *
+ * @param[in] result error code of last operation
+ * @param[in] info pointer to user's file info strucutre
+ */
+typedef void (*DVDCallback)(uint32_t result, DVDFileInfo *info);
+
+struct _DVDFileInfo {
+ DVDCommandBlock blk;
+ uint32_t addr;
+ uint32_t len;
+ DVDCallback cb;
+} __attribute__((packed));
+
+bool DVDOpen(const char* param_1, DVDFileInfo* param_2);
+bool DVDClose(DVDFileInfo* fileInfo);
+int32_t DVDReadPrio(DVDFileInfo* fileInfo, void* buffer, int length, int offset, int prio);
+
+
+bool DVDGetCurrentDir(char* outBuf, uint32_t bufSize);
+bool DVDChangeDir(const char* path);
+
+
+typedef struct _DVDDirCursor DVDDirCursor;
+
+struct _DVDDirCursor {
+ int32_t dir_idx;
+ int32_t file_cursor;
+ uint32_t num_entries; // could be an offset, could be a length
+} __attribute__((packed));
+
+typedef struct _DVDDirEntryInfo DVDDirEntryInfo;
+
+struct _DVDDirEntryInfo {
+ int32_t curr_entrynum;
+ int32_t is_dir;
+ char* name;
+} __attribute__((packed));
+
+bool DVDOpenDir(const char* path, DVDDirCursor* dirinfo);
+/**
+ * @brief Fetch the current entry and forward the cursor to the next entry.
+ *
+ * @param[in|out] cursor The cursor to an opened directory.
+ * @param[out] entryInfo The data on the current entry.
+ * @returns True if the cursor successfully fetched an entry. False otherwise.
+ */
+bool DVDReadDir(DVDDirCursor* cursor, _DVDDirEntryInfo* entryInfo);
+bool DVDCloseDir(DVDDirCursor*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __DVD_H__ \ No newline at end of file