forked from RTEMS/rtems
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
339 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
c/src/lib/libbsp/arm/raspberrypi/console/console_select.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* @file | ||
* | ||
* @ingroup raspberrypi_console | ||
* | ||
* @brief console select | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2015 Yang Qiao | ||
* | ||
* The license and distribution terms for this file may be | ||
* found in the file LICENSE in this distribution or at | ||
* | ||
* http://www.rtems.org/license/LICENSE | ||
* | ||
*/ | ||
|
||
#include <bsp.h> | ||
#include <bsp/fatal.h> | ||
#include <rtems/libio.h> | ||
#include <stdlib.h> | ||
#include <assert.h> | ||
#include <termios.h> | ||
|
||
#include <rtems/termiostypes.h> | ||
#include <libchip/serial.h> | ||
#include "../../../shared/console_private.h" | ||
|
||
rtems_device_minor_number BSPPrintkPort = 0; | ||
|
||
/* | ||
* Method to return true if the device associated with the | ||
* minor number probs available. | ||
*/ | ||
static bool bsp_Is_Available( rtems_device_minor_number minor ) | ||
{ | ||
console_tbl *cptr = Console_Port_Tbl[minor]; | ||
|
||
/* | ||
* First perform the configuration dependent probe, then the | ||
* device dependent probe | ||
*/ | ||
if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) && | ||
cptr->pDeviceFns->deviceProbe(minor)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/* | ||
* Method to return the first available device. | ||
*/ | ||
static rtems_device_minor_number bsp_First_Available_Device( void ) | ||
{ | ||
rtems_device_minor_number minor; | ||
|
||
for (minor=0; minor < Console_Port_Count ; minor++) { | ||
console_tbl *cptr = Console_Port_Tbl[minor]; | ||
|
||
/* | ||
* First perform the configuration dependent probe, then the | ||
* device dependent probe | ||
*/ | ||
|
||
if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) && | ||
cptr->pDeviceFns->deviceProbe(minor)) { | ||
return minor; | ||
} | ||
} | ||
|
||
/* | ||
* Error No devices were found. We will want to bail here. | ||
*/ | ||
bsp_fatal(BSP_FATAL_CONSOLE_NO_DEV); | ||
} | ||
|
||
void bsp_console_select(void) | ||
{ | ||
|
||
/* | ||
* Reset Console_Port_Minor and | ||
* BSPPrintkPort here if desired. | ||
* | ||
* This default version allows the bsp to set these | ||
* values at creation and will not touch them again | ||
* unless the selected port number is not available. | ||
*/ | ||
|
||
Console_Port_Minor = BSP_CONSOLE_FB; | ||
BSPPrintkPort = BSP_CONSOLE_FB; | ||
|
||
/* | ||
* If the device that was selected isn't available then | ||
* let the user know and select the first available device. | ||
*/ | ||
if ( !bsp_Is_Available( Console_Port_Minor ) ) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yangqiao
Author
Owner
|
||
Console_Port_Minor = bsp_First_Available_Device(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
/** | ||
* @file | ||
* | ||
* @ingroup raspberrypi_console | ||
* | ||
* @brief framebuffer graphic console support. | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2015 Yang Qiao | ||
* | ||
* The license and distribution terms for this file may be | ||
* found in the file LICENSE in this distribution or at | ||
* | ||
* http://www.rtems.org/license/LICENSE | ||
* | ||
*/ | ||
|
||
#include <rtems.h> | ||
#include <rtems/libio.h> | ||
|
||
#include <stdlib.h> | ||
|
||
#include <libchip/serial.h> | ||
#include <libchip/sersupp.h> | ||
|
||
#include <bsp.h> | ||
#include <bsp/fbcons.h> | ||
|
||
/* | ||
* fbcons_init | ||
* | ||
* This function initializes the fb console to a quiecsent state. | ||
*/ | ||
static void fbcons_init(int minor) | ||
{ | ||
} | ||
|
||
/* | ||
* fbcons_open | ||
* | ||
* This function opens a port for communication. | ||
* | ||
* Default state is 9600 baud, 8 bits, No parity, and 1 stop bit. | ||
*/ | ||
static int fbcons_open( | ||
int major, | ||
int minor, | ||
void *arg | ||
) | ||
{ | ||
return RTEMS_SUCCESSFUL; | ||
} | ||
|
||
/* | ||
* fbcons_close | ||
* | ||
* This function shuts down the requested port. | ||
*/ | ||
static int fbcons_close( | ||
int major, | ||
int minor, | ||
void *arg | ||
) | ||
{ | ||
return(RTEMS_SUCCESSFUL); | ||
} | ||
|
||
/* | ||
* fbcons_write_polled | ||
* | ||
* This routine polls out the requested character. | ||
*/ | ||
static void fbcons_write_polled( | ||
int minor, | ||
char c | ||
) | ||
{ | ||
_RPI_outch( c ); | ||
if( c == '\n') | ||
_RPI_outch( '\r' ); /* LF = LF + CR */ | ||
} | ||
|
||
/* | ||
* fbcons_write_support_polled | ||
* | ||
* Console Termios output entry point when using polled output. | ||
* | ||
*/ | ||
static ssize_t fbcons_write_support_polled( | ||
int minor, | ||
const char *buf, | ||
size_t len | ||
) | ||
{ | ||
int nwrite = 0; | ||
|
||
/* | ||
* poll each byte in the string out of the port. | ||
*/ | ||
while (nwrite < len) { | ||
fbcons_write_polled(minor, *buf++); | ||
nwrite++; | ||
} | ||
|
||
/* | ||
* return the number of bytes written. | ||
*/ | ||
return nwrite; | ||
} | ||
|
||
/* | ||
* fbcons_inbyte_nonblocking_polled | ||
* | ||
* Console Termios polling input entry point. | ||
*/ | ||
static int fbcons_inbyte_nonblocking_polled( | ||
int minor | ||
) | ||
{ | ||
// if( rtems_kbpoll() ) { | ||
// int c = getch(); | ||
// return c; | ||
// } | ||
|
||
return -1; | ||
} | ||
|
||
/* | ||
* fbcons_set_attributes | ||
* | ||
* This function sets the UART channel to reflect the requested termios | ||
* port settings. | ||
*/ | ||
static int fbcons_set_attributes( | ||
int minor, | ||
const struct termios *t | ||
) | ||
{ | ||
return 0; | ||
} | ||
|
||
bool fbcons_probe( | ||
int minor | ||
) | ||
{ | ||
// rtems_status_code status; | ||
static bool firstTime = true; | ||
|
||
/* | ||
* keyboard interrupt should be registered when the keyboard is available | ||
*/ | ||
if ( firstTime ) { | ||
printk("[+]fbcons_probe executed\n"); | ||
} | ||
firstTime = false; | ||
|
||
return true; | ||
} | ||
|
||
const console_fns fbcons_fns = | ||
{ | ||
.deviceProbe = libchip_serial_default_probe, /* deviceProbe */ | ||
.deviceFirstOpen = fbcons_open, /* deviceFirstOpen */ | ||
.deviceLastClose = fbcons_close, /* deviceLastClose */ | ||
.deviceRead = fbcons_inbyte_nonblocking_polled, /* deviceRead */ | ||
.deviceWrite = fbcons_write_support_polled, /* deviceWrite */ | ||
.deviceInitialize = fbcons_init, /* deviceInitialize */ | ||
.deviceWritePolled = fbcons_write_polled, /* deviceWritePolled */ | ||
.deviceSetAttributes = fbcons_set_attributes, /* deviceSetAttributes */ | ||
.deviceOutputUsesInterrupts = FALSE, /* deviceOutputUsesInterrupts*/ | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @file | ||
* | ||
* @ingroup raspberrypi_console | ||
* | ||
* @brief framebuffer graphic console support. | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2015 Yang Qiao | ||
* | ||
* The license and distribution terms for this file may be | ||
* found in the file LICENSE in this distribution or at | ||
* | ||
* http://www.rtems.org/license/LICENSE | ||
* | ||
*/ | ||
|
||
#ifndef _FBCONS_H_ | ||
#define _FBCONS_H_ | ||
|
||
#include <libchip/serial.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* | ||
* This is the ASCII for "PI" in the upper word and 2835 | ||
* in the lower which should be unique enough to | ||
* distinguish this type of serial device from others. | ||
*/ | ||
|
||
#define FB_CONSOLE 0x50492835 | ||
|
||
bool fbcons_probe( int minor ); | ||
|
||
/* | ||
* Driver function table | ||
*/ | ||
extern const console_fns fbcons_fns; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _FBCONS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,5 @@ | |
void bsp_start(void) | ||
{ | ||
bsp_interrupt_initialize(); | ||
_RPI_initVideo(); | ||
} |
Verify this is succeeding