FreeCalypso > hg > freecalypso-citrine
comparison services/ffs/task.h @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 09 Jun 2016 00:02:41 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:75a11d740a02 |
|---|---|
| 1 /****************************************************************************** | |
| 2 * Flash File System (ffs) | |
| 3 * Idea, design and coding by Mads Meisner-Jensen, mmj@ti.com | |
| 4 * | |
| 5 * ffs task | |
| 6 * | |
| 7 * $Id: task.h 1.23.1.17 Wed, 29 Oct 2003 12:54:27 +0100 tsj $ | |
| 8 * | |
| 9 ******************************************************************************/ | |
| 10 | |
| 11 #include "ffs.h" | |
| 12 | |
| 13 | |
| 14 #define OS_FREE(addr) rvf_free_buf(addr) | |
| 15 #define OS_MAIL_WAIT(event) rvf_wait(event, 0) | |
| 16 #define OS_MAIL_READ() rvf_read_mbox(RVF_TASK_MBOX_0) | |
| 17 #define OS_MAIL_SEND(dest, data) rvf_send_msg(dest, data); | |
| 18 #define OS_DELAY(time) rvf_delay(time) | |
| 19 #define OS_CREATE_TASK rvf_create_task | |
| 20 | |
| 21 #define OS_OK RV_OK | |
| 22 #define OS_TASK_MBOX_0 RVF_TASK_MBOX_0 | |
| 23 #define OS_MAIL_EVENT_MASK RVF_TASK_MBOX_0_EVT_MASK | |
| 24 #define T_OS_MB_ID T_RVF_MB_ID | |
| 25 | |
| 26 /****************************************************************************** | |
| 27 * Globals | |
| 28 ******************************************************************************/ | |
| 29 | |
| 30 extern T_OS_MB_ID ffs_mb_id; | |
| 31 extern UINT16 ffs_addr_id; | |
| 32 void ffs_task(void); | |
| 33 | |
| 34 /****************************************************************************** | |
| 35 * Macros | |
| 36 ******************************************************************************/ | |
| 37 | |
| 38 #define MSG_ALLOC(mail) if ((rvf_get_buf(ffs_mb_id, sizeof(struct ffs_req_s), \ | |
| 39 (T_RVF_BUFFER*) &mail)) == RVF_RED) { \ | |
| 40 return EFFS_MEMORY; \ | |
| 41 } | |
| 42 | |
| 43 #define MSG_SEND(mail) if (rvf_send_msg(ffs_addr_id, mail)) { \ | |
| 44 return EFFS_MSGSEND; \ | |
| 45 } | |
| 46 | |
| 47 | |
| 48 #define FFS_BLOCKING_CALL_BEGIN() \ | |
| 49 int result, error; \ | |
| 50 struct ffs_blocking_s fb; \ | |
| 51 T_RVF_MUTEX mutex; \ | |
| 52 if ((error = ffs_b_begin(&fb, &mutex, &result)) < 0) \ | |
| 53 return error; | |
| 54 | |
| 55 // The result variable contains the output from the ffs_xx_b() | |
| 56 // function. After the requested task has been executed is the contents in | |
| 57 // result replaced with the output from that task | |
| 58 #define FFS_BLOCKING_CALL_END() \ | |
| 59 if ((error = ffs_b_end(&mutex, result)) < 0) \ | |
| 60 return error; | |
| 61 | |
| 62 /****************************************************************************** | |
| 63 * Target Platform Abstraction Functions | |
| 64 ******************************************************************************/ | |
| 65 | |
| 66 req_id_t request_id_get(void); | |
| 67 void *target_malloc(unsigned int size); | |
| 68 | |
| 69 | |
| 70 /****************************************************************************** | |
| 71 * Types | |
| 72 ******************************************************************************/ | |
| 73 | |
| 74 // In and output variables to blocking functions | |
| 75 struct ffs_blocking_s { | |
| 76 int *result; | |
| 77 T_RVF_MUTEX *mutex; | |
| 78 }; | |
| 79 | |
| 80 // Structure of operation request mail sent from targetffs.c to FFS task. | |
| 81 struct ffs_req_s { | |
| 82 T_RV_HDR header; | |
| 83 const char *path; | |
| 84 char *src; | |
| 85 int size; | |
| 86 uint16 value16; | |
| 87 req_id_t request_id; | |
| 88 char cmd; | |
| 89 fd_t fdi; | |
| 90 T_RV_RETURN *cp; | |
| 91 struct ffs_blocking_s *fb; | |
| 92 }; | |
| 93 | |
| 94 // NOTEME: should we use the indices from tmffs.h instead? | |
| 95 typedef enum FFS_REQ_CMD { | |
| 96 NOP = 0, | |
| 97 PREFORMAT, | |
| 98 FORMAT, | |
| 99 FILE_WRITE, | |
| 100 REMOVE, | |
| 101 RENAME, | |
| 102 MKDIR, | |
| 103 SYMLINK, | |
| 104 FCONTROL, | |
| 105 OPEN, | |
| 106 WRITE, | |
| 107 CLOSE, | |
| 108 SEEK, | |
| 109 TRUNC, | |
| 110 FTRUNC, | |
| 111 FDATASYNC | |
| 112 } ffs_req_e; | |
| 113 | |
| 114 effs_t task_file_write(struct ffs_req_s *req); | |
| 115 effs_t task_symlink(struct ffs_req_s *req); | |
| 116 effs_t task_format(struct ffs_req_s *req); | |
| 117 effs_t task_preformat(struct ffs_req_s *req); | |
| 118 effs_t task_mkdir(struct ffs_req_s *req); | |
| 119 effs_t task_remove(struct ffs_req_s *req); | |
| 120 effs_t task_fcontrol(struct ffs_req_s *req); | |
| 121 effs_t task_rename(struct ffs_req_s *p); | |
| 122 fd_t task_open(struct ffs_req_s *req); | |
| 123 int task_write(struct ffs_req_s *req); | |
| 124 effs_t task_close(struct ffs_req_s *req); | |
| 125 int task_seek(struct ffs_req_s *req); | |
| 126 effs_t task_trunc(struct ffs_req_s *req); | |
| 127 effs_t task_ftrunc(struct ffs_req_s *req); | |
| 128 effs_t task_fdatasync(struct ffs_req_s *req); | |
| 129 | |
| 130 effs_t ffs_b_begin(struct ffs_blocking_s *fb, T_RVF_MUTEX *mutex, int *result); | |
| 131 effs_t ffs_b_end(T_RVF_MUTEX *mutex, int result); | |
| 132 void target_free(void *buf); | |
| 133 |
