Changeset 22c3a54b in rtems


Ignore:
Timestamp:
06/21/16 04:59:38 (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
3d9fd2ce
Parents:
f1531574
git-author:
Sebastian Huber <sebastian.huber@…> (06/21/16 04:59:38)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/22/16 05:45:49)
Message:

Add printer task

Location:
cpukit
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/printer.h

    rf1531574 r22c3a54b  
    2020
    2121#include <rtems/print.h>
     22#include <rtems/chain.h>
     23#include <rtems/rtems/intr.h>
     24#include <rtems/rtems/tasks.h>
    2225
    2326#include <stdio.h>
     
    111114extern void rtems_print_printer_fprintf(rtems_printer *printer, FILE *file);
    112115
     116typedef struct {
     117  rtems_id                     task;
     118  RTEMS_INTERRUPT_LOCK_MEMBER( lock )
     119  rtems_chain_control          free_buffers;
     120  rtems_chain_control          todo_buffers;
     121  size_t                       task_stack_size;
     122  rtems_task_priority          task_priority;
     123  int                          fd;
     124  void                        *buffer_table;
     125  size_t                       buffer_count;
     126  size_t                       buffer_size;
     127} rtems_printer_task_context;
     128
     129static inline void rtems_printer_task_initialize(
     130  rtems_printer_task_context *context
     131)
     132{
     133  memset( context, 0, sizeof( *context ) );
     134}
     135
     136static inline void rtems_printer_task_set_stack_size(
     137  rtems_printer_task_context *context,
     138  size_t                    stack_size
     139)
     140{
     141  context->task_stack_size = stack_size;
     142}
     143
     144static inline void rtems_printer_task_set_priority(
     145  rtems_printer_task_context *context,
     146  rtems_task_priority       priority
     147)
     148{
     149  context->task_priority = priority;
     150}
     151
     152static inline void rtems_printer_task_set_file_descriptor(
     153  rtems_printer_task_context *context,
     154  int                       fd
     155)
     156{
     157  context->fd = fd;
     158}
     159
     160static inline void rtems_printer_task_set_buffer_table(
     161  rtems_printer_task_context *context,
     162  void                     *buffer_table
     163)
     164{
     165  context->buffer_table = buffer_table;
     166}
     167
     168static inline void rtems_printer_task_set_buffer_count(
     169  rtems_printer_task_context *context,
     170  size_t                    buffer_count
     171)
     172{
     173  context->buffer_count = buffer_count;
     174}
     175
     176static inline void rtems_printer_task_set_buffer_size(
     177  rtems_printer_task_context *context,
     178  size_t                    buffer_size
     179)
     180{
     181  context->buffer_size = buffer_size;
     182}
     183
     184/**
     185 * @brief Creates a printer task.
     186 *
     187 * Print requests via rtems_printf() or rtems_vprintf() using a printer task
     188 * printer are output to a buffer and then placed on a work queue in FIFO
     189 * order.  The work queue is emptied by the printer task.  The printer task
     190 * writes the buffer content to the file descriptor specified by the context.
     191 * Buffers are allocated from a pool of buffers as specified by the context.
     192 *
     193 * @param[in] printer Pointer to the printer structure.
     194 * @param[in] context The initialized printer task context.
     195 *
     196 * @retval 0 Successful operation.
     197 * @retval EINVAL Invalid context parameters.
     198 * @retval ENOMEM Not enough resources.
     199 */
     200int rtems_print_printer_task(
     201  rtems_printer              *printer,
     202  rtems_printer_task_context *context
     203);
     204
     205/**
     206 * @brief Drains the work queue of the printer task.
     207 *
     208 * Waits until all output buffers in the work queue at the time of this
     209 * function call are written to the file descriptor and an fsync() completed.
     210 *
     211 * The printer task must be successfully started via rtems_print_printer_task()
     212 * before this function can be used.  Otherwise, the behaviour is undefined.
     213 *
     214 * @param[in] context The printer task context of a successfully started
     215 *   printer task.
     216 */
     217void rtems_printer_task_drain(rtems_printer_task_context *context);
     218
    113219/** @} */
    114220
  • cpukit/libcsupport/Makefile.am

    rf1531574 r22c3a54b  
    129129    $(BSD_LIBC_C_FILES) $(BASE_FS_C_FILES) $(MALLOC_C_FILES) \
    130130    $(ERROR_C_FILES) $(ASSOCIATION_C_FILES)
     131libcsupport_a_SOURCES += src/printertask.c
    131132
    132133libcsupport_a_SOURCES += $(LIBC_GLUE_C_FILES) $(PASSWORD_GROUP_C_FILES) \
Note: See TracChangeset for help on using the changeset viewer.