4 * Copyright (c) 2011 embedded brains GmbH. All rights reserved.
10 * <rtems@embedded-brains.de>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * As a special exception, linking other files with the object code from
17 * this one to produce an executable application does not by itself cause
18 * the resulting executable application to be covered by the GNU General
20 * This exception does not however invalidate any other reasons why the
21 * executable file might be covered by the GNU Public License. In particular,
22 * the other YAFFS files are not covered by this exception, and using them
23 * in a proprietary application requires a paid license from Aleph One.
26 #include "rtems_yaffs.h"
31 static void rtems_yaffs_default_lock(struct yaffs_dev *dev, void *arg)
33 rtems_status_code sc = RTEMS_SUCCESSFUL;
34 rtems_yaffs_default_os_context *os_context = arg;
36 sc = rtems_semaphore_obtain(
37 os_context->semaphore_id,
41 assert(sc == RTEMS_SUCCESSFUL);
44 static void rtems_yaffs_default_unlock(struct yaffs_dev *dev, void *arg)
46 rtems_status_code sc = RTEMS_SUCCESSFUL;
47 rtems_yaffs_default_os_context *os_context = arg;
49 sc = rtems_semaphore_release(os_context->semaphore_id);
50 assert(sc == RTEMS_SUCCESSFUL);
53 static void rtems_yaffs_default_unmount(struct yaffs_dev *dev, void *arg)
55 rtems_status_code sc = RTEMS_SUCCESSFUL;
56 rtems_yaffs_default_os_context *os_context = arg;
58 sc = rtems_semaphore_delete(os_context->semaphore_id);
59 assert(sc == RTEMS_SUCCESSFUL);
62 int rtems_yaffs_initialize_default_os_context(
63 rtems_yaffs_default_os_context *os_context
66 rtems_status_code sc = RTEMS_SUCCESSFUL;
68 os_context->os_context.lock = rtems_yaffs_default_lock;
69 os_context->os_context.unlock = rtems_yaffs_default_unlock;
70 os_context->os_context.unmount = rtems_yaffs_default_unmount;
72 sc = rtems_semaphore_create(
73 rtems_build_name('Y', 'A', 'F', 'S'),
76 | RTEMS_BINARY_SEMAPHORE
77 | RTEMS_INHERIT_PRIORITY
80 &os_context->semaphore_id
82 if (sc == RTEMS_SUCCESSFUL) {