wake-0 / fhvOS

This repository contains an os for the arm cortex a8 in combination with beaglebone.
GNU General Public License v2.0
7 stars 1 forks source link

[Console] Implement a console #36

Closed trylimits closed 9 years ago

trylimits commented 9 years ago

We should implement a console which also overrides the printf(..) and scanf(..) functions. Those should be redirected to the UART0 output.

General concept for that is to provide our own functions which should look approx. like this:

extern int fprintf (char* format, ...)
{
   va_list args;

   va_start(args,format);

   int return_status = 0;
   return_status = vfprintf(STREAM, format, args);

   va_end(args);
   return return_status;
}

where STREAM is of type FILE.

trylimits commented 9 years ago

I would like to discuss some specifications of the console:

  1. Is the console a user application or integrated into the kernel
  2. Should the console override printf and scanf
  3. Should the console be blocked by one process or should it be available for all processes

@mpe5651 @Blackjack92 Pls provide your opinions asap.

trylimits commented 9 years ago

I did some testing on whic ASCII codes are sent if the following keys are sent over uart:

Backspace=127
Key UP=91 followed by 65
Key DOWN=91 followed by 66
Key LEFT=91 followed by 68
Key RIGHT=91 followed by 67
Key DEL=91 followed by 51 followed by 126

Trivial test code:

DeviceManagerRead(consoleDevice, &buf[0], 1);
char temp[10];
sprintf(temp, "[D] %i\r\n", buf[0]);
DeviceManagerWrite(consoleDevice, temp, 10);
trylimits commented 9 years ago

The above commit implements a first prototype for a console. Implemented is:

1.) ASCII Logo
2.) Welcome message
3.) Prompt
4.) Command input

Not implemented:

1.) Handling of control keys (cursor, bs, del)
2.) IPC to kernel (command)
3.) ...
trylimits commented 9 years ago

Above commits implement the scanf and printf override. The console implementation directly uses scanf to fetch the user input.

Atm. not all input characters are supported, but the set of accepted characters can be easily extended by changing the method acceptChar(..) in console.c.

All improvements of the console should be treated in new tickets.

Below code snippet starts the console as a process:

DeviceManagerInit();

device_t uart = DeviceManagerGetDevice("UART0", 5);
ConsoleInit(uart);

SchedulerInit();
SchedulerStartProcess(&ConsoleProcess);

device_t timer = DeviceManagerGetDevice("TIMER2", 6);
DeviceManagerInitDevice(timer);
device_t cpu = DeviceManagerGetDevice("CPU", 3);
DeviceManagerIoctl(cpu, DRIVER_CPU_COMMAND_INTERRUPT_MASTER_IRQ_ENABLE, 0, NULL, 0);
DeviceManagerIoctl(cpu, DRIVER_CPU_COMMAND_INTERRUPT_RESET_AINTC, 0, NULL, 0);
SchedulerStart(timer);