forked from Imagelibrary/rtems
This commit covers at least PR2020, 2022, and 2023. This patch adds all of the code for both BSPs, modifications to libcpu/powerpc for the ppc440, and some updates to the BSPs from follow up review and testing. These BSPs should be good baselines for future development. The configurations used by Ric are custom and have a non-standard NIC. They also do not have a UART. Thus the current console driver just prints to a RAM buffer. The NIC and UART support are left for future work. When the UART support is added, moving the existing "to RAM" console driver to a shared location is likely desirable because boards with no debug UART port are commonly deployed. This would let printk() go to RAM.
103 lines
3.7 KiB
C
103 lines
3.7 KiB
C
#include <rtems.h>
|
|
#include <rtems/libio.h>
|
|
|
|
#include <string.h>
|
|
|
|
ssize_t app_memory_write(int minor, const char* buf, size_t len)
|
|
__attribute__(( weak, alias("__bsp_memory_write") ));
|
|
|
|
ssize_t __bsp_memory_write(int minor, const char* buf, size_t len);
|
|
rtems_device_driver console_initialize(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg);
|
|
rtems_device_driver console_open(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg);
|
|
rtems_device_driver console_close(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg);
|
|
rtems_device_driver console_read(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg);
|
|
rtems_device_driver console_write(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg);
|
|
rtems_device_driver console_control(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg);
|
|
|
|
|
|
ssize_t __bsp_memory_write(int minor, const char* buf, size_t len)
|
|
{
|
|
const char* const last = buf+len;
|
|
while (buf < last)
|
|
{
|
|
BSP_output_char(*buf++);
|
|
}
|
|
return len;
|
|
}
|
|
|
|
static rtems_termios_callbacks gMemCallbacks = {
|
|
0, /* firstOpen */
|
|
0, /* lastClose */
|
|
0, /* PollRead */
|
|
app_memory_write, /* write */
|
|
0, /* SetAttr */
|
|
0, /* stopRemoteTx */
|
|
0, /* startRemoteTx */
|
|
0 /* outputUsesInterrupts */
|
|
};
|
|
|
|
rtems_device_driver console_initialize(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg)
|
|
{
|
|
rtems_status_code status;
|
|
|
|
rtems_termios_initialize();
|
|
|
|
status = rtems_io_register_name("/dev/console", major, 0);
|
|
|
|
if (status != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred (status);
|
|
return RTEMS_SUCCESSFUL;
|
|
}
|
|
|
|
rtems_device_driver console_open(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg)
|
|
{
|
|
rtems_status_code sc;
|
|
|
|
sc = rtems_termios_open (major, minor, arg, &gMemCallbacks);
|
|
|
|
return sc;
|
|
}
|
|
|
|
rtems_device_driver console_close(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg)
|
|
{
|
|
return rtems_termios_close(arg);
|
|
}
|
|
|
|
rtems_device_driver console_read(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg)
|
|
{
|
|
return rtems_termios_read(arg);
|
|
}
|
|
|
|
rtems_device_driver console_write(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg)
|
|
{
|
|
return rtems_termios_write(arg);
|
|
}
|
|
|
|
rtems_device_driver console_control(rtems_device_major_number major,
|
|
rtems_device_minor_number minor,
|
|
void* arg)
|
|
{
|
|
return rtems_termios_ioctl(arg);
|
|
}
|