RTEMS  5.1
media.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2009, 2018 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Dornierstr. 4
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifndef RTEMS_MEDIA_H
24 #define RTEMS_MEDIA_H
25 
26 #include <sys/types.h>
27 #include <rtems.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 
49 #define RTEMS_MEDIA_MOUNT_BASE "/media"
50 
51 #define RTEMS_MEDIA_DELIMITER '-'
52 
69 typedef enum {
70  RTEMS_MEDIA_EVENT_DISK_ATTACH,
71  RTEMS_MEDIA_EVENT_DISK_DETACH,
72  RTEMS_MEDIA_EVENT_MOUNT,
73  RTEMS_MEDIA_EVENT_UNMOUNT,
74  RTEMS_MEDIA_EVENT_PARTITION_INQUIRY,
75  RTEMS_MEDIA_EVENT_PARTITION_ATTACH,
76  RTEMS_MEDIA_EVENT_PARTITION_DETACH,
77  RTEMS_MEDIA_EVENT_ERROR
79 
91 typedef enum {
92  RTEMS_MEDIA_STATE_INQUIRY,
93  RTEMS_MEDIA_STATE_READY,
94  RTEMS_MEDIA_STATE_ABORTED,
95  RTEMS_MEDIA_STATE_SUCCESS,
96  RTEMS_MEDIA_STATE_FAILED,
97  RTEMS_MEDIA_ERROR_DISK_UNKNOWN,
98  RTEMS_MEDIA_ERROR_DISK_EXISTS,
99  RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_UNKNOWN,
100  RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_EXISTS,
101  RTEMS_MEDIA_ERROR_PARTITION_UNKNOWN,
102  RTEMS_MEDIA_ERROR_PARTITION_ORPHAN,
103  RTEMS_MEDIA_ERROR_PARTITION_DETACH_WITH_MOUNT,
104  RTEMS_MEDIA_ERROR_PARTITION_WITH_UNKNOWN_DISK,
105  RTEMS_MEDIA_ERROR_MOUNT_POINT_UNKNOWN,
106  RTEMS_MEDIA_ERROR_MOUNT_POINT_EXISTS,
107  RTEMS_MEDIA_ERROR_MOUNT_POINT_ORPHAN
109 
286  rtems_media_event event,
287  rtems_media_state state,
288  const char *src,
289  const char *dest,
290  void *listener_arg
291 );
292 
310  rtems_media_state state,
311  const char *src,
312  char **dest,
313  void *worker_arg
314 );
315 
331 {
332  return RTEMS_SUCCESSFUL;
333 }
334 
343  rtems_media_listener listener,
344  void *listener_arg
345 );
346 
354  rtems_media_listener listener,
355  void *listener_arg
356 );
357 
374  rtems_media_event event,
375  const char *src,
376  char **dest,
377  rtems_media_worker worker,
378  void *worker_arg
379 );
380 
401  rtems_task_priority priority,
402  size_t stack_size,
403  rtems_mode modes,
404  rtems_attribute attributes
405 );
406 
417  rtems_media_event event,
418  const char *src,
419  rtems_media_worker worker,
420  void *worker_arg
421 );
422 
426 static inline rtems_status_code rtems_media_server_disk_attach(
427  const char *driver_name,
428  rtems_media_worker worker,
429  void *worker_arg
430 )
431 {
433  RTEMS_MEDIA_EVENT_DISK_ATTACH,
434  driver_name,
435  worker,
436  worker_arg
437  );
438 }
439 
443 static inline rtems_status_code rtems_media_server_disk_detach(
444  const char *disk_path
445 )
446 {
448  RTEMS_MEDIA_EVENT_DISK_DETACH,
449  disk_path,
450  NULL,
451  NULL
452  );
453 }
454 
468  const char *prefix,
469  const char *name,
470  rtems_device_major_number major
471 );
472 
480 char *rtems_media_replace_prefix(const char *new_prefix, const char *path);
481 
488  const char *path,
489  rtems_device_minor_number minor
490 );
491 
507  const char *device_path,
508  dev_t *device_identifier
509 );
510 
511 const char *rtems_media_event_description(rtems_media_event event);
512 
513 const char *rtems_media_state_description(rtems_media_state state);
514 
519 #ifdef __cplusplus
520 }
521 #endif /* __cplusplus */
522 
523 #endif /* RTEMS_MEDIA_H */
Definition: status.h:47
uint32_t rtems_attribute
Definition: attr.h:41
rtems_status_code rtems_media_listener_add(rtems_media_listener listener, void *listener_arg)
Adds the listener with argument listener_arg.
Definition: media.c:98
rtems_status_code rtems_media_server_post_event(rtems_media_event event, const char *src, rtems_media_worker worker, void *worker_arg)
Sends an event message to the media server.
Definition: media-server.c:117
rtems_media_event
Definition: media.h:69
char * rtems_media_create_path(const char *prefix, const char *name, rtems_device_major_number major)
Creates a new path as "prefix/name-major".
Definition: media-path.c:31
rtems_status_code(* rtems_media_listener)(rtems_media_event event, rtems_media_state state, const char *src, const char *dest, void *listener_arg)
Event listener.
Definition: media.h:285
rtems_status_code(* rtems_media_worker)(rtems_media_state state, const char *src, char **dest, void *worker_arg)
Do the work corresponding to an event.
Definition: media.h:309
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_status_code rtems_media_post_event(rtems_media_event event, const char *src, char **dest, rtems_media_worker worker, void *worker_arg)
Posts the event with source src.
Definition: media.c:914
rtems_media_state
Definition: media.h:91
char * rtems_media_append_minor(const char *path, rtems_device_minor_number minor)
Appends the minor number to the path resulting in "path-minor".
Definition: media-path.c:69
rtems_status_code rtems_media_get_device_identifier(const char *device_path, dev_t *device_identifier)
Returns the device identifier for the device located at device_path in device_identifier.
Definition: media-dev-ident.c:31
char * rtems_media_replace_prefix(const char *new_prefix, const char *path)
Replaces the prefix of the path with new_prefix.
Definition: media-path.c:51
RTEMS_INLINE_ROUTINE rtems_status_code rtems_media_initialize(void)
Initializes the media manager.
Definition: media.h:330
rtems_status_code rtems_media_listener_remove(rtems_media_listener listener, void *listener_arg)
Removes the listener with argument listener_arg.
Definition: media.c:129
uint32_t rtems_mode
Definition: modes.h:41
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
rtems_status_code rtems_media_server_initialize(rtems_task_priority priority, size_t stack_size, rtems_mode modes, rtems_attribute attributes)
Initializes the media manager and media server.
Definition: media-server.c:73
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
uint32_t rtems_task_priority
Definition: tasks.h:55