comparison src/cs/drivers/drv_app/ffs/board/task.h @ 0:945cf7f506b2

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