summaryrefslogtreecommitdiff
path: root/cesar/sys
diff options
context:
space:
mode:
authorsave2010-01-19 09:13:38 +0000
committersave2010-01-19 09:13:38 +0000
commit8f8d73ffa347ae9b7848475993e3cfa1ce8fe9a3 (patch)
treedf43f6b02274509e966219f1045cd2fbd4e23456 /cesar/sys
parent8a93a3fcddf62074c4930bde696935b06f16c129 (diff)
cesar/sys/sale: Add sale interface documentation for Cesar2
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6627 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/sys')
-rw-r--r--cesar/sys/sale/sale.h324
1 files changed, 324 insertions, 0 deletions
diff --git a/cesar/sys/sale/sale.h b/cesar/sys/sale/sale.h
new file mode 100644
index 0000000000..09243d6a6a
--- /dev/null
+++ b/cesar/sys/sale/sale.h
@@ -0,0 +1,324 @@
+#ifndef sale_h
+#define sale_h
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2010 SPiDCOM Technologies
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file sale.h
+ * \brief Interfaces for System Abstraction Layer Entity.
+ * \ingroup sys
+ *
+ * This file contains interfaces, exported macros, variables... For the
+ * System Abstraction Layer Entity.
+ *
+ * This is an interface documentation only file. As many of theses will be
+ * implemented as macro or inline functions, it will most of the time be
+ * replaced with an implementation specific file.
+ */
+#include "common/defs/net_buffer.h"
+
+#error "This is an documentation only header."
+
+/** Number of microseconds in a jiffy. */
+#define SALE_US_PER_JFF
+
+/** Thread context structure. */
+struct sale_thread_t
+{
+ /* Implementation specific. */
+}
+typedef struct sale_thread_t sale_thread_t;
+
+/** Declare a thread stack. This should be used right after the sale_thread_t
+ * structure. */
+#define SALE_THREAD_STACK(size) SALE_THREAD_STACK_ (size)
+
+/** Flag context structure. */
+struct sale_event_t
+{
+ /* Implementation specific. */
+}
+typedef struct sale_event_t sale_event_t;
+
+/** Alarm context structure. */
+struct sale_alarm_t
+{
+ /* Implementation specific. */
+}
+typedef struct sale_alarm_t sale_alarm_t;
+
+BEGIN_DECLS
+
+/**
+ * Allocate a net_buffer.
+ * \param size net_buffer size
+ * \return allocated buffer or NULL on error
+ */
+net_buffer_t *
+sale_net_buffer_alloc (int size);
+
+/**
+ * Free a net_buffer.
+ * \param pointer net_buffer pointer
+ */
+void
+sale_net_buffer_free (net_buffer_t *pointer);
+
+/**
+ * Map a memory area.
+ * \param phys_addr physical address to map
+ * \param size area size to map
+ * \return mapped area address
+ */
+void *
+sale_phys_map_area (u32 phys_addr, int size);
+
+/**
+ * Unmap a memory area.
+ * \param virt_addr virtual address to unmap
+ */
+void
+sale_phys_unmap_area (void *virt_addr);
+
+/**
+ * Find a virtual address corresponding to it physical one.
+ * \param phys_addr physical address
+ * \return virtual address
+ */
+void *
+sale_phys_to_virt (void *phys_addr);
+
+/**
+ * Find a physical address corresponding to it virtual one.
+ * \param virt_addr virtual address
+ * \return physical address
+ */
+void *
+sale_virt_to_phys (void *virt_addr);
+
+/**
+ * Invalidate cache for reading.
+ * \param addr start area address to synchronise
+ * \param words area size in words to synchronise
+ *
+ * This synchronise cache for reading from memory to processor. Any word
+ * loaded in cache will be discarded (and may be loaded, processor dependent).
+ */
+void
+sale_cache_invalidate (u32 *addr, int words);
+
+/**
+ * Invalidate and load cache for reading.
+ * \param addr start area address to synchronise
+ * \param words area size in words to synchronise
+ *
+ * This synchronise cache for reading from memory to processor. Any word
+ * loaded in cache will be discarded and reloaded.
+ */
+void
+sale_cache_load (u32 *addr, int words);
+
+/**
+ * Flush any write back buffer and write any dirty cache entry.
+ * \param addr start area address to synchronise
+ * \param words area size in words to synchronise
+ *
+ * This synchronise cache for writing from processor to memory. Any dirty
+ * word in cache will be written back to memory.
+ */
+void
+sale_cache_write_back (u32 *addr, int words);
+
+/**
+ * Register an interrupt.
+ * \param num interrupt number
+ * \param name interrupt name
+ * \param isr_handler isr handler
+ * \param dsr_handler dsr handler
+ * \param handler_data handler argument
+ */
+void
+sale_irq_request (int num, char *name,
+ void (*isr_handler) (void *handler_data),
+ void (*dsr_handler) (void *handler_data),
+ void *handler_data);
+
+/**
+ * Unregister an interrupt.
+ * \param num interrupt number
+ */
+void
+sale_irq_free (int num);
+
+/**
+ * Request a DSR run.
+ * \param num interrupt number
+ *
+ * This request the DSR to run in a near future. Calling this several times
+ * before the DSR is executed will have no further effect.
+ */
+void
+sale_dsr_schedule (int num);
+
+/**
+ * Forbid ISR execution.
+ * \return previous state
+ */
+uint
+sale_isr_lock (void);
+
+/**
+ * Restore previous ISR lock state.
+ * \param saved_state state returned by sale_isr_lock
+ */
+void
+sale_isr_unlock (uint saved_state);
+
+/**
+ * Forbid DSR execution.
+ * \return previous state
+ */
+uint
+sale_dsr_lock (void);
+
+/**
+ * Restore DSR execution.
+ * \param saved_state state returned by sale_dsr_lock
+ */
+void
+sale_dsr_unlock (uint saved_state);
+
+/**
+ * Initialise and start a thread.
+ * \param ctx thread context structure
+ * \param name thread name
+ * \param priority thread priority
+ * \param thread_stack_size size of thread stack in bytes
+ * \param entry thread entry
+ * \param entry_data thread entry argument
+ *
+ * Priority range can be 0 to 5.
+ * 5 is the max priority.
+ *
+ * Thread stack will be allocated or will use space reserved with
+ * SALE_THREAD_STACK right after the thread context. Its size can be ignored
+ * if the system handles it automatically.
+ */
+void
+sale_thread_create (sale_thread_t *ctx, char *name,
+ int priority, int thread_stack_size,
+ void (*entry) (void *entry_data),
+ void *entry_data);
+
+/**
+ * Delete a thread.
+ * \param ctx thread context structure
+ */
+void
+sale_thread_delete (sale_thread_t *ctx);
+
+/**
+ * Switch to an other thread execution.
+ *
+ * Start the scheduler to check if an other task need to be executed.
+ */
+void
+sale_thread_schedule (void);
+
+/**
+ * Suspend execution for a fixed delay.
+ * \param delay_jff delay in jiffies
+ */
+void
+sale_thread_delay (int delay_jff);
+
+/**
+ * Initialise an event.
+ * \param ctx event context structure
+ */
+void
+sale_event_init (sale_event_t *ctx);
+
+/**
+ * Uninitialise an event.
+ * \param ctx event context structure
+ */
+void
+sale_event_uninit (sale_event_t *ctx);
+
+/**
+ * Wait on a event.
+ * \param ctx event context structure
+ * \param condition C condition to be woken up
+ * \return 0 or negative if interrupted
+ */
+#define sale_event_wait(ctx, condition)
+
+/**
+ * Wake up event queue.
+ * \param ctx event context structure
+ */
+void
+sale_event_wakeup (sale_event_t *ctx);
+
+/**
+ * Initialise an alarm.
+ * \param ctx alarm context structure
+ * \param alarm_handler alarm handler
+ * \param handler_data handler argument
+ *
+ * Handler is running in DSR context.
+ */
+void
+sale_alarm_init (sale_alarm_t *ctx,
+ void (*alarm_handler) (void *handler_data),
+ void *handler_data);
+
+/**
+ * Uninitialise an alarm.
+ * \param ctx alarm context structure
+ *
+ * If the alarm is programmed, it is canceled.
+ */
+void
+sale_alarm_uninit (sale_alarm_t *ctx);
+
+/**
+ * Program an alarm to the given date.
+ * \param ctx alarm context structure
+ * \param expire_jffdate expiration date
+ *
+ * If the alarm was programmed, its expiration date is changed.
+ */
+void
+sale_alarm_program (sale_alarm_t *ctx, u32 expire_jffdate);
+
+/**
+ * Cancel an alarm.
+ * \param ctx alarm context structure
+ *
+ * There is no arm to cancel an alarm which is not programmed.
+ */
+void
+sale_alarm_cancel (sale_alarm_t *ctx);
+
+/**
+ * Get current date.
+ * \return current date in jiffies
+ */
+u32
+sale_jffdate (void);
+
+/**
+ * To Check.
+ */
+u32
+sale_phy_date (void);
+
+END_DECLS
+
+#endif /* sale_h */