Numerous miscellaneous features incorporated from Tony Bennett

(tbennett@divnc.com) including the following major additions:

  + variable length messages
  + named devices
  + debug monitor
  + association tables/variables
This commit is contained in:
Joel Sherrill
1995-08-17 19:51:51 +00:00
parent 3b438fa4b0
commit b06e68ef1f
151 changed files with 15476 additions and 1815 deletions
+12 -19
View File
@@ -23,31 +23,24 @@ extern "C" {
/* variables */
extern volatile rtems_unsigned32 Clock_driver_ticks;
extern rtems_device_major_number rtems_clock_major;
extern rtems_device_minor_number rtems_clock_minor;
/* functions */
rtems_task Exit_task();
void exit_task_init();
void Install_clock( rtems_isr_entry );
void ReInstall_clock( rtems_isr_entry );
void Clock_exit();
rtems_isr Clock_isr(
rtems_vector_number
);
/* driver entries */
/* default clock driver entry */
#define CLOCK_DRIVER_TABLE_ENTRY \
{ Clock_initialize, NULL, NULL, NULL, NULL, NULL }
{ Clock_initialize, NULL, NULL, NULL, NULL, Clock_control }
rtems_device_driver Clock_initialize(
rtems_device_major_number,
rtems_device_minor_number,
void *,
rtems_id,
rtems_unsigned32 *
void *
);
rtems_device_driver Clock_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
);
#ifdef __cplusplus
@@ -0,0 +1,44 @@
/*
* @(#)assoc.h 1.2 - 95/06/28
*
*
* Rtems associativity routines. Mainly used to convert a value from
* one space to another (eg: our errno's to host errno's and v.v)
*
*
* $Id$
*/
#ifndef _INCLUDE_ASSOC_H
#define _INCLUDE_ASSOC_H
typedef struct {
char *name;
unsigned32 local_value;
unsigned32 remote_value;
} rtems_assoc_t;
/*
* Flag/marker for optional default value in each table
*/
#define RTEMS_ASSOC_DEFAULT_NAME "(default)"
rtems_assoc_t *rtems_assoc_ptr_by_name(rtems_assoc_t *, char *);
rtems_assoc_t *rtems_assoc_ptr_by_value(rtems_assoc_t *, unsigned32);
rtems_assoc_t *rtems_assoc_ptr_by_remote(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_remote_by_local(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_local_by_remote(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_remote_by_name(rtems_assoc_t *, char *);
unsigned32 rtems_assoc_local_by_name(rtems_assoc_t *, char *);
char *rtems_assoc_name_by_local(rtems_assoc_t *, unsigned32);
char *rtems_assoc_name_by_remote(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_remote_by_local_bitfield(rtems_assoc_t *, unsigned32);
char *rtems_assoc_name_by_local_bitfield(rtems_assoc_t *, unsigned32, char *);
char *rtems_assoc_name_by_remote_bitfield(rtems_assoc_t *, unsigned32, char *);
unsigned32 rtems_assoc_local_by_remote_bitfield(rtems_assoc_t *ap, unsigned32);
#endif /* ! _INCLUDE_ASSOC_H */
@@ -0,0 +1,26 @@
/*
* @(#)error.h 1.1 - 95/08/02
*
*
* Defines and externs for rtems error reporting
*
* $Id$
*/
/*
* rtems_error() and rtems_panic() support
*/
#define RTEMS_ERROR_ERRNO (1<<((sizeof(int) * 8) - 2)) /* hi bit; use 'errno' */
#define RTEMS_ERROR_PANIC (RTEMS_ERROR_ERRNO / 2) /* err fatal; no return */
#define RTEMS_ERROR_ABORT (RTEMS_ERROR_ERRNO / 4) /* err is fatal; panic */
#define RTEMS_ERROR_MASK (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | \
RTEMS_ERROR_PANIC) /* all */
char *rtems_status_text(rtems_status_code);
int rtems_error(int error_code, char *printf_format, ...);
void rtems_panic(char *printf_format, ...);
extern int rtems_panic_in_progress;
@@ -0,0 +1,101 @@
/*
* @(#)libio.h 1.1 - 95/06/02
*
*
* General purpose communication channel for RTEMS to allow UNIX/POSIX
* system call behavior on top of RTEMS IO devices.
*
* TODO
* stat(2)
* unlink(2)
* rename(2)
*
* $Id$
*/
#ifndef _RTEMS_LIBIO_H
#define _RTEMS_LIBIO_H
typedef unsigned32 rtems_libio_offset_t;
/*
* An open file data structure, indexed by 'fd'
* TODO:
* should really have a separate per/file data structure that this
* points to (eg: size, offset, driver, pathname should be in that)
*/
typedef struct {
rtems_driver_name_t *driver;
rtems_libio_offset_t size; /* size of file */
rtems_libio_offset_t offset; /* current offset into the file */
unsigned32 flags;
char *pathname; /* opened pathname */
Objects_Id sem;
unsigned32 data0; /* private to "driver" */
unsigned32 data1; /* ... */
} rtems_libio_t;
/*
* param block for read/write
* Note: it must include 'offset' instead of using iop's offset since
* we can have multiple outstanding i/o's on a device.
*/
typedef struct {
rtems_libio_t *iop;
rtems_libio_offset_t offset;
unsigned8 *buffer;
unsigned32 count;
unsigned32 flags;
unsigned32 bytes_moved;
} rtems_libio_rw_args_t;
/*
* param block for open/close
*/
typedef struct {
rtems_libio_t *iop;
unsigned32 flags;
unsigned32 mode;
} rtems_libio_open_close_args_t;
/*
* param block for ioctl
*/
typedef struct {
rtems_libio_t *iop;
unsigned32 command;
void *buffer;
unsigned32 ioctl_return;
} rtems_libio_ioctl_args_t;
/*
* Values for 'flag'
*/
#define LIBIO_FLAGS_NO_DELAY 0x0001 /* return immediately if no data */
#define LIBIO_FLAGS_READ 0x0002 /* reading */
#define LIBIO_FLAGS_WRITE 0x0004 /* writing */
#define LIBIO_FLAGS_LINE_BUFFERED 0x0008 /* line buffered io (^h, ^u, etc) */
#define LIBIO_FLAGS_OPEN 0x0100 /* device is open */
#define LIBIO_FLAGS_APPEND 0x0200 /* all writes append */
#define LIBIO_FLAGS_CREATE 0x0400 /* create file */
#define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
void rtems_libio_config(rtems_configuration_table *config, unsigned32 max_fds);
void rtems_libio_init(void);
int __open(const char *pathname, unsigned32 flag, unsigned32 mode);
int __close(int fd);
int __read(int fd, void *buffer, unsigned32 count);
int __write(int fd, const void *buffer, unsigned32 count);
int __ioctl(int fd, unsigned32 command, void *buffer);
int __lseek(int fd, rtems_libio_offset_t offset, int whence);
#endif /* _RTEMS_LIBIO_H */
+258
View File
@@ -0,0 +1,258 @@
/*
* @(#)assoc.c 1.4 - 95/08/02
*
*
* assoc.c
* rtems assoc routines
*
* $Id$
*/
#include <rtems.h>
#include "assoc.h"
#include <stdio.h> /* sprintf */
#include <string.h> /* strcat, strcmp */
#define STREQ(a,b) (strcmp((a), (b)) == 0)
#define rtems_assoc_is_default(ap) ((ap)->name && STREQ(ap->name, RTEMS_ASSOC_DEFAULT_NAME))
rtems_assoc_t *
rtems_assoc_ptr_by_name(
rtems_assoc_t *ap,
char *name
)
{
rtems_assoc_t *default_ap = 0;
if (rtems_assoc_is_default(ap))
default_ap = ap++;
for ( ; ap->name; ap++)
if (strcmp(ap->name, name) == 0)
return ap;
return default_ap;
}
rtems_assoc_t *
rtems_assoc_ptr_by_local(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
rtems_assoc_t *default_ap = 0;
if (rtems_assoc_is_default(ap))
default_ap = ap++;
for ( ; ap->name; ap++)
if (ap->local_value == local_value)
return ap;
return default_ap;
}
rtems_assoc_t *
rtems_assoc_ptr_by_remote(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
rtems_assoc_t *default_ap = 0;
if (rtems_assoc_is_default(ap))
default_ap = ap++;
for ( ; ap->name; ap++)
if (ap->remote_value == remote_value)
return ap;
return default_ap;
}
/*
* Get values
*/
unsigned32
rtems_assoc_remote_by_local(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_local(ap, local_value);
if (nap)
return nap->remote_value;
return 0;
}
unsigned32
rtems_assoc_local_by_remote(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_remote(ap, remote_value);
if (nap)
return nap->local_value;
return 0;
}
unsigned32
rtems_assoc_remote_by_name(
rtems_assoc_t *ap,
char *name
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_name(ap, name);
if (nap)
return nap->remote_value;
return 0;
}
unsigned32
rtems_assoc_local_by_name(
rtems_assoc_t *ap,
char *name
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_name(ap, name);
if (nap)
return nap->local_value;
return 0;
}
/*
* what to return if a value is not found
* this is not reentrant, but it really shouldn't be invoked anyway
*/
char *
rtems_assoc_name_bad(
unsigned32 bad_value
)
{
static char bad_buffer[32];
sprintf(bad_buffer, "< %d [0x%x] >", bad_value, bad_value);
return bad_buffer;
}
char *
rtems_assoc_name_by_local(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_local(ap, local_value);
if (nap)
return nap->name;
return rtems_assoc_name_bad(local_value);
}
char *
rtems_assoc_name_by_remote(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_remote(ap, remote_value);
if (nap)
return nap->name;
return rtems_assoc_name_bad(remote_value);
}
/*
* Bitfield functions assume just 1 bit set in each of remote and local
* entries; they do not check for this.
*/
unsigned32 rtems_assoc_remote_by_local_bitfield(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
unsigned32 b;
unsigned32 remote_value = 0;
for (b = 1; b; b <<= 1)
if (b & local_value)
remote_value |= rtems_assoc_remote_by_local(ap, b);
return remote_value;
}
unsigned32 rtems_assoc_local_by_remote_bitfield(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
unsigned32 b;
unsigned32 local_value = 0;
for (b = 1; b; b <<= 1)
if (b & remote_value)
local_value |= rtems_assoc_local_by_remote(ap, b);
return local_value;
}
char *rtems_assoc_name_by_remote_bitfield(
rtems_assoc_t *ap,
unsigned32 value,
char *buffer
)
{
unsigned32 b;
*buffer = 0;
for (b = 1; b; b <<= 1)
if (b & value)
{
if (*buffer)
strcat(buffer, " ");
strcat(buffer, rtems_assoc_name_by_remote(ap, b));
}
return buffer;
}
char *rtems_assoc_name_by_local_bitfield(
rtems_assoc_t *ap,
unsigned32 value,
char *buffer
)
{
unsigned32 b;
*buffer = 0;
for (b = 1; b; b <<= 1)
if (b & value)
{
if (*buffer)
strcat(buffer, " ");
strcat(buffer, rtems_assoc_name_by_local(ap, b));
}
return buffer;
}
+212
View File
@@ -0,0 +1,212 @@
/*
* @(#)error.c 1.2 - 95/08/02
*
*
* report errors and panics to RTEMS' stderr.
* Currently just used by RTEMS monitor.
*
*
* $Id$
*/
/*
* These routines provide general purpose error reporting.
* rtems_error reports an error to stderr and allows use of
* printf style formatting. A newline is appended to all messages.
*
* error_flag can be specified as any of the following:
*
* RTEMS_ERROR_ERRNO -- include errno text in output
* RTEMS_ERROR_PANIC -- halts local system after output
* RTEMS_ERROR_ABORT -- abort after output
*
* It can also include a rtems_status value which can be OR'd
* with the above flags. *
*
* EXAMPLE
* #include <rtems.h>
* #include <rtems/error.h>
* rtems_error(0, "stray interrupt %d", intr);
*
* EXAMPLE
* if ((status = rtems_task_create(...)) != RTEMS_SUCCCESSFUL)
* {
* rtems_error(status | RTEMS_ERROR_ABORT,
* "could not create task");
* }
*
* EXAMPLE
* if ((fd = open(pathname, O_RDNLY)) < 0)
* {
* rtems_error(FLOSS_ERROR_ERRNO, "open of '%s' failed", pathname);
* goto failed;
* }
*/
#include <rtems.h>
#include "error.h"
#include "assoc.h"
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> /* _exit() */
/* bug in hpux <errno.h>: no prototypes unless you are C++ */
#ifdef hpux9
char *strerror(int);
#endif
extern char *rtems_progname;
int rtems_panic_in_progress;
rtems_assoc_t rtems_status_assoc[] = {
{ "successful completion", RTEMS_SUCCESSFUL, },
{ "returned from a thread", RTEMS_TASK_EXITTED, },
{ "multiprocessing not configured", RTEMS_MP_NOT_CONFIGURED, },
{ "invalid object name", RTEMS_INVALID_NAME, },
{ "invalid object id", RTEMS_INVALID_ID, },
{ "too many", RTEMS_TOO_MANY, },
{ "timed out waiting", RTEMS_TIMEOUT, },
{ "object deleted while waiting", RTEMS_OBJECT_WAS_DELETED, },
{ "specified size was invalid", RTEMS_INVALID_SIZE, },
{ "address specified is invalid", RTEMS_INVALID_ADDRESS, },
{ "number was invalid", RTEMS_INVALID_NUMBER, },
{ "item has not been initialized", RTEMS_NOT_DEFINED, },
{ "resources still outstanding", RTEMS_RESOURCE_IN_USE, },
{ "request not satisfied", RTEMS_UNSATISFIED, },
{ "thread is in wrong state", RTEMS_INCORRECT_STATE, },
{ "thread already in state", RTEMS_ALREADY_SUSPENDED, },
{ "illegal on calling thread", RTEMS_ILLEGAL_ON_SELF, },
{ "illegal for remote object", RTEMS_ILLEGAL_ON_REMOTE_OBJECT, },
{ "called from wrong environment", RTEMS_CALLED_FROM_ISR, },
{ "invalid thread priority", RTEMS_INVALID_PRIORITY, },
{ "invalid date/time", RTEMS_INVALID_CLOCK, },
{ "invalid node id", RTEMS_INVALID_NODE, },
{ "directive not configured", RTEMS_NOT_CONFIGURED, },
{ "not owner of resource", RTEMS_NOT_OWNER_OF_RESOURCE , },
{ "directive not implemented", RTEMS_NOT_IMPLEMENTED, },
{ "RTEMS inconsistency detected", RTEMS_INTERNAL_ERROR, },
{ "internal multiprocessing only", RTEMS_PROXY_BLOCKING, },
{ "could not get enough memory", RTEMS_NO_MEMORY, },
{ 0, 0, 0 },
};
char *
rtems_status_text(
rtems_status_code status
)
{
return rtems_assoc_name_by_local(rtems_status_assoc, status);
}
static int rtems_verror(
unsigned32 error_flag,
char *printf_format,
va_list arglist
)
{
int local_errno = 0;
int chars_written = 0;
rtems_status_code status;
if (error_flag & RTEMS_ERROR_PANIC)
{
rtems_panic_in_progress++;
/* disable task switches */
_Thread_Disable_dispatch();
/* don't aggravate things */
if (rtems_panic_in_progress > 2)
return 0;
}
(void) fflush(stdout); /* in case stdout/stderr same */
status = error_flag & ~RTEMS_ERROR_MASK;
if (error_flag & RTEMS_ERROR_ERRNO) /* include errno? */
local_errno = errno;
if (_Configuration_Is_multiprocessing())
fprintf(stderr, "[%d] ", _Configuration_MP_table->node);
if (rtems_progname && *rtems_progname)
chars_written += fprintf(stderr, "%s: ", rtems_progname);
chars_written += vfprintf(stderr, printf_format, arglist);
if (status)
chars_written += fprintf(stderr, " (status: %s)", rtems_status_text(status));
if (local_errno)
if ((local_errno > 0) && *strerror(local_errno))
chars_written += fprintf(stderr, " (errno: %s)", strerror(local_errno));
else
chars_written += fprintf(stderr, " (unknown errno=%d)", local_errno);
chars_written += fprintf(stderr, "\n");
(void) fflush(stderr);
if (error_flag & (RTEMS_ERROR_PANIC | RTEMS_ERROR_ABORT))
{
if (error_flag & RTEMS_ERROR_PANIC)
{
rtems_error(0, "fatal error, exiting");
_exit(local_errno);
}
else
{
rtems_error(0, "fatal error, aborting");
abort();
}
}
return chars_written;
}
/*
* Report an error.
* error_flag is as above; printf_format is a normal
* printf(3) format string, with its concommitant arguments.
*
* Returns the number of characters written.
*/
int rtems_error(
int error_flag,
char *printf_format,
...
)
{
va_list arglist;
int chars_written;
va_start(arglist, printf_format);
chars_written = rtems_verror(error_flag, printf_format, arglist);
va_end(arglist);
return chars_written;
}
/*
* rtems_panic is shorthand for rtems_error(RTEMS_ERROR_PANIC, ...)
*/
void rtems_panic(
char *printf_format,
...
)
{
va_list arglist;
va_start(arglist, printf_format);
(void) rtems_verror(RTEMS_ERROR_PANIC, printf_format, arglist);
va_end(arglist);
}
+433
View File
@@ -0,0 +1,433 @@
/*
* @(#)libio.c 1.1 - 95/06/02
*
*
* Provide UNIX/POSIX-like io system calls for RTEMS using the
* RTEMS IO manager
*
* TODO
*
* $Id$
*/
#include <rtems.h>
#include <rtems/assoc.h> /* assoc.h not included by rtems.h */
#include <fcntl.h> /* O_RDONLY, et.al. */
#if defined(solaris2)
#define O_NDELAY O_NONBLOCK
#endif
#include <errno.h>
#include <string.h> /* strcmp */
#include <unistd.h>
#include <stdlib.h> /* calloc() */
#include "libio.h" /* libio.h not pulled in by rtems */
/*
* Semaphore to protect the io table
*/
Objects_Id rtems_libio_semaphore;
#define RTEMS_LIBIO_SEM rtems_build_name('L', 'B', 'I', 'O')
#define RTEMS_LIBIO_IOP_SEM(n) rtems_build_name('L', 'B', 'I', n)
unsigned32 rtems_libio_number_iops;
rtems_libio_t *rtems_libio_iops;
rtems_libio_t *rtems_libio_last_iop;
#define rtems_libio_iop(fd) ((((unsigned32)(fd)) < rtems_libio_number_iops) ? \
&rtems_libio_iops[fd] : 0)
#define rtems_libio_check_fd(fd) \
do { \
if ((fd) >= rtems_libio_number_iops) \
{ \
errno = EBADF; \
return -1; \
} \
} while (0)
#define rtems_libio_check_buffer(buffer) \
do { \
if ((buffer) == 0) \
{ \
errno = EINVAL; \
return -1; \
} \
} while (0)
#define rtems_libio_check_count(count) \
do { \
if ((count) == 0) \
{ \
return 0; \
} \
} while (0)
#define rtems_libio_check_permissions(iop, flag) \
do { \
if (((iop)->flags & (flag)) == 0) \
{ \
errno = EINVAL; \
return -1; \
} \
} while (0)
void
rtems_libio_config(
rtems_configuration_table *config,
unsigned32 max_fds
)
{
rtems_libio_number_iops = max_fds;
/*
* tweak config to reflect # of semaphores we will need
*/
config->maximum_semaphores += 1; /* one for iop table */
config->maximum_semaphores += max_fds;
}
/*
* Called by bsp startup code to init the libio area.
*/
void
rtems_libio_init(void)
{
rtems_status_code rc;
if (rtems_libio_number_iops > 0)
{
rtems_libio_iops = (rtems_libio_t *) calloc(rtems_libio_number_iops,
sizeof(rtems_libio_t));
if (rtems_libio_iops == NULL)
rtems_fatal_error_occurred(RTEMS_NO_MEMORY);
rtems_libio_last_iop = rtems_libio_iops + (rtems_libio_number_iops - 1);
}
rc = rtems_semaphore_create(RTEMS_LIBIO_SEM,
1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
&rtems_libio_semaphore);
if (rc != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(rc);
}
/*
* Convert RTEMS status to a UNIX errno
*/
rtems_assoc_t errno_assoc[] = {
{ "OK", RTEMS_SUCCESSFUL, 0 },
{ "TIMEOUT", RTEMS_TIMEOUT, ETIME },
{ "NO MEMORY", RTEMS_NO_MEMORY, ENOMEM },
{ 0, 0, 0 },
};
static unsigned32
rtems_libio_errno(rtems_status_code code)
{
int rc;
if ((rc = rtems_assoc_remote_by_local(errno_assoc, (unsigned32) code)))
{
errno = rc;
return -1;
}
return 0;
}
/*
* Convert UNIX fnctl(2) flags to ones that RTEMS drivers understand
*/
rtems_assoc_t access_modes_assoc[] = {
{ "READ", LIBIO_FLAGS_READ, O_RDONLY },
{ "WRITE", LIBIO_FLAGS_WRITE, O_WRONLY },
{ "READ/WRITE", LIBIO_FLAGS_READ_WRITE, O_RDWR },
{ 0, 0, 0 },
};
rtems_assoc_t status_flags_assoc[] = {
{ "NO DELAY", LIBIO_FLAGS_NO_DELAY, O_NDELAY },
{ "APPEND", LIBIO_FLAGS_APPEND, O_APPEND },
{ "CREATE", LIBIO_FLAGS_CREATE, O_CREAT },
{ 0, 0, 0 },
};
static unsigned32
rtems_libio_fcntl_flags(unsigned32 fcntl_flags)
{
unsigned32 flags = 0;
unsigned32 access_modes;
/*
* Access mode is a small integer
*/
access_modes = fcntl_flags & O_ACCMODE;
fcntl_flags &= ~O_ACCMODE;
flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes);
/*
* Everything else is single bits
*/
flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags);
return flags;
}
static rtems_libio_t *
rtems_libio_allocate(void)
{
rtems_libio_t *iop;
rtems_status_code rc;
rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++)
if ((iop->flags & LIBIO_FLAGS_OPEN) == 0)
{
/*
* Got one; create a semaphore for it
*/
rc = rtems_semaphore_create(RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops),
1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
&iop->sem);
if (rc != RTEMS_SUCCESSFUL)
goto failed;
iop->flags = LIBIO_FLAGS_OPEN;
goto done;
}
failed:
iop = 0;
done:
rtems_semaphore_release(rtems_libio_semaphore);
return iop;
}
static void
rtems_libio_free(rtems_libio_t *iop)
{
rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (iop->sem)
rtems_semaphore_delete(iop->sem);
(void) memset(iop, 0, sizeof(*iop));
rtems_semaphore_release(rtems_libio_semaphore);
}
int
__open(
const char *pathname,
unsigned32 flag,
unsigned32 mode)
{
rtems_status_code rc;
rtems_libio_t *iop = 0;
rtems_driver_name_t *np;
rtems_libio_open_close_args_t args;
if ((rc = rtems_io_lookup_name(pathname, &np)) != RTEMS_SUCCESSFUL)
goto done;
iop = rtems_libio_allocate();
if (iop == 0)
{
rc = RTEMS_TOO_MANY;
goto done;
}
iop->driver = np;
iop->pathname = (char *) pathname;
iop->flags |= rtems_libio_fcntl_flags(flag);
args.iop = iop;
args.flags = iop->flags;
args.mode = mode;
rc = rtems_io_open(np->major, np->minor, (void *) &args);
done:
if (rc != RTEMS_SUCCESSFUL)
{
if (iop)
rtems_libio_free(iop);
return rtems_libio_errno(rc);
}
return iop - rtems_libio_iops;
}
int
__close(
int fd
)
{
rtems_status_code rc;
rtems_driver_name_t *np;
rtems_libio_t *iop = rtems_libio_iop(fd);
rtems_libio_open_close_args_t args;
rtems_libio_check_fd(fd);
np = iop->driver;
args.iop = iop;
args.flags = 0;
args.mode = 0;
rc = rtems_io_close(np->major, np->minor, (void *) &args);
if (rc != RTEMS_SUCCESSFUL)
return rtems_libio_errno(rc);
return 0;
}
int
__read(
int fd,
void * buffer,
unsigned32 count
)
{
rtems_status_code rc;
rtems_driver_name_t *np;
rtems_libio_t *iop = rtems_libio_iop(fd);
rtems_libio_rw_args_t args;
rtems_libio_check_fd(fd);
rtems_libio_check_buffer(buffer);
rtems_libio_check_count(count);
rtems_libio_check_permissions(iop, LIBIO_FLAGS_READ);
np = iop->driver;
args.iop = iop;
args.offset = iop->offset;
args.buffer = buffer;
args.count = count;
args.flags = iop->flags;
args.bytes_moved = 0;
rc = rtems_io_read(np->major, np->minor, (void *) &args);
iop->offset += args.bytes_moved;
if (rc != RTEMS_SUCCESSFUL)
return rtems_libio_errno(rc);
return args.bytes_moved;
}
int
__write(
int fd,
const void *buffer,
unsigned32 count
)
{
rtems_status_code rc;
rtems_driver_name_t *np;
rtems_libio_t *iop = rtems_libio_iop(fd);
rtems_libio_rw_args_t args;
rtems_libio_check_fd(fd);
rtems_libio_check_buffer(buffer);
rtems_libio_check_count(count);
rtems_libio_check_permissions(iop, LIBIO_FLAGS_WRITE);
np = iop->driver;
args.iop = iop;
args.offset = iop->offset;
args.buffer = (void *) buffer;
args.count = count;
args.flags = iop->flags;
args.bytes_moved = 0;
rc = rtems_io_write(np->major, np->minor, (void *) &args);
iop->offset += args.bytes_moved;
if (rc != RTEMS_SUCCESSFUL)
return rtems_libio_errno(rc);
return args.bytes_moved;
}
int
__ioctl(
int fd,
unsigned32 command,
void * buffer)
{
rtems_status_code rc;
rtems_driver_name_t *np;
rtems_libio_t *iop = rtems_libio_iop(fd);
rtems_libio_ioctl_args_t args;
rtems_libio_check_fd(fd);
np = iop->driver;
args.iop = iop;
args.command = command;
args.buffer = buffer;
rc = rtems_io_control(np->major, np->minor, (void *) &args);
if (rc != RTEMS_SUCCESSFUL)
return rtems_libio_errno(rc);
return args.ioctl_return;
}
/*
* internal only??
*/
int
__lseek(
int fd,
rtems_libio_offset_t offset,
int whence
)
{
rtems_libio_t *iop = rtems_libio_iop(fd);
rtems_libio_check_fd(fd);
switch (whence)
{
case SEEK_SET:
iop->offset = offset;
break;
case SEEK_CUR:
iop->offset += offset;
break;
case SEEK_END:
iop->offset = iop->size - offset;
break;
default:
errno = EINVAL;
return -1;
}
return 0;
}
+45 -28
View File
@@ -41,14 +41,22 @@ extern "C" {
/*
* The following defines the data types needed to manipulate
* the contents of message buffers.
* Since msgs are variable length we just make a ptr to 1.
*/
typedef struct {
unsigned32 field1;
unsigned32 field2;
unsigned32 field3;
unsigned32 field4;
} Message_queue_Buffer;
unsigned32 size;
#ifndef __cplusplus
/* NOTE: [0] is gcc specific,
* but specifically disallowed by ANSI STD C++
* g++ warns about it, so we #ifdef it out to
* get rid of warnings when compiled by g++.
*/
unsigned32 buffer[0];
#endif
} Message_queue_Buffer;
/*
* The following records define the organization of a message
@@ -68,10 +76,13 @@ typedef struct {
typedef struct {
Objects_Control Object;
Thread_queue_Control Wait_queue;
rtems_attribute attribute_set;
rtems_attribute attribute_set;
unsigned32 maximum_pending_messages;
unsigned32 number_of_pending_messages;
unsigned32 maximum_message_size;
Chain_Control Pending_messages;
Message_queue_Buffer *message_buffers;
Chain_Control Inactive_messages;
} Message_queue_Control;
/*
@@ -81,13 +92,6 @@ typedef struct {
EXTERN Objects_Information _Message_queue_Information;
/*
* The following defines the data structures used to
* manage the pool of inactive message buffers.
*/
EXTERN Chain_Control _Message_queue_Inactive_messages;
/*
* The following enumerated type details the modes in which a message
* may be submitted to a message queue. The message may be posted
@@ -108,8 +112,7 @@ typedef enum {
*/
void _Message_queue_Manager_initialization(
unsigned32 maximum_message_queues,
unsigned32 maximum_messages
unsigned32 maximum_message_queues
);
/*
@@ -126,10 +129,11 @@ void _Message_queue_Manager_initialization(
*/
rtems_status_code rtems_message_queue_create(
Objects_Name name,
unsigned32 count,
Objects_Name name,
unsigned32 count,
unsigned32 max_message_size,
rtems_attribute attribute_set,
Objects_Id *id
Objects_Id *id
);
/*
@@ -183,7 +187,8 @@ rtems_status_code rtems_message_queue_delete(
rtems_status_code rtems_message_queue_send(
Objects_Id id,
void *buffer
void *buffer,
unsigned32 size
);
/*
@@ -204,7 +209,8 @@ rtems_status_code rtems_message_queue_send(
rtems_status_code rtems_message_queue_urgent(
Objects_Id id,
void *buffer
void *buffer,
unsigned32 size
);
/*
@@ -226,6 +232,7 @@ rtems_status_code rtems_message_queue_urgent(
rtems_status_code rtems_message_queue_broadcast(
Objects_Id id,
void *buffer,
unsigned32 size,
unsigned32 *count
);
@@ -246,8 +253,9 @@ rtems_status_code rtems_message_queue_broadcast(
rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
unsigned32 *size_p,
unsigned32 option_set,
rtems_interval timeout
rtems_interval timeout
);
/*
@@ -276,8 +284,9 @@ rtems_status_code rtems_message_queue_flush(
*/
STATIC INLINE void _Message_queue_Copy_buffer (
Message_queue_Buffer *source,
Message_queue_Buffer *destination
void *source,
void *destination,
unsigned32 size
);
/*
@@ -295,7 +304,8 @@ STATIC INLINE void _Message_queue_Copy_buffer (
boolean _Message_queue_Seize(
Message_queue_Control *the_message_queue,
unsigned32 option_set,
Message_queue_Buffer *buffer
void *buffer,
unsigned32 *size_p
);
/*
@@ -322,7 +332,8 @@ unsigned32 _Message_queue_Flush_support(
rtems_status_code _Message_queue_Submit(
Objects_Id id,
Message_queue_Buffer *buffer,
void *buffer,
unsigned32 size,
Message_queue_Submit_types submit_type
);
@@ -336,7 +347,9 @@ rtems_status_code _Message_queue_Submit(
*/
STATIC INLINE Message_queue_Buffer_control *
_Message_queue_Allocate_message_buffer ( void );
_Message_queue_Allocate_message_buffer (
Message_queue_Control *the_message_queue
);
/*
* _Message_queue_Free_message_buffer
@@ -348,6 +361,7 @@ STATIC INLINE Message_queue_Buffer_control *
*/
STATIC INLINE void _Message_queue_Free_message_buffer (
Message_queue_Control *the_message_queue,
Message_queue_Buffer_control *the_message
);
@@ -415,14 +429,17 @@ STATIC INLINE boolean _Message_queue_Is_null (
* the inactive chain of free message queue control blocks.
*/
STATIC INLINE Message_queue_Control *_Message_queue_Allocate ( void );
Message_queue_Control *_Message_queue_Allocate (
unsigned32 count,
unsigned32 max_message_size
);
/*
* _Message_queue_Free
*
* DESCRIPTION:
*
* This routine allocates a message queue control block from
* This routine deallocates a message queue control block into
* the inactive chain of free message queue control blocks.
*/
+7 -7
View File
@@ -55,15 +55,14 @@ typedef enum {
*/
typedef struct {
rtems_packet_prefix Prefix;
rtems_packet_prefix Prefix;
Message_queue_MP_Remote_operations operation;
Objects_Name name;
rtems_option option_set;
rtems_option option_set;
Objects_Id proxy_id;
unsigned32 count;
unsigned32 size;
unsigned32 pad0;
unsigned32 pad1;
unsigned32 pad2;
Message_queue_Buffer Buffer;
} Message_queue_MP_Packet;
@@ -95,9 +94,10 @@ void _Message_queue_MP_Send_process_packet (
rtems_status_code _Message_queue_MP_Send_request_packet (
Message_queue_MP_Remote_operations operation,
Objects_Id message_queue_id,
Message_queue_Buffer *buffer,
rtems_option option_set,
rtems_interval timeout
void *buffer,
unsigned32 *size_p,
rtems_option option_set,
rtems_interval timeout
);
/*
+45 -28
View File
@@ -41,14 +41,22 @@ extern "C" {
/*
* The following defines the data types needed to manipulate
* the contents of message buffers.
* Since msgs are variable length we just make a ptr to 1.
*/
typedef struct {
unsigned32 field1;
unsigned32 field2;
unsigned32 field3;
unsigned32 field4;
} Message_queue_Buffer;
unsigned32 size;
#ifndef __cplusplus
/* NOTE: [0] is gcc specific,
* but specifically disallowed by ANSI STD C++
* g++ warns about it, so we #ifdef it out to
* get rid of warnings when compiled by g++.
*/
unsigned32 buffer[0];
#endif
} Message_queue_Buffer;
/*
* The following records define the organization of a message
@@ -68,10 +76,13 @@ typedef struct {
typedef struct {
Objects_Control Object;
Thread_queue_Control Wait_queue;
rtems_attribute attribute_set;
rtems_attribute attribute_set;
unsigned32 maximum_pending_messages;
unsigned32 number_of_pending_messages;
unsigned32 maximum_message_size;
Chain_Control Pending_messages;
Message_queue_Buffer *message_buffers;
Chain_Control Inactive_messages;
} Message_queue_Control;
/*
@@ -81,13 +92,6 @@ typedef struct {
EXTERN Objects_Information _Message_queue_Information;
/*
* The following defines the data structures used to
* manage the pool of inactive message buffers.
*/
EXTERN Chain_Control _Message_queue_Inactive_messages;
/*
* The following enumerated type details the modes in which a message
* may be submitted to a message queue. The message may be posted
@@ -108,8 +112,7 @@ typedef enum {
*/
void _Message_queue_Manager_initialization(
unsigned32 maximum_message_queues,
unsigned32 maximum_messages
unsigned32 maximum_message_queues
);
/*
@@ -126,10 +129,11 @@ void _Message_queue_Manager_initialization(
*/
rtems_status_code rtems_message_queue_create(
Objects_Name name,
unsigned32 count,
Objects_Name name,
unsigned32 count,
unsigned32 max_message_size,
rtems_attribute attribute_set,
Objects_Id *id
Objects_Id *id
);
/*
@@ -183,7 +187,8 @@ rtems_status_code rtems_message_queue_delete(
rtems_status_code rtems_message_queue_send(
Objects_Id id,
void *buffer
void *buffer,
unsigned32 size
);
/*
@@ -204,7 +209,8 @@ rtems_status_code rtems_message_queue_send(
rtems_status_code rtems_message_queue_urgent(
Objects_Id id,
void *buffer
void *buffer,
unsigned32 size
);
/*
@@ -226,6 +232,7 @@ rtems_status_code rtems_message_queue_urgent(
rtems_status_code rtems_message_queue_broadcast(
Objects_Id id,
void *buffer,
unsigned32 size,
unsigned32 *count
);
@@ -246,8 +253,9 @@ rtems_status_code rtems_message_queue_broadcast(
rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
unsigned32 *size_p,
unsigned32 option_set,
rtems_interval timeout
rtems_interval timeout
);
/*
@@ -276,8 +284,9 @@ rtems_status_code rtems_message_queue_flush(
*/
STATIC INLINE void _Message_queue_Copy_buffer (
Message_queue_Buffer *source,
Message_queue_Buffer *destination
void *source,
void *destination,
unsigned32 size
);
/*
@@ -295,7 +304,8 @@ STATIC INLINE void _Message_queue_Copy_buffer (
boolean _Message_queue_Seize(
Message_queue_Control *the_message_queue,
unsigned32 option_set,
Message_queue_Buffer *buffer
void *buffer,
unsigned32 *size_p
);
/*
@@ -322,7 +332,8 @@ unsigned32 _Message_queue_Flush_support(
rtems_status_code _Message_queue_Submit(
Objects_Id id,
Message_queue_Buffer *buffer,
void *buffer,
unsigned32 size,
Message_queue_Submit_types submit_type
);
@@ -336,7 +347,9 @@ rtems_status_code _Message_queue_Submit(
*/
STATIC INLINE Message_queue_Buffer_control *
_Message_queue_Allocate_message_buffer ( void );
_Message_queue_Allocate_message_buffer (
Message_queue_Control *the_message_queue
);
/*
* _Message_queue_Free_message_buffer
@@ -348,6 +361,7 @@ STATIC INLINE Message_queue_Buffer_control *
*/
STATIC INLINE void _Message_queue_Free_message_buffer (
Message_queue_Control *the_message_queue,
Message_queue_Buffer_control *the_message
);
@@ -415,14 +429,17 @@ STATIC INLINE boolean _Message_queue_Is_null (
* the inactive chain of free message queue control blocks.
*/
STATIC INLINE Message_queue_Control *_Message_queue_Allocate ( void );
Message_queue_Control *_Message_queue_Allocate (
unsigned32 count,
unsigned32 max_message_size
);
/*
* _Message_queue_Free
*
* DESCRIPTION:
*
* This routine allocates a message queue control block from
* This routine deallocates a message queue control block into
* the inactive chain of free message queue control blocks.
*/
+7 -7
View File
@@ -55,15 +55,14 @@ typedef enum {
*/
typedef struct {
rtems_packet_prefix Prefix;
rtems_packet_prefix Prefix;
Message_queue_MP_Remote_operations operation;
Objects_Name name;
rtems_option option_set;
rtems_option option_set;
Objects_Id proxy_id;
unsigned32 count;
unsigned32 size;
unsigned32 pad0;
unsigned32 pad1;
unsigned32 pad2;
Message_queue_Buffer Buffer;
} Message_queue_MP_Packet;
@@ -95,9 +94,10 @@ void _Message_queue_MP_Send_process_packet (
rtems_status_code _Message_queue_MP_Send_request_packet (
Message_queue_MP_Remote_operations operation,
Objects_Id message_queue_id,
Message_queue_Buffer *buffer,
rtems_option option_set,
rtems_interval timeout
void *buffer,
unsigned32 *size_p,
rtems_option option_set,
rtems_interval timeout
);
/*
-13
View File
@@ -82,19 +82,6 @@ STATIC INLINE boolean _Attributes_Is_priority(
return ( attribute_set & RTEMS_PRIORITY );
}
/*PAGE
*
* _Attributes_Is_limit
*
*/
STATIC INLINE boolean _Attributes_Is_limit(
rtems_attribute attribute_set
)
{
return ( attribute_set & RTEMS_LIMIT );
}
/*PAGE
*
* _Attributes_Is_binary_semaphore
+19 -18
View File
@@ -17,6 +17,8 @@
#ifndef __MESSAGE_QUEUE_inl
#define __MESSAGE_QUEUE_inl
#include <rtems/wkspace.h>
/*PAGE
*
* _Message_queue_Copy_buffer
@@ -24,11 +26,12 @@
*/
STATIC INLINE void _Message_queue_Copy_buffer (
Message_queue_Buffer *source,
Message_queue_Buffer *destination
void *source,
void *destination,
unsigned32 size
)
{
*destination = *source;
memcpy(destination, source, size);
}
/*PAGE
@@ -38,10 +41,12 @@ STATIC INLINE void _Message_queue_Copy_buffer (
*/
STATIC INLINE Message_queue_Buffer_control *
_Message_queue_Allocate_message_buffer ( void )
_Message_queue_Allocate_message_buffer (
Message_queue_Control *the_message_queue
)
{
return (Message_queue_Buffer_control *)
_Chain_Get( &_Message_queue_Inactive_messages );
_Chain_Get( &the_message_queue->Inactive_messages );
}
/*PAGE
@@ -51,10 +56,11 @@ STATIC INLINE Message_queue_Buffer_control *
*/
STATIC INLINE void _Message_queue_Free_message_buffer (
Message_queue_Buffer_control *the_message
Message_queue_Control *the_message_queue,
Message_queue_Buffer_control *the_message
)
{
_Chain_Append( &_Message_queue_Inactive_messages, &the_message->Node );
_Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
}
/*PAGE
@@ -116,17 +122,6 @@ STATIC INLINE boolean _Message_queue_Is_null (
return ( the_message_queue == NULL );
}
/*PAGE
*
* _Message_queue_Allocate
*
*/
STATIC INLINE Message_queue_Control *_Message_queue_Allocate ( void )
{
return (Message_queue_Control *)
_Objects_Allocate( &_Message_queue_Information );
}
/*PAGE
*
@@ -138,6 +133,12 @@ STATIC INLINE void _Message_queue_Free (
Message_queue_Control *the_message_queue
)
{
if (the_message_queue->message_buffers)
{
_Workspace_Free((void *) the_message_queue->message_buffers);
the_message_queue->message_buffers = 0;
}
_Objects_Free( &_Message_queue_Information, &the_message_queue->Object );
}
@@ -82,19 +82,6 @@ STATIC INLINE boolean _Attributes_Is_priority(
return ( attribute_set & RTEMS_PRIORITY );
}
/*PAGE
*
* _Attributes_Is_limit
*
*/
STATIC INLINE boolean _Attributes_Is_limit(
rtems_attribute attribute_set
)
{
return ( attribute_set & RTEMS_LIMIT );
}
/*PAGE
*
* _Attributes_Is_binary_semaphore
+19 -18
View File
@@ -17,6 +17,8 @@
#ifndef __MESSAGE_QUEUE_inl
#define __MESSAGE_QUEUE_inl
#include <rtems/wkspace.h>
/*PAGE
*
* _Message_queue_Copy_buffer
@@ -24,11 +26,12 @@
*/
STATIC INLINE void _Message_queue_Copy_buffer (
Message_queue_Buffer *source,
Message_queue_Buffer *destination
void *source,
void *destination,
unsigned32 size
)
{
*destination = *source;
memcpy(destination, source, size);
}
/*PAGE
@@ -38,10 +41,12 @@ STATIC INLINE void _Message_queue_Copy_buffer (
*/
STATIC INLINE Message_queue_Buffer_control *
_Message_queue_Allocate_message_buffer ( void )
_Message_queue_Allocate_message_buffer (
Message_queue_Control *the_message_queue
)
{
return (Message_queue_Buffer_control *)
_Chain_Get( &_Message_queue_Inactive_messages );
_Chain_Get( &the_message_queue->Inactive_messages );
}
/*PAGE
@@ -51,10 +56,11 @@ STATIC INLINE Message_queue_Buffer_control *
*/
STATIC INLINE void _Message_queue_Free_message_buffer (
Message_queue_Buffer_control *the_message
Message_queue_Control *the_message_queue,
Message_queue_Buffer_control *the_message
)
{
_Chain_Append( &_Message_queue_Inactive_messages, &the_message->Node );
_Chain_Append( &the_message_queue->Inactive_messages, &the_message->Node );
}
/*PAGE
@@ -116,17 +122,6 @@ STATIC INLINE boolean _Message_queue_Is_null (
return ( the_message_queue == NULL );
}
/*PAGE
*
* _Message_queue_Allocate
*
*/
STATIC INLINE Message_queue_Control *_Message_queue_Allocate ( void )
{
return (Message_queue_Control *)
_Objects_Allocate( &_Message_queue_Information );
}
/*PAGE
*
@@ -138,6 +133,12 @@ STATIC INLINE void _Message_queue_Free (
Message_queue_Control *the_message_queue
)
{
if (the_message_queue->message_buffers)
{
_Workspace_Free((void *) the_message_queue->message_buffers);
the_message_queue->message_buffers = 0;
}
_Objects_Free( &_Message_queue_Information, &the_message_queue->Object );
}
-9
View File
@@ -60,15 +60,6 @@
#define _Attributes_Is_priority( _attribute_set ) \
( (_attribute_set) & RTEMS_PRIORITY )
/*PAGE
*
* _Attributes_Is_limit
*
*/
#define _Attributes_Is_limit( _attribute_set ) \
( (_attribute_set) & RTEMS_LIMIT )
/*PAGE
*
* _Attributes_Is_binary_semaphore
@@ -60,15 +60,6 @@
#define _Attributes_Is_priority( _attribute_set ) \
( (_attribute_set) & RTEMS_PRIORITY )
/*PAGE
*
* _Attributes_Is_limit
*
*/
#define _Attributes_Is_limit( _attribute_set ) \
( (_attribute_set) & RTEMS_LIMIT )
/*PAGE
*
* _Attributes_Is_binary_semaphore
+15 -9
View File
@@ -26,8 +26,7 @@
#include <rtems/wkspace.h>
void _Message_queue_Manager_initialization(
unsigned32 maximum_message_queues,
unsigned32 maximum_messages
unsigned32 maximum_message_queues
)
{
}
@@ -35,7 +34,8 @@ void _Message_queue_Manager_initialization(
rtems_status_code rtems_message_queue_create(
Objects_Name name,
unsigned32 count,
rtems_attribute attribute_set,
unsigned32 max_message_size,
rtems_attribute attribute_set,
Objects_Id *id
)
{
@@ -60,7 +60,8 @@ rtems_status_code rtems_message_queue_delete(
rtems_status_code rtems_message_queue_send(
Objects_Id id,
void *buffer
void *buffer,
unsigned32 size
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -68,7 +69,8 @@ rtems_status_code rtems_message_queue_send(
rtems_status_code rtems_message_queue_urgent(
Objects_Id id,
void *buffer
void *buffer,
unsigned32 size
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -77,6 +79,7 @@ rtems_status_code rtems_message_queue_urgent(
rtems_status_code rtems_message_queue_broadcast(
Objects_Id id,
void *buffer,
unsigned32 size,
unsigned32 *count
)
{
@@ -86,8 +89,9 @@ rtems_status_code rtems_message_queue_broadcast(
rtems_status_code rtems_message_queue_receive(
Objects_Id id,
void *buffer,
unsigned32 *size_p,
unsigned32 option_set,
rtems_interval timeout
rtems_interval timeout
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -110,8 +114,9 @@ unsigned32 _Message_queue_Flush_support(
boolean _Message_queue_Seize(
Message_queue_Control *the_message_queue,
rtems_option option_set,
Message_queue_Buffer *buffer
rtems_option option_set,
void *buffer,
unsigned32 *size_p
)
{
_Thread_Executing->Wait.return_code = RTEMS_UNSATISFIED;
@@ -120,7 +125,8 @@ boolean _Message_queue_Seize(
rtems_status_code _Message_queue_Submit(
Objects_Id id,
Message_queue_Buffer *buffer,
void *buffer,
unsigned32 size,
Message_queue_Submit_types submit_type
)
{
+30 -33
View File
@@ -32,14 +32,14 @@ extern "C" {
*/
typedef struct {
Objects_Name name; /* task name */
unsigned32 stack_size; /* task stack size */
Objects_Name name; /* task name */
unsigned32 stack_size; /* task stack size */
rtems_task_priority initial_priority; /* task priority */
rtems_attribute attribute_set; /* task attributes */
rtems_task_entry entry_point; /* task entry point */
rtems_mode mode_set; /* task initial mode */
unsigned32 argument; /* task argument */
} rtems_initialization_tasks_table;
rtems_attribute attribute_set; /* task attributes */
rtems_task_entry entry_point; /* task entry point */
rtems_mode mode_set; /* task initial mode */
unsigned32 argument; /* task argument */
} rtems_initialization_tasks_table;
/*
*
@@ -56,14 +56,12 @@ typedef struct {
typedef unsigned32 rtems_device_major_number;
typedef unsigned32 rtems_device_minor_number;
typedef void rtems_device_driver;
typedef rtems_status_code rtems_device_driver;
typedef rtems_device_driver ( *rtems_device_driver_entry )(
rtems_device_major_number,
rtems_device_minor_number,
void *,
Objects_Id,
unsigned32 *
void *
);
typedef struct {
@@ -173,12 +171,13 @@ typedef rtems_mpci_entry ( *rtems_mpci_receive_entry )(
typedef struct {
unsigned32 default_timeout; /* in ticks */
unsigned32 maximum_packet_size;
rtems_mpci_initialization_entry initialization;
rtems_mpci_get_packet_entry get_packet;
rtems_mpci_return_packet_entry return_packet;
rtems_mpci_send_entry send_packet;
rtems_mpci_receive_entry receive_packet;
} rtems_mpci_table;
} rtems_mpci_table;
/*
* The following records define the Multiprocessor Configuration
@@ -192,8 +191,7 @@ struct Configuration_Table_MP {
unsigned32 maximum_nodes; /* maximum # nodes in system */
unsigned32 maximum_global_objects; /* maximum # global objects */
unsigned32 maximum_proxies; /* maximum # proxies */
rtems_mpci_table *User_mpci_table;
/* pointer to MPCI table */
rtems_mpci_table *User_mpci_table; /* pointer to MPCI table */
};
/*
@@ -209,25 +207,24 @@ struct Configuration_Table_MP {
*/
struct Configuration_Table {
void *work_space_start;
unsigned32 work_space_size;
unsigned32 maximum_tasks;
unsigned32 maximum_timers;
unsigned32 maximum_semaphores;
unsigned32 maximum_message_queues;
unsigned32 maximum_messages;
unsigned32 maximum_partitions;
unsigned32 maximum_regions;
unsigned32 maximum_ports;
unsigned32 maximum_periods;
unsigned32 maximum_extensions;
unsigned32 microseconds_per_tick;
unsigned32 ticks_per_timeslice;
unsigned32 number_of_initialization_tasks;
void *work_space_start;
unsigned32 work_space_size;
unsigned32 maximum_tasks;
unsigned32 maximum_timers;
unsigned32 maximum_semaphores;
unsigned32 maximum_message_queues;
unsigned32 maximum_partitions;
unsigned32 maximum_regions;
unsigned32 maximum_ports;
unsigned32 maximum_periods;
unsigned32 maximum_extensions;
unsigned32 microseconds_per_tick;
unsigned32 ticks_per_timeslice;
unsigned32 number_of_initialization_tasks;
rtems_initialization_tasks_table *User_initialization_tasks_table;
unsigned32 number_of_device_drivers;
unsigned32 number_of_device_drivers;
rtems_driver_address_table *Device_driver_table;
rtems_extensions_table *User_extension_table;
rtems_extensions_table *User_extension_table;
rtems_multiprocessing_table *User_multiprocessing_table;
};
@@ -244,7 +241,7 @@ extern const rtems_multiprocessing_table
* configuration information.
*/
EXTERN rtems_configuration_table *_Configuration_Table;
EXTERN rtems_configuration_table *_Configuration_Table;
EXTERN rtems_multiprocessing_table *_Configuration_MP_table;
EXTERN rtems_mpci_table *_Configuration_MPCI_table;
@@ -258,7 +255,7 @@ EXTERN rtems_mpci_table *_Configuration_MPCI_table;
*/
STATIC INLINE void _Configuration_Handler_initialization(
rtems_configuration_table *configuration_table,
rtems_configuration_table *configuration_table,
rtems_multiprocessing_table *multiprocessing_table,
rtems_mpci_table *users_mpci_table
);
+21 -15
View File
@@ -10,10 +10,12 @@
* This material may be reproduced by or for the U.S. Government pursuant
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
* $Id$
*/
#ifndef __RTEMS_DIRECTIVES_h
#define RTEMS___DIRECTIVES_h
#define __RTEMS_DIRECTIVES_h
#ifdef __cplusplus
extern "C" {
@@ -85,20 +87,24 @@ extern "C" {
#define RTEMS_DUAL_PORTED_MEMORY_EXTERNAL_TO_INTERNAL 63
#define RTEMS_DUAL_PORTED_MEMORY_INTERNAL_TO_EXTERNAL 64
#define RTEMS_IO_INITIALIZE 65
#define RTEMS_IO_OPEN 66
#define RTEMS_IO_CLOSE 67
#define RTEMS_IO_READ 68
#define RTEMS_IO_WRITE 69
#define RTEMS_IO_CONTROL 70
#define RTEMS_FATAL_ERROR_OCCURRED 71
#define RTEMS_RATE_MONOTONIC_CREATE 72
#define RTEMS_RATE_MONOTONIC_NAME_TO_ID 73
#define RTEMS_RATE_MONOTONIC_DELETE 74
#define RTEMS_RATE_MONOTONIC_CANCEL 75
#define RTEMS_RATE_MONOTONIC_PERIOD 76
#define RTEMS_MULTIPROCESSING_ANNOUNCE 77
#define RTEMS_DEBUG_ENABLE 78
#define RTEMS_DEBUG_DISABLE 79
#define RTEMS_IO_REGISTER_NAME 66
#define RTEMS_IO_LOOKUP_NAME 67
#define RTEMS_IO_OPEN 68
#define RTEMS_IO_CLOSE 69
#define RTEMS_IO_READ 70
#define RTEMS_IO_WRITE 71
#define RTEMS_IO_CONTROL 72
#define RTEMS_FATAL_ERROR_OCCURRED 73
#define RTEMS_RATE_MONOTONIC_CREATE 74
#define RTEMS_RATE_MONOTONIC_NAME_TO_ID 75
#define RTEMS_RATE_MONOTONIC_DELETE 76
#define RTEMS_RATE_MONOTONIC_CANCEL 77
#define RTEMS_RATE_MONOTONIC_PERIOD 78
#define RTEMS_MULTIPROCESSING_ANNOUNCE 79
#define RTEMS_DEBUG_ENABLE 80
#define RTEMS_DEBUG_DISABLE 81
#define RTEMS_NUMBER_OF_ENTRY_POINTS 82
#ifdef __cplusplus
}
+55 -45
View File
@@ -34,29 +34,32 @@ extern "C" {
#include <rtems/config.h>
/*
* The following type defines the set of IO operations which are
* recognized by _IO_Handler and can be supported by a RTEMS
* device driver.
*/
typedef enum {
IO_INITIALIZE_OPERATION = 0,
IO_OPEN_OPERATION = 1,
IO_CLOSE_OPERATION = 2,
IO_READ_OPERATION = 3,
IO_WRITE_OPERATION = 4,
IO_CONTROL_OPERATION = 5
} IO_operations;
/*
* The following declare the data required to manage the Device Driver
* Address Table.
*/
EXTERN unsigned32 _IO_Number_of_drivers;
EXTERN unsigned32 _IO_Number_of_drivers;
EXTERN rtems_driver_address_table *_IO_Driver_address_table;
/*
* Table for the io device names
*/
typedef struct {
char *device_name;
unsigned32 device_name_length;
rtems_device_major_number major;
rtems_device_minor_number minor;
} rtems_driver_name_t;
/*XXX this really should be allocated some better way... */
/*XXX it should probably be a chain and use a 'maximum' drivers field
* in config table */
#define RTEMS_MAX_DRIVER_NAMES 20
EXTERN rtems_driver_name_t rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES];
/*
* _IO_Manager_initialization
*
@@ -70,6 +73,36 @@ STATIC INLINE void _IO_Manager_initialization(
unsigned32 number_of_drivers
);
/*
* rtems_io_register_name
*
* DESCRIPTION:
*
* Associate a name with a driver.
*
*/
rtems_status_code rtems_io_register_name(
char *device_name,
rtems_device_major_number major,
rtems_device_minor_number minor
);
/*
* rtems_io_lookup_name
*
* DESCRIPTION:
*
* Find what driver "owns" this name
*/
rtems_status_code rtems_io_lookup_name(
const char *pathname,
rtems_driver_name_t **rnp
);
/*
* rtems_io_initialize
*
@@ -82,8 +115,7 @@ STATIC INLINE void _IO_Manager_initialization(
rtems_status_code rtems_io_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -98,8 +130,7 @@ rtems_status_code rtems_io_initialize(
rtems_status_code rtems_io_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -114,8 +145,7 @@ rtems_status_code rtems_io_open(
rtems_status_code rtems_io_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -130,8 +160,7 @@ rtems_status_code rtems_io_close(
rtems_status_code rtems_io_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -146,8 +175,7 @@ rtems_status_code rtems_io_read(
rtems_status_code rtems_io_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -162,8 +190,7 @@ rtems_status_code rtems_io_write(
rtems_status_code rtems_io_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -177,23 +204,6 @@ rtems_status_code rtems_io_control(
void _IO_Initialize_all_drivers( void );
/*
* _IO_Handler_routine
*
* DESCRIPTION:
*
* This routine provides the common foundation for all of the IO
* Manager's directives.
*/
rtems_status_code _IO_Handler_routine(
IO_operations operation,
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
);
#include <rtems/io.inl>
#ifdef __cplusplus
+17 -15
View File
@@ -49,7 +49,7 @@ const char _RTEMS_version[] =
* This table is used by the single entry point code.
*/
const void * _Entry_points[ NUMBER_OF_ENTRY_POINTS + 1 ] = {
const void * _Entry_points[ RTEMS_NUMBER_OF_ENTRY_POINTS ] = {
(void *) rtems_initialize_executive, /* 0 */
(void *) rtems_initialize_executive_early, /* 1 */
(void *) rtems_initialize_executive_late, /* 2 */
@@ -116,20 +116,22 @@ const void * _Entry_points[ NUMBER_OF_ENTRY_POINTS + 1 ] = {
(void *) rtems_port_external_to_internal, /* 63 */
(void *) rtems_port_internal_to_external, /* 64 */
(void *) rtems_io_initialize, /* 65 */
(void *) rtems_io_open, /* 66 */
(void *) rtems_io_close, /* 67 */
(void *) rtems_io_read, /* 68 */
(void *) rtems_io_write, /* 69 */
(void *) rtems_io_control, /* 70 */
(void *) rtems_fatal_error_occurred, /* 71 */
(void *) rtems_rate_monotonic_create, /* 72 */
(void *) rtems_rate_monotonic_ident, /* 73 */
(void *) rtems_rate_monotonic_delete, /* 74 */
(void *) rtems_rate_monotonic_cancel, /* 75 */
(void *) rtems_rate_monotonic_period, /* 76 */
(void *) rtems_multiprocessing_announce, /* 77 */
(void *) rtems_debug_enable, /* 78 */
(void *) rtems_debug_disable /* 79 */
(void *) rtems_io_register_name, /* 66 */
(void *) rtems_io_lookup_name, /* 67 */
(void *) rtems_io_open, /* 68 */
(void *) rtems_io_close, /* 69 */
(void *) rtems_io_read, /* 70 */
(void *) rtems_io_write, /* 71 */
(void *) rtems_io_control, /* 72 */
(void *) rtems_fatal_error_occurred, /* 73 */
(void *) rtems_rate_monotonic_create, /* 74 */
(void *) rtems_rate_monotonic_ident, /* 75 */
(void *) rtems_rate_monotonic_delete, /* 76 */
(void *) rtems_rate_monotonic_cancel, /* 77 */
(void *) rtems_rate_monotonic_period, /* 78 */
(void *) rtems_multiprocessing_announce, /* 79 */
(void *) rtems_debug_enable, /* 80 */
(void *) rtems_debug_disable /* 81 */
};
#ifdef __cplusplus
+30 -33
View File
@@ -32,14 +32,14 @@ extern "C" {
*/
typedef struct {
Objects_Name name; /* task name */
unsigned32 stack_size; /* task stack size */
Objects_Name name; /* task name */
unsigned32 stack_size; /* task stack size */
rtems_task_priority initial_priority; /* task priority */
rtems_attribute attribute_set; /* task attributes */
rtems_task_entry entry_point; /* task entry point */
rtems_mode mode_set; /* task initial mode */
unsigned32 argument; /* task argument */
} rtems_initialization_tasks_table;
rtems_attribute attribute_set; /* task attributes */
rtems_task_entry entry_point; /* task entry point */
rtems_mode mode_set; /* task initial mode */
unsigned32 argument; /* task argument */
} rtems_initialization_tasks_table;
/*
*
@@ -56,14 +56,12 @@ typedef struct {
typedef unsigned32 rtems_device_major_number;
typedef unsigned32 rtems_device_minor_number;
typedef void rtems_device_driver;
typedef rtems_status_code rtems_device_driver;
typedef rtems_device_driver ( *rtems_device_driver_entry )(
rtems_device_major_number,
rtems_device_minor_number,
void *,
Objects_Id,
unsigned32 *
void *
);
typedef struct {
@@ -173,12 +171,13 @@ typedef rtems_mpci_entry ( *rtems_mpci_receive_entry )(
typedef struct {
unsigned32 default_timeout; /* in ticks */
unsigned32 maximum_packet_size;
rtems_mpci_initialization_entry initialization;
rtems_mpci_get_packet_entry get_packet;
rtems_mpci_return_packet_entry return_packet;
rtems_mpci_send_entry send_packet;
rtems_mpci_receive_entry receive_packet;
} rtems_mpci_table;
} rtems_mpci_table;
/*
* The following records define the Multiprocessor Configuration
@@ -192,8 +191,7 @@ struct Configuration_Table_MP {
unsigned32 maximum_nodes; /* maximum # nodes in system */
unsigned32 maximum_global_objects; /* maximum # global objects */
unsigned32 maximum_proxies; /* maximum # proxies */
rtems_mpci_table *User_mpci_table;
/* pointer to MPCI table */
rtems_mpci_table *User_mpci_table; /* pointer to MPCI table */
};
/*
@@ -209,25 +207,24 @@ struct Configuration_Table_MP {
*/
struct Configuration_Table {
void *work_space_start;
unsigned32 work_space_size;
unsigned32 maximum_tasks;
unsigned32 maximum_timers;
unsigned32 maximum_semaphores;
unsigned32 maximum_message_queues;
unsigned32 maximum_messages;
unsigned32 maximum_partitions;
unsigned32 maximum_regions;
unsigned32 maximum_ports;
unsigned32 maximum_periods;
unsigned32 maximum_extensions;
unsigned32 microseconds_per_tick;
unsigned32 ticks_per_timeslice;
unsigned32 number_of_initialization_tasks;
void *work_space_start;
unsigned32 work_space_size;
unsigned32 maximum_tasks;
unsigned32 maximum_timers;
unsigned32 maximum_semaphores;
unsigned32 maximum_message_queues;
unsigned32 maximum_partitions;
unsigned32 maximum_regions;
unsigned32 maximum_ports;
unsigned32 maximum_periods;
unsigned32 maximum_extensions;
unsigned32 microseconds_per_tick;
unsigned32 ticks_per_timeslice;
unsigned32 number_of_initialization_tasks;
rtems_initialization_tasks_table *User_initialization_tasks_table;
unsigned32 number_of_device_drivers;
unsigned32 number_of_device_drivers;
rtems_driver_address_table *Device_driver_table;
rtems_extensions_table *User_extension_table;
rtems_extensions_table *User_extension_table;
rtems_multiprocessing_table *User_multiprocessing_table;
};
@@ -244,7 +241,7 @@ extern const rtems_multiprocessing_table
* configuration information.
*/
EXTERN rtems_configuration_table *_Configuration_Table;
EXTERN rtems_configuration_table *_Configuration_Table;
EXTERN rtems_multiprocessing_table *_Configuration_MP_table;
EXTERN rtems_mpci_table *_Configuration_MPCI_table;
@@ -258,7 +255,7 @@ EXTERN rtems_mpci_table *_Configuration_MPCI_table;
*/
STATIC INLINE void _Configuration_Handler_initialization(
rtems_configuration_table *configuration_table,
rtems_configuration_table *configuration_table,
rtems_multiprocessing_table *multiprocessing_table,
rtems_mpci_table *users_mpci_table
);
+21 -15
View File
@@ -10,10 +10,12 @@
* This material may be reproduced by or for the U.S. Government pursuant
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
* $Id$
*/
#ifndef __RTEMS_DIRECTIVES_h
#define RTEMS___DIRECTIVES_h
#define __RTEMS_DIRECTIVES_h
#ifdef __cplusplus
extern "C" {
@@ -85,20 +87,24 @@ extern "C" {
#define RTEMS_DUAL_PORTED_MEMORY_EXTERNAL_TO_INTERNAL 63
#define RTEMS_DUAL_PORTED_MEMORY_INTERNAL_TO_EXTERNAL 64
#define RTEMS_IO_INITIALIZE 65
#define RTEMS_IO_OPEN 66
#define RTEMS_IO_CLOSE 67
#define RTEMS_IO_READ 68
#define RTEMS_IO_WRITE 69
#define RTEMS_IO_CONTROL 70
#define RTEMS_FATAL_ERROR_OCCURRED 71
#define RTEMS_RATE_MONOTONIC_CREATE 72
#define RTEMS_RATE_MONOTONIC_NAME_TO_ID 73
#define RTEMS_RATE_MONOTONIC_DELETE 74
#define RTEMS_RATE_MONOTONIC_CANCEL 75
#define RTEMS_RATE_MONOTONIC_PERIOD 76
#define RTEMS_MULTIPROCESSING_ANNOUNCE 77
#define RTEMS_DEBUG_ENABLE 78
#define RTEMS_DEBUG_DISABLE 79
#define RTEMS_IO_REGISTER_NAME 66
#define RTEMS_IO_LOOKUP_NAME 67
#define RTEMS_IO_OPEN 68
#define RTEMS_IO_CLOSE 69
#define RTEMS_IO_READ 70
#define RTEMS_IO_WRITE 71
#define RTEMS_IO_CONTROL 72
#define RTEMS_FATAL_ERROR_OCCURRED 73
#define RTEMS_RATE_MONOTONIC_CREATE 74
#define RTEMS_RATE_MONOTONIC_NAME_TO_ID 75
#define RTEMS_RATE_MONOTONIC_DELETE 76
#define RTEMS_RATE_MONOTONIC_CANCEL 77
#define RTEMS_RATE_MONOTONIC_PERIOD 78
#define RTEMS_MULTIPROCESSING_ANNOUNCE 79
#define RTEMS_DEBUG_ENABLE 80
#define RTEMS_DEBUG_DISABLE 81
#define RTEMS_NUMBER_OF_ENTRY_POINTS 82
#ifdef __cplusplus
}
+55 -45
View File
@@ -34,29 +34,32 @@ extern "C" {
#include <rtems/config.h>
/*
* The following type defines the set of IO operations which are
* recognized by _IO_Handler and can be supported by a RTEMS
* device driver.
*/
typedef enum {
IO_INITIALIZE_OPERATION = 0,
IO_OPEN_OPERATION = 1,
IO_CLOSE_OPERATION = 2,
IO_READ_OPERATION = 3,
IO_WRITE_OPERATION = 4,
IO_CONTROL_OPERATION = 5
} IO_operations;
/*
* The following declare the data required to manage the Device Driver
* Address Table.
*/
EXTERN unsigned32 _IO_Number_of_drivers;
EXTERN unsigned32 _IO_Number_of_drivers;
EXTERN rtems_driver_address_table *_IO_Driver_address_table;
/*
* Table for the io device names
*/
typedef struct {
char *device_name;
unsigned32 device_name_length;
rtems_device_major_number major;
rtems_device_minor_number minor;
} rtems_driver_name_t;
/*XXX this really should be allocated some better way... */
/*XXX it should probably be a chain and use a 'maximum' drivers field
* in config table */
#define RTEMS_MAX_DRIVER_NAMES 20
EXTERN rtems_driver_name_t rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES];
/*
* _IO_Manager_initialization
*
@@ -70,6 +73,36 @@ STATIC INLINE void _IO_Manager_initialization(
unsigned32 number_of_drivers
);
/*
* rtems_io_register_name
*
* DESCRIPTION:
*
* Associate a name with a driver.
*
*/
rtems_status_code rtems_io_register_name(
char *device_name,
rtems_device_major_number major,
rtems_device_minor_number minor
);
/*
* rtems_io_lookup_name
*
* DESCRIPTION:
*
* Find what driver "owns" this name
*/
rtems_status_code rtems_io_lookup_name(
const char *pathname,
rtems_driver_name_t **rnp
);
/*
* rtems_io_initialize
*
@@ -82,8 +115,7 @@ STATIC INLINE void _IO_Manager_initialization(
rtems_status_code rtems_io_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -98,8 +130,7 @@ rtems_status_code rtems_io_initialize(
rtems_status_code rtems_io_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -114,8 +145,7 @@ rtems_status_code rtems_io_open(
rtems_status_code rtems_io_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -130,8 +160,7 @@ rtems_status_code rtems_io_close(
rtems_status_code rtems_io_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -146,8 +175,7 @@ rtems_status_code rtems_io_read(
rtems_status_code rtems_io_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -162,8 +190,7 @@ rtems_status_code rtems_io_write(
rtems_status_code rtems_io_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
);
/*
@@ -177,23 +204,6 @@ rtems_status_code rtems_io_control(
void _IO_Initialize_all_drivers( void );
/*
* _IO_Handler_routine
*
* DESCRIPTION:
*
* This routine provides the common foundation for all of the IO
* Manager's directives.
*/
rtems_status_code _IO_Handler_routine(
IO_operations operation,
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
);
#include <rtems/io.inl>
#ifdef __cplusplus
+17 -15
View File
@@ -49,7 +49,7 @@ const char _RTEMS_version[] =
* This table is used by the single entry point code.
*/
const void * _Entry_points[ NUMBER_OF_ENTRY_POINTS + 1 ] = {
const void * _Entry_points[ RTEMS_NUMBER_OF_ENTRY_POINTS ] = {
(void *) rtems_initialize_executive, /* 0 */
(void *) rtems_initialize_executive_early, /* 1 */
(void *) rtems_initialize_executive_late, /* 2 */
@@ -116,20 +116,22 @@ const void * _Entry_points[ NUMBER_OF_ENTRY_POINTS + 1 ] = {
(void *) rtems_port_external_to_internal, /* 63 */
(void *) rtems_port_internal_to_external, /* 64 */
(void *) rtems_io_initialize, /* 65 */
(void *) rtems_io_open, /* 66 */
(void *) rtems_io_close, /* 67 */
(void *) rtems_io_read, /* 68 */
(void *) rtems_io_write, /* 69 */
(void *) rtems_io_control, /* 70 */
(void *) rtems_fatal_error_occurred, /* 71 */
(void *) rtems_rate_monotonic_create, /* 72 */
(void *) rtems_rate_monotonic_ident, /* 73 */
(void *) rtems_rate_monotonic_delete, /* 74 */
(void *) rtems_rate_monotonic_cancel, /* 75 */
(void *) rtems_rate_monotonic_period, /* 76 */
(void *) rtems_multiprocessing_announce, /* 77 */
(void *) rtems_debug_enable, /* 78 */
(void *) rtems_debug_disable /* 79 */
(void *) rtems_io_register_name, /* 66 */
(void *) rtems_io_lookup_name, /* 67 */
(void *) rtems_io_open, /* 68 */
(void *) rtems_io_close, /* 69 */
(void *) rtems_io_read, /* 70 */
(void *) rtems_io_write, /* 71 */
(void *) rtems_io_control, /* 72 */
(void *) rtems_fatal_error_occurred, /* 73 */
(void *) rtems_rate_monotonic_create, /* 74 */
(void *) rtems_rate_monotonic_ident, /* 75 */
(void *) rtems_rate_monotonic_delete, /* 76 */
(void *) rtems_rate_monotonic_cancel, /* 77 */
(void *) rtems_rate_monotonic_period, /* 78 */
(void *) rtems_multiprocessing_announce, /* 79 */
(void *) rtems_debug_enable, /* 80 */
(void *) rtems_debug_disable /* 81 */
};
#ifdef __cplusplus
+23 -23
View File
@@ -23,11 +23,27 @@ void _IO_Initialize_all_drivers( void )
{
}
rtems_status_code rtems_io_register_name(
char *device_name,
rtems_device_major_number major,
rtems_device_minor_number minor
)
{
return RTEMS_NOT_CONFIGURED;
}
rtems_status_code rtems_io_lookup_name(
const char *pathname,
rtems_driver_name_t **rnp
)
{
return RTEMS_NOT_CONFIGURED;
}
rtems_status_code rtems_io_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -36,8 +52,7 @@ rtems_status_code rtems_io_initialize(
rtems_status_code rtems_io_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -46,8 +61,7 @@ rtems_status_code rtems_io_open(
rtems_status_code rtems_io_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -56,8 +70,7 @@ rtems_status_code rtems_io_close(
rtems_status_code rtems_io_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -66,8 +79,7 @@ rtems_status_code rtems_io_read(
rtems_status_code rtems_io_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return( RTEMS_NOT_CONFIGURED );
@@ -76,19 +88,7 @@ rtems_status_code rtems_io_write(
rtems_status_code rtems_io_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
)
{
return( RTEMS_NOT_CONFIGURED );
}
rtems_status_code _IO_Handler_routine(
IO_operations operation,
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return( RTEMS_NOT_CONFIGURED );
+1 -2
View File
@@ -177,8 +177,7 @@ rtems_interrupt_level rtems_initialize_executive_early(
_Event_Manager_initialization();
_Message_queue_Manager_initialization(
configuration_table->maximum_message_queues,
configuration_table->maximum_messages
configuration_table->maximum_message_queues
);
_Semaphore_Manager_initialization(
+123 -145
View File
@@ -18,6 +18,9 @@
#include <rtems/io.h>
#include <rtems/isr.h>
#include <rtems/thread.h>
#include <rtems/intr.h>
#include <string.h>
/*PAGE
*
@@ -33,12 +36,82 @@
void _IO_Initialize_all_drivers( void )
{
rtems_device_major_number major;
unsigned32 ignored;
for ( major=0 ; major < _IO_Number_of_drivers ; major ++ )
(void) rtems_io_initialize( major, 0, _Configuration_Table, &ignored );
(void) rtems_io_initialize( major, 0, _Configuration_Table);
}
/*PAGE
*
* rtems_io_register_name
*
* Associate a name with a driver
*
* Input Paramters:
*
* Output Parameters:
*/
rtems_status_code rtems_io_register_name(
char *device_name,
rtems_device_major_number major,
rtems_device_minor_number minor
)
{
rtems_driver_name_t *np;
unsigned32 level;
/* find an empty slot */
for (np = rtems_driver_name_table; np < &rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES]; np++)
{
rtems_interrupt_disable(level);
if (np->device_name == 0)
{
np->device_name = device_name;
np->device_name_length = strlen(device_name);
np->major = major;
np->minor = minor;
rtems_interrupt_enable(level);
return RTEMS_SUCCESSFUL;
}
rtems_interrupt_enable(level);
}
return RTEMS_TOO_MANY;
}
/*PAGE
*
* rtems_io_lookup_name
*
* Find what driver "owns" this name
*
* Input Paramters:
*
* Output Parameters:
*/
rtems_status_code rtems_io_lookup_name(
const char *pathname,
rtems_driver_name_t **rnp
)
{
rtems_driver_name_t *np;
for (np = rtems_driver_name_table; np < &rtems_driver_name_table[RTEMS_MAX_DRIVER_NAMES]; np++)
if (np->device_name)
if (strncmp(np->device_name, pathname, np->device_name_length) == 0)
{
*rnp = np;
return RTEMS_SUCCESSFUL;
}
*rnp = 0;
return RTEMS_UNSATISFIED;
}
/*PAGE
*
* rtems_io_initialize
@@ -49,27 +122,24 @@ void _IO_Initialize_all_drivers( void )
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code rtems_io_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return _IO_Handler_routine(
IO_INITIALIZE_OPERATION,
major,
minor,
argument,
return_value
);
rtems_device_driver_entry callout;
if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;
callout = _IO_Driver_address_table[major].initialization;
return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -82,27 +152,24 @@ rtems_status_code rtems_io_initialize(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code rtems_io_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return _IO_Handler_routine(
IO_OPEN_OPERATION,
major,
minor,
argument,
return_value
);
rtems_device_driver_entry callout;
if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;
callout = _IO_Driver_address_table[major].open;
return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -115,27 +182,24 @@ rtems_status_code rtems_io_open(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code rtems_io_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return _IO_Handler_routine(
IO_CLOSE_OPERATION,
major,
minor,
argument,
return_value
);
rtems_device_driver_entry callout;
if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;
callout = _IO_Driver_address_table[major].close;
return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -148,27 +212,24 @@ rtems_status_code rtems_io_close(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code rtems_io_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return _IO_Handler_routine(
IO_READ_OPERATION,
major,
minor,
argument,
return_value
);
rtems_device_driver_entry callout;
if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;
callout = _IO_Driver_address_table[major].read;
return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -181,27 +242,24 @@ rtems_status_code rtems_io_read(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code rtems_io_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return _IO_Handler_routine(
IO_WRITE_OPERATION,
major,
minor,
argument,
return_value
);
rtems_device_driver_entry callout;
if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;
callout = _IO_Driver_address_table[major].write;
return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
@@ -214,103 +272,23 @@ rtems_status_code rtems_io_write(
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code rtems_io_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
void *argument
)
{
return _IO_Handler_routine(
IO_CONTROL_OPERATION,
major,
minor,
argument,
return_value
);
rtems_device_driver_entry callout;
if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;
callout = _IO_Driver_address_table[major].control;
return callout ? callout(major, minor, argument) : RTEMS_SUCCESSFUL;
}
/*PAGE
*
* _IO_Handler_routine
*
* This routine implements all IO manager directives.
*
* Input Paramters:
* operation - I/O operation to be performed
* major - device driver number
* minor - device number
* argument - pointer to argument(s)
* return_value - pointer to driver's return value
*
* Output Parameters:
* returns - return code
* *return_value - driver's return code
*/
rtems_status_code _IO_Handler_routine(
IO_operations operation,
rtems_device_major_number major,
rtems_device_minor_number minor,
void *argument,
unsigned32 *return_value
)
{
rtems_device_driver_entry io_callout;
/*
* NOTE: There is no range checking as in Ada because:
* + arrays in Ada are not always zero based.
* + with zero based arrays, a comparison of an unsigned
* number being less than zero would be necessary to
* check it as a range. This would cause a warning for
* checking an unsigned number for being negative.
*/
if ( major >= _IO_Number_of_drivers )
return ( RTEMS_INVALID_NUMBER );
switch ( operation ) {
case IO_INITIALIZE_OPERATION:
io_callout = _IO_Driver_address_table[ major ].initialization;
break;
case IO_OPEN_OPERATION:
io_callout = _IO_Driver_address_table[ major ].open;
break;
case IO_CLOSE_OPERATION:
io_callout = _IO_Driver_address_table[ major ].close;
break;
case IO_READ_OPERATION:
io_callout = _IO_Driver_address_table[ major ].read;
break;
case IO_WRITE_OPERATION:
io_callout = _IO_Driver_address_table[ major ].write;
break;
case IO_CONTROL_OPERATION:
io_callout = _IO_Driver_address_table[ major ].control;
break;
default: /* unreached -- only to remove warnings */
io_callout = NULL;
break;
}
if ( io_callout != NULL )
(*io_callout)(
major,
minor,
argument,
_Thread_Executing->Object.id,
return_value
);
else
*return_value = 0;
return( RTEMS_SUCCESSFUL );
}
+28
View File
@@ -99,6 +99,18 @@ EXTERN unsigned32 _Objects_Local_node;
#define RTEMS_SEARCH_LOCAL_NODE 0x7FFFFFFF
#define RTEMS_WHO_AM_I 0
/*
* Parameters and return id's for _Objects_Get_next
*/
#define RTEMS_OBJECT_ID_INITIAL_INDEX (0)
#define RTEMS_OBJECT_ID_FINAL_INDEX (0xffff)
#define RTEMS_OBJECT_ID_INITIAL(node) (_Objects_Build_id( \
node, \
RTEMS_OBJECT_ID_INITIAL_INDEX))
#define RTEMS_OBJECT_ID_FINAL ((Objects_Id) ~0)
/*
* _Objects_Handler_initialization
*
@@ -178,6 +190,22 @@ Objects_Control *_Objects_Get (
Objects_Locations *location
);
/*
* _Objects_Get_next
*
* DESCRIPTION:
*
* Like _Objects_Get, but is used to find "next" open object.
*
*/
Objects_Control *_Objects_Get_next(
Objects_Information *information,
Objects_Id id,
unsigned32 *location_p,
Objects_Id *next_id_p
);
/*
* _Objects_Is_name_valid
*
+5 -2
View File
@@ -78,6 +78,7 @@ typedef void * proc_ptr;
#include <rtems/cpu.h> /* processor specific information */
#include <rtems/status.h> /* RTEMS status codes */
#include <rtems/directives.h>
/*
* Define NULL
@@ -103,6 +104,9 @@ typedef void * proc_ptr;
#define stringify( _x ) # _x
#define RTEMS_offsetof(type, field) \
((unsigned32) &(((type *) 0)->field))
/*
* The following is the extern for the RTEMS version string.
* The contents of this string are CPU specific.
@@ -115,8 +119,7 @@ extern const char _Copyright_Notice[]; /* RTEMS copyright string */
* The jump table of entry points into RTEMS directives.
*/
#define NUMBER_OF_ENTRY_POINTS 79
extern const void * _Entry_points[ NUMBER_OF_ENTRY_POINTS + 1 ];
extern const void * _Entry_points[ RTEMS_NUMBER_OF_ENTRY_POINTS ];
/*
* The following defines the CPU dependent information table.
+1
View File
@@ -115,6 +115,7 @@ typedef struct {
union {
unsigned32 segment_size; /* size of segment requested */
rtems_event_set event_condition;
unsigned32 *message_size_p; /* ptr for return size of message */
} Extra;
void *return_argument; /* address of user return param */
rtems_status_code return_code; /* status for thread awakened */
@@ -99,6 +99,18 @@ EXTERN unsigned32 _Objects_Local_node;
#define RTEMS_SEARCH_LOCAL_NODE 0x7FFFFFFF
#define RTEMS_WHO_AM_I 0
/*
* Parameters and return id's for _Objects_Get_next
*/
#define RTEMS_OBJECT_ID_INITIAL_INDEX (0)
#define RTEMS_OBJECT_ID_FINAL_INDEX (0xffff)
#define RTEMS_OBJECT_ID_INITIAL(node) (_Objects_Build_id( \
node, \
RTEMS_OBJECT_ID_INITIAL_INDEX))
#define RTEMS_OBJECT_ID_FINAL ((Objects_Id) ~0)
/*
* _Objects_Handler_initialization
*
@@ -178,6 +190,22 @@ Objects_Control *_Objects_Get (
Objects_Locations *location
);
/*
* _Objects_Get_next
*
* DESCRIPTION:
*
* Like _Objects_Get, but is used to find "next" open object.
*
*/
Objects_Control *_Objects_Get_next(
Objects_Information *information,
Objects_Id id,
unsigned32 *location_p,
Objects_Id *next_id_p
);
/*
* _Objects_Is_name_valid
*
@@ -115,6 +115,7 @@ typedef struct {
union {
unsigned32 segment_size; /* size of segment requested */
rtems_event_set event_condition;
unsigned32 *message_size_p; /* ptr for return size of message */
} Extra;
void *return_argument; /* address of user return param */
rtems_status_code return_code; /* status for thread awakened */
+5 -2
View File
@@ -78,6 +78,7 @@ typedef void * proc_ptr;
#include <rtems/cpu.h> /* processor specific information */
#include <rtems/status.h> /* RTEMS status codes */
#include <rtems/directives.h>
/*
* Define NULL
@@ -103,6 +104,9 @@ typedef void * proc_ptr;
#define stringify( _x ) # _x
#define RTEMS_offsetof(type, field) \
((unsigned32) &(((type *) 0)->field))
/*
* The following is the extern for the RTEMS version string.
* The contents of this string are CPU specific.
@@ -115,8 +119,7 @@ extern const char _Copyright_Notice[]; /* RTEMS copyright string */
* The jump table of entry points into RTEMS directives.
*/
#define NUMBER_OF_ENTRY_POINTS 79
extern const void * _Entry_points[ NUMBER_OF_ENTRY_POINTS + 1 ];
extern const void * _Entry_points[ RTEMS_NUMBER_OF_ENTRY_POINTS ];
/*
* The following defines the CPU dependent information table.
+67
View File
@@ -12,6 +12,7 @@
*
* $Id$
*/
#include <rtems/system.h>
#include <rtems/chain.h>
#include <rtems/config.h>
@@ -226,3 +227,69 @@ Objects_Control *_Objects_Get(
_Objects_MP_Is_remote( information, id, location, &the_object );
return the_object;
}
/*PAGE
*
* _Objects_Get_next
*
* Like _Objects_Get, but considers the 'id' as a "hint" and
* finds next valid one after that point.
* Mostly used for monitor and debug traversal of an object.
*
* Input parameters:
* information - pointer to entry in table for this class
* id - object id to search for
* location - address of where to store the location
* next_id - address to store next id to try
*
* Output parameters:
* returns - address of object if local
* location - one of the following:
* OBJECTS_ERROR - invalid object ID
* OBJECTS_REMOTE - remote object
* OBJECTS_LOCAL - local object
* next_id - will contain a reasonable "next" id to continue traversal
*
* NOTE:
* assumes can add '1' to an id to get to next index.
*/
Objects_Control *
_Objects_Get_next(
Objects_Information *information,
Objects_Id id,
unsigned32 *location_p,
Objects_Id *next_id_p
)
{
Objects_Control *object;
Objects_Id next_id;
if (rtems_get_index(id) == RTEMS_OBJECT_ID_INITIAL_INDEX)
next_id = information->minimum_id;
else
next_id = id;
do {
/* walked off end of list? */
if (next_id > information->maximum_id)
{
*location_p = OBJECTS_ERROR;
goto final;
}
/* try to grab one */
object = _Objects_Get(information, next_id, location_p);
next_id++;
} while (*location_p != OBJECTS_LOCAL);
*next_id_p = next_id;
return object;
final:
*next_id_p = RTEMS_OBJECT_ID_FINAL;
return 0;
}
+12 -19
View File
@@ -23,31 +23,24 @@ extern "C" {
/* variables */
extern volatile rtems_unsigned32 Clock_driver_ticks;
extern rtems_device_major_number rtems_clock_major;
extern rtems_device_minor_number rtems_clock_minor;
/* functions */
rtems_task Exit_task();
void exit_task_init();
void Install_clock( rtems_isr_entry );
void ReInstall_clock( rtems_isr_entry );
void Clock_exit();
rtems_isr Clock_isr(
rtems_vector_number
);
/* driver entries */
/* default clock driver entry */
#define CLOCK_DRIVER_TABLE_ENTRY \
{ Clock_initialize, NULL, NULL, NULL, NULL, NULL }
{ Clock_initialize, NULL, NULL, NULL, NULL, Clock_control }
rtems_device_driver Clock_initialize(
rtems_device_major_number,
rtems_device_minor_number,
void *,
rtems_id,
rtems_unsigned32 *
void *
);
rtems_device_driver Clock_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
);
#ifdef __cplusplus
+44
View File
@@ -0,0 +1,44 @@
/*
* @(#)assoc.h 1.2 - 95/06/28
*
*
* Rtems associativity routines. Mainly used to convert a value from
* one space to another (eg: our errno's to host errno's and v.v)
*
*
* $Id$
*/
#ifndef _INCLUDE_ASSOC_H
#define _INCLUDE_ASSOC_H
typedef struct {
char *name;
unsigned32 local_value;
unsigned32 remote_value;
} rtems_assoc_t;
/*
* Flag/marker for optional default value in each table
*/
#define RTEMS_ASSOC_DEFAULT_NAME "(default)"
rtems_assoc_t *rtems_assoc_ptr_by_name(rtems_assoc_t *, char *);
rtems_assoc_t *rtems_assoc_ptr_by_value(rtems_assoc_t *, unsigned32);
rtems_assoc_t *rtems_assoc_ptr_by_remote(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_remote_by_local(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_local_by_remote(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_remote_by_name(rtems_assoc_t *, char *);
unsigned32 rtems_assoc_local_by_name(rtems_assoc_t *, char *);
char *rtems_assoc_name_by_local(rtems_assoc_t *, unsigned32);
char *rtems_assoc_name_by_remote(rtems_assoc_t *, unsigned32);
unsigned32 rtems_assoc_remote_by_local_bitfield(rtems_assoc_t *, unsigned32);
char *rtems_assoc_name_by_local_bitfield(rtems_assoc_t *, unsigned32, char *);
char *rtems_assoc_name_by_remote_bitfield(rtems_assoc_t *, unsigned32, char *);
unsigned32 rtems_assoc_local_by_remote_bitfield(rtems_assoc_t *ap, unsigned32);
#endif /* ! _INCLUDE_ASSOC_H */
+26
View File
@@ -0,0 +1,26 @@
/*
* @(#)error.h 1.1 - 95/08/02
*
*
* Defines and externs for rtems error reporting
*
* $Id$
*/
/*
* rtems_error() and rtems_panic() support
*/
#define RTEMS_ERROR_ERRNO (1<<((sizeof(int) * 8) - 2)) /* hi bit; use 'errno' */
#define RTEMS_ERROR_PANIC (RTEMS_ERROR_ERRNO / 2) /* err fatal; no return */
#define RTEMS_ERROR_ABORT (RTEMS_ERROR_ERRNO / 4) /* err is fatal; panic */
#define RTEMS_ERROR_MASK (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | \
RTEMS_ERROR_PANIC) /* all */
char *rtems_status_text(rtems_status_code);
int rtems_error(int error_code, char *printf_format, ...);
void rtems_panic(char *printf_format, ...);
extern int rtems_panic_in_progress;
+101
View File
@@ -0,0 +1,101 @@
/*
* @(#)libio.h 1.1 - 95/06/02
*
*
* General purpose communication channel for RTEMS to allow UNIX/POSIX
* system call behavior on top of RTEMS IO devices.
*
* TODO
* stat(2)
* unlink(2)
* rename(2)
*
* $Id$
*/
#ifndef _RTEMS_LIBIO_H
#define _RTEMS_LIBIO_H
typedef unsigned32 rtems_libio_offset_t;
/*
* An open file data structure, indexed by 'fd'
* TODO:
* should really have a separate per/file data structure that this
* points to (eg: size, offset, driver, pathname should be in that)
*/
typedef struct {
rtems_driver_name_t *driver;
rtems_libio_offset_t size; /* size of file */
rtems_libio_offset_t offset; /* current offset into the file */
unsigned32 flags;
char *pathname; /* opened pathname */
Objects_Id sem;
unsigned32 data0; /* private to "driver" */
unsigned32 data1; /* ... */
} rtems_libio_t;
/*
* param block for read/write
* Note: it must include 'offset' instead of using iop's offset since
* we can have multiple outstanding i/o's on a device.
*/
typedef struct {
rtems_libio_t *iop;
rtems_libio_offset_t offset;
unsigned8 *buffer;
unsigned32 count;
unsigned32 flags;
unsigned32 bytes_moved;
} rtems_libio_rw_args_t;
/*
* param block for open/close
*/
typedef struct {
rtems_libio_t *iop;
unsigned32 flags;
unsigned32 mode;
} rtems_libio_open_close_args_t;
/*
* param block for ioctl
*/
typedef struct {
rtems_libio_t *iop;
unsigned32 command;
void *buffer;
unsigned32 ioctl_return;
} rtems_libio_ioctl_args_t;
/*
* Values for 'flag'
*/
#define LIBIO_FLAGS_NO_DELAY 0x0001 /* return immediately if no data */
#define LIBIO_FLAGS_READ 0x0002 /* reading */
#define LIBIO_FLAGS_WRITE 0x0004 /* writing */
#define LIBIO_FLAGS_LINE_BUFFERED 0x0008 /* line buffered io (^h, ^u, etc) */
#define LIBIO_FLAGS_OPEN 0x0100 /* device is open */
#define LIBIO_FLAGS_APPEND 0x0200 /* all writes append */
#define LIBIO_FLAGS_CREATE 0x0400 /* create file */
#define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
void rtems_libio_config(rtems_configuration_table *config, unsigned32 max_fds);
void rtems_libio_init(void);
int __open(const char *pathname, unsigned32 flag, unsigned32 mode);
int __close(int fd);
int __read(int fd, void *buffer, unsigned32 count);
int __write(int fd, const void *buffer, unsigned32 count);
int __ioctl(int fd, unsigned32 command, void *buffer);
int __lseek(int fd, rtems_libio_offset_t offset, int whence);
#endif /* _RTEMS_LIBIO_H */
+30 -1
View File
@@ -21,7 +21,9 @@ extern "C" {
#endif
#include <rtems.h>
#include <iosupp.h>
#include <clockdrv.h>
#include <rtems/ttydrv.h>
#include <libcsupport.h>
/*
* Define the time limits for RTEMS Test Suite test durations.
@@ -64,6 +66,18 @@ extern void Clock_delay(rtems_unsigned32 microseconds);
#define delay( microseconds ) \
Clock_delay(microseconds);
/*
* Todo: this should be put somewhere else
*/
#undef CLOCK_DRIVER_TABLE_ENTRY
#define CLOCK_DRIVER_TABLE_ENTRY { Clock_initialize, NULL, NULL, NULL, NULL, Clock_control }
rtems_device_driver Clock_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
);
/*
* We printf() to a buffer if multiprocessing, *or* if this is set.
* ref: src/lib/libbsp/hppa/simhppa/iosupp/consupp.c
@@ -71,8 +85,23 @@ extern void Clock_delay(rtems_unsigned32 microseconds);
extern int use_print_buffer;
/*
* When not doing printf to a buffer, we do printf thru RTEMS libio
* and our tty driver. Set it up so that console is right.
*/
#define CONSOLE_DRIVER_TABLE_ENTRY \
{ tty_initialize, tty_open, tty_close, tty_read, tty_write, tty_control }
/*
* How many libio files we want
*/
#define BSP_LIBIO_MAX_FDS 20
#define HPPA_INTERRUPT_EXTERNAL_MPCI HPPA_INTERRUPT_EXTERNAL_10
rtems_isr_entry set_vector(rtems_isr_entry, rtems_vector_number, int);
void bsp_start( void );
void bsp_cleanup( void );
@@ -1,6 +1,5 @@
/*
* @(#)bspstart.c 1.14 - 95/05/16
*
* @(#)bspstart.c 1.16 - 95/06/28
*/
/* bsp_start()
@@ -24,13 +23,17 @@
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
* bspstart.c,v 1.2 1995/05/09 20:17:33 joel Exp
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include <rtems/libio.h>
#include <libcsupport.h>
#include <string.h>
#include <fcntl.h>
#ifdef STACK_CHECKER_ON
#include <stackchk.h>
@@ -127,8 +130,17 @@ bsp_libc_init(void)
RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
/*
* Init the RTEMS libio facility to provide UNIX-like system
* calls for use by newlib (ie: provide __open, __close, etc)
* Uses malloc() to get area for the iops, so must be after malloc init
*/
rtems_libio_init();
/*
* Set up for the libc handling.
* XXX; this should allow for case of some other non-clock interrupts
*/
if (BSP_Configuration.ticks_per_timeslice > 0)
@@ -219,6 +231,32 @@ bsp_pretasking_hook(void)
#endif
}
/*
* After drivers are setup, register some "filenames"
* and open stdin, stdout, stderr files
*
* Newlib will automatically associate the files with these
* (it hardcodes the numbers)
*/
void
bsp_postdriver_hook(void)
{
int stdin_fd, stdout_fd, stderr_fd;
if ((stdin_fd = __open("/dev/tty00", O_RDONLY, 0)) == -1)
rtems_fatal_error_occurred('STD0');
if ((stdout_fd = __open("/dev/tty00", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred('STD1');
if ((stderr_fd = __open("/dev/tty00", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred('STD2');
if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
rtems_fatal_error_occurred('STIO');
}
/*
* Function: bsp_start
* Created: 94/12/6
@@ -289,7 +327,7 @@ bsp_start(void)
Cpu_table.predriver_hook = NULL;
Cpu_table.postdriver_hook = NULL;
Cpu_table.postdriver_hook = bsp_postdriver_hook; /* register drivers */
Cpu_table.idle_task = NULL; /* do not override system IDLE task */
@@ -342,21 +380,27 @@ bsp_start(void)
#endif
#ifdef STACK_CHECKER_ON
/*
* Add 1 extension for stack checker
*/
/*
* Add 1 extension for stack checker
*/
BSP_Configuration.maximum_extensions++;
#endif
#if SIMHPPA_FAST_IDLE
/*
* Add 1 extension for fast idle
*/
/*
* Add 1 extension for fast idle
*/
BSP_Configuration.maximum_extensions++;
#endif
/*
* Tell libio how many fd's we want and allow it to tweak config
*/
rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
/*
* Add 1 extension for MPCI_fatal
*/
+12 -11
View File
@@ -16,20 +16,24 @@
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
* poll.c,v 1.2 1995/05/09 20:22:57 joel Exp
* $Id$
*/
#include <rtems.h>
#include <rtems/sysstate.h>
#include <rtems/libio.h>
#include "shm.h"
#include "clockdrv.h"
void Shm_Poll()
{
rtems_unsigned32 tmpfront;
rtems_libio_ioctl_args_t args;
Clock_isr( 0 ); /* invoke standard clock ISR */
/* invoke clock isr */
args.iop = 0;
args.command = rtems_build_name('I', 'S', 'R', ' ');
(void) rtems_io_control(rtems_clock_major, rtems_clock_minor, &args);
/*
* Check for msgs only if we are "up"
@@ -39,14 +43,11 @@ void Shm_Poll()
if (_System_state_Is_up(_System_state_Get()))
{
/* enable_tracing(); */
/* ticks += 1; */
Shm_Lock( Shm_Local_receive_queue );
tmpfront = Shm_Local_receive_queue->front;
Shm_Unlock( Shm_Local_receive_queue );
if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list ) {
rtems_multiprocessing_announce();
Shm_Interrupt_count++;
if ( Shm_Convert(tmpfront) != Shm_Locked_queue_End_of_list )
{
rtems_multiprocessing_announce();
Shm_Interrupt_count++;
}
}
}
+8 -2
View File
@@ -19,10 +19,16 @@
*/
#include <rtems.h>
#include <rtems/libio.h>
#include "shm.h"
#include "clockdrv.h"
rtems_isr Shm_setclockvec()
{
ReInstall_clock( Shm_Poll );
rtems_libio_ioctl_args_t args;
args.iop = 0;
args.command = rtems_build_name('N', 'E', 'W', ' ');
args.buffer = (void *) Shm_Poll;
(void) rtems_io_control(rtems_clock_major, rtems_clock_minor, &args);
}
+3
View File
@@ -20,6 +20,8 @@
#ifndef __SHM_h
#define __SHM_h
#include <clockdrv.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -518,6 +520,7 @@ extern rtems_mpci_table MPCI_table;
rtems_mpci_table MPCI_table = {
100000, /* default timeout value in ticks */
MAX_PACKET_SIZE, /* maximum packet size */
Shm_Initialization, /* initialization procedure */
Shm_Get_packet, /* get packet procedure */
Shm_Return_packet, /* return packet procedure */
+3
View File
@@ -20,6 +20,8 @@
#ifndef __SHM_h
#define __SHM_h
#include <clockdrv.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -518,6 +520,7 @@ extern rtems_mpci_table MPCI_table;
rtems_mpci_table MPCI_table = {
100000, /* default timeout value in ticks */
MAX_PACKET_SIZE, /* maximum packet size */
Shm_Initialization, /* initialization procedure */
Shm_Get_packet, /* get packet procedure */
Shm_Return_packet, /* return packet procedure */
+82 -43
View File
@@ -1,7 +1,7 @@
/* Clock
*
* This routine initializes the interval timer on the
* PA-RISC CPU. The tick frequency is specified by the bsp.
* This routine generates clock ticks using standard POSIX services.
* The tick frequency is specified by the bsp.
*
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
* On-Line Applications Research Corporation (OAR).
@@ -15,62 +15,44 @@
*/
#include <rtems.h>
#include <rtems/libio.h>
#include <bsp.h>
/*
* In order to get the types and prototypes used in this file under
* Solaris 2.3, it is necessary to pull the following magic.
*/
#if defined(solaris)
#warning "Ignore the undefining __STDC__ warning"
#undef __STDC__
#define __STDC__ 0
#undef _POSIX_C_SOURCE
#endif
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
extern rtems_configuration_table Configuration;
extern sigset_t UNIX_SIGNAL_MASK;
/*
* Function prototypes
*/
void Install_clock();
void Clock_isr();
void Clock_exit();
/*
* CPU_HPPA_CLICKS_PER_TICK is either a #define or an rtems_unsigned32
* allocated and set by bsp_start()
*/
#ifndef CPU_HPPA_CLICKS_PER_TICK
extern rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK;
#endif
void Clock_exit(void);
volatile rtems_unsigned32 Clock_driver_ticks;
struct itimerval new;
/*
* These are set by clock driver during its init
*/
rtems_device_driver
Clock_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp,
rtems_id tid,
rtems_unsigned32 *rval
)
{
Install_clock(Clock_isr);
}
void
ReInstall_clock(rtems_isr_entry new_clock_isr)
{
rtems_unsigned32 isrlevel = 0;
rtems_interrupt_disable(isrlevel);
(void)set_vector(new_clock_isr, SIGALRM, 1);
rtems_interrupt_enable(isrlevel);
}
rtems_device_major_number rtems_clock_major = ~0;
rtems_device_minor_number rtems_clock_minor;
void
Install_clock(rtems_isr_entry clock_isr)
{
struct itimerval new;
Clock_driver_ticks = 0;
new.it_value.tv_sec = 0;
@@ -85,11 +67,20 @@ Install_clock(rtems_isr_entry clock_isr)
atexit(Clock_exit);
}
void
ReInstall_clock(rtems_isr_entry new_clock_isr)
{
rtems_unsigned32 isrlevel = 0;
rtems_interrupt_disable(isrlevel);
(void)set_vector(new_clock_isr, SIGALRM, 1);
rtems_interrupt_enable(isrlevel);
}
void
Clock_isr(int vector)
{
Clock_driver_ticks++;
rtems_clock_tick();
}
@@ -101,6 +92,7 @@ Clock_isr(int vector)
void
Clock_exit(void)
{
struct itimerval new;
struct sigaction act;
/*
@@ -121,3 +113,50 @@ Clock_exit(void)
(void)set_vector(0, SIGALRM, 1);
}
rtems_device_driver
Clock_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
)
{
Install_clock((rtems_isr_entry) Clock_isr);
/*
* make major/minor avail to others such as shared memory driver
*/
rtems_clock_major = major;
rtems_clock_minor = minor;
return RTEMS_SUCCESSFUL;
}
rtems_device_driver Clock_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
)
{
rtems_libio_ioctl_args_t *args = pargp;
if (args == 0)
goto done;
/*
* This is hokey, but until we get a defined interface
* to do this, it will just be this simple...
*/
if (args->command == rtems_build_name('I', 'S', 'R', ' '))
{
Clock_isr(SIGALRM);
}
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
{
ReInstall_clock(args->buffer);
}
done:
return RTEMS_SUCCESSFUL;
}
@@ -28,10 +28,9 @@
rtems_device_driver
console_initialize(rtems_device_major_number major,
rtems_device_minor_number minor,
void * arg,
rtems_id self,
rtems_unsigned32 * status)
void * arg
)
{
*status = RTEMS_SUCCESSFUL;
return RTEMS_SUCCESSFUL;
}
+14
View File
@@ -78,6 +78,20 @@ extern rtems_configuration_table BSP_Configuration;
*/
/* #define INTERRUPT_EXTERNAL_MPCI SIGUSR1 */
/*
* Console driver init
*/
rtems_device_driver console_initialize(
rtems_device_major_number, rtems_device_minor_number minor, void *);
#define CONSOLE_DRIVER_TABLE_ENTRY \
{ console_initialize, NULL, NULL, NULL, NULL, NULL }
/*
* NOTE: Use the standard Clock driver entry
*/
/* functions */
+258
View File
@@ -0,0 +1,258 @@
/*
* @(#)assoc.c 1.4 - 95/08/02
*
*
* assoc.c
* rtems assoc routines
*
* $Id$
*/
#include <rtems.h>
#include "assoc.h"
#include <stdio.h> /* sprintf */
#include <string.h> /* strcat, strcmp */
#define STREQ(a,b) (strcmp((a), (b)) == 0)
#define rtems_assoc_is_default(ap) ((ap)->name && STREQ(ap->name, RTEMS_ASSOC_DEFAULT_NAME))
rtems_assoc_t *
rtems_assoc_ptr_by_name(
rtems_assoc_t *ap,
char *name
)
{
rtems_assoc_t *default_ap = 0;
if (rtems_assoc_is_default(ap))
default_ap = ap++;
for ( ; ap->name; ap++)
if (strcmp(ap->name, name) == 0)
return ap;
return default_ap;
}
rtems_assoc_t *
rtems_assoc_ptr_by_local(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
rtems_assoc_t *default_ap = 0;
if (rtems_assoc_is_default(ap))
default_ap = ap++;
for ( ; ap->name; ap++)
if (ap->local_value == local_value)
return ap;
return default_ap;
}
rtems_assoc_t *
rtems_assoc_ptr_by_remote(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
rtems_assoc_t *default_ap = 0;
if (rtems_assoc_is_default(ap))
default_ap = ap++;
for ( ; ap->name; ap++)
if (ap->remote_value == remote_value)
return ap;
return default_ap;
}
/*
* Get values
*/
unsigned32
rtems_assoc_remote_by_local(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_local(ap, local_value);
if (nap)
return nap->remote_value;
return 0;
}
unsigned32
rtems_assoc_local_by_remote(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_remote(ap, remote_value);
if (nap)
return nap->local_value;
return 0;
}
unsigned32
rtems_assoc_remote_by_name(
rtems_assoc_t *ap,
char *name
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_name(ap, name);
if (nap)
return nap->remote_value;
return 0;
}
unsigned32
rtems_assoc_local_by_name(
rtems_assoc_t *ap,
char *name
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_name(ap, name);
if (nap)
return nap->local_value;
return 0;
}
/*
* what to return if a value is not found
* this is not reentrant, but it really shouldn't be invoked anyway
*/
char *
rtems_assoc_name_bad(
unsigned32 bad_value
)
{
static char bad_buffer[32];
sprintf(bad_buffer, "< %d [0x%x] >", bad_value, bad_value);
return bad_buffer;
}
char *
rtems_assoc_name_by_local(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_local(ap, local_value);
if (nap)
return nap->name;
return rtems_assoc_name_bad(local_value);
}
char *
rtems_assoc_name_by_remote(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
rtems_assoc_t *nap;
nap = rtems_assoc_ptr_by_remote(ap, remote_value);
if (nap)
return nap->name;
return rtems_assoc_name_bad(remote_value);
}
/*
* Bitfield functions assume just 1 bit set in each of remote and local
* entries; they do not check for this.
*/
unsigned32 rtems_assoc_remote_by_local_bitfield(
rtems_assoc_t *ap,
unsigned32 local_value
)
{
unsigned32 b;
unsigned32 remote_value = 0;
for (b = 1; b; b <<= 1)
if (b & local_value)
remote_value |= rtems_assoc_remote_by_local(ap, b);
return remote_value;
}
unsigned32 rtems_assoc_local_by_remote_bitfield(
rtems_assoc_t *ap,
unsigned32 remote_value
)
{
unsigned32 b;
unsigned32 local_value = 0;
for (b = 1; b; b <<= 1)
if (b & remote_value)
local_value |= rtems_assoc_local_by_remote(ap, b);
return local_value;
}
char *rtems_assoc_name_by_remote_bitfield(
rtems_assoc_t *ap,
unsigned32 value,
char *buffer
)
{
unsigned32 b;
*buffer = 0;
for (b = 1; b; b <<= 1)
if (b & value)
{
if (*buffer)
strcat(buffer, " ");
strcat(buffer, rtems_assoc_name_by_remote(ap, b));
}
return buffer;
}
char *rtems_assoc_name_by_local_bitfield(
rtems_assoc_t *ap,
unsigned32 value,
char *buffer
)
{
unsigned32 b;
*buffer = 0;
for (b = 1; b; b <<= 1)
if (b & value)
{
if (*buffer)
strcat(buffer, " ");
strcat(buffer, rtems_assoc_name_by_local(ap, b));
}
return buffer;
}

Some files were not shown because too many files have changed in this diff Show More