RTEMS  5.0.0
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 
47 #define RTEMS_MEDIA_MOUNT_BASE "/media"
48 
49 #define RTEMS_MEDIA_DELIMITER '-'
50 
67 typedef enum {
68  RTEMS_MEDIA_EVENT_DISK_ATTACH,
69  RTEMS_MEDIA_EVENT_DISK_DETACH,
70  RTEMS_MEDIA_EVENT_MOUNT,
71  RTEMS_MEDIA_EVENT_UNMOUNT,
72  RTEMS_MEDIA_EVENT_PARTITION_INQUIRY,
73  RTEMS_MEDIA_EVENT_PARTITION_ATTACH,
74  RTEMS_MEDIA_EVENT_PARTITION_DETACH,
75  RTEMS_MEDIA_EVENT_ERROR
77 
89 typedef enum {
90  RTEMS_MEDIA_STATE_INQUIRY,
91  RTEMS_MEDIA_STATE_READY,
92  RTEMS_MEDIA_STATE_ABORTED,
93  RTEMS_MEDIA_STATE_SUCCESS,
94  RTEMS_MEDIA_STATE_FAILED,
95  RTEMS_MEDIA_ERROR_DISK_UNKNOWN,
96  RTEMS_MEDIA_ERROR_DISK_EXISTS,
97  RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_UNKNOWN,
98  RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_EXISTS,
99  RTEMS_MEDIA_ERROR_PARTITION_UNKNOWN,
100  RTEMS_MEDIA_ERROR_PARTITION_ORPHAN,
101  RTEMS_MEDIA_ERROR_PARTITION_DETACH_WITH_MOUNT,
102  RTEMS_MEDIA_ERROR_PARTITION_WITH_UNKNOWN_DISK,
103  RTEMS_MEDIA_ERROR_MOUNT_POINT_UNKNOWN,
104  RTEMS_MEDIA_ERROR_MOUNT_POINT_EXISTS,
105  RTEMS_MEDIA_ERROR_MOUNT_POINT_ORPHAN
107 
284  rtems_media_event event,
285  rtems_media_state state,
286  const char *src,
287  const char *dest,
288  void *listener_arg
289 );
290 
308  rtems_media_state state,
309  const char *src,
310  char **dest,
311  void *worker_arg
312 );
313 
329 {
330  return RTEMS_SUCCESSFUL;
331 }
332 
341  rtems_media_listener listener,
342  void *listener_arg
343 );
344 
352  rtems_media_listener listener,
353  void *listener_arg
354 );
355 
372  rtems_media_event event,
373  const char *src,
374  char **dest,
375  rtems_media_worker worker,
376  void *worker_arg
377 );
378 
399  rtems_task_priority priority,
400  size_t stack_size,
401  rtems_mode modes,
402  rtems_attribute attributes
403 );
404 
415  rtems_media_event event,
416  const char *src,
417  rtems_media_worker worker,
418  void *worker_arg
419 );
420 
424 static inline rtems_status_code rtems_media_server_disk_attach(
425  const char *driver_name,
426  rtems_media_worker worker,
427  void *worker_arg
428 )
429 {
431  RTEMS_MEDIA_EVENT_DISK_ATTACH,
432  driver_name,
433  worker,
434  worker_arg
435  );
436 }
437 
441 static inline rtems_status_code rtems_media_server_disk_detach(
442  const char *disk_path
443 )
444 {
446  RTEMS_MEDIA_EVENT_DISK_DETACH,
447  disk_path,
448  NULL,
449  NULL
450  );
451 }
452 
466  const char *prefix,
467  const char *name,
468  rtems_device_major_number major
469 );
470 
478 char *rtems_media_replace_prefix(const char *new_prefix, const char *path);
479 
486  const char *path,
487  rtems_device_minor_number minor
488 );
489 
505  const char *device_path,
506  dev_t *device_identifier
507 );
508 
509 const char *rtems_media_event_description(rtems_media_event event);
510 
511 const char *rtems_media_state_description(rtems_media_state state);
512 
517 #ifdef __cplusplus
518 }
519 #endif /* __cplusplus */
520 
521 #endif /* RTEMS_MEDIA_H */
Definition: status.h:47
uint32_t rtems_attribute
Definition: attr.h:41
RTEMS_INLINE_ROUTINE rtems_status_code rtems_media_initialize(void)
Initializes the media manager.
Definition: media.h:328
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:283
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 RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
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:913
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
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
Classic API Status.
Definition: status.h:43
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
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_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_media_event
Definition: media.h:67
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_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:307
uint32_t rtems_mode
Definition: modes.h:41
rtems_media_state
Definition: media.h:89
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
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
uint32_t rtems_task_priority
Definition: tasks.h:54