Remove special handling for tty access, make init do it

This commit is contained in:
Kevin Lange 2014-04-05 15:43:14 -07:00
parent a8d599b570
commit 51d398fc76
4 changed files with 16 additions and 21 deletions

View File

@ -163,9 +163,6 @@ exec(
current_process->image.heap = heap; /* heap end */
current_process->image.heap_actual = heap + (0x1000 - heap % 0x1000);
current_process->image.user_stack = USER_STACK_TOP;
while (current_process->fds->length < 3) {
process_append_fd((process_t *)current_process, NULL);
}
current_process->image.start = entry;

View File

@ -210,7 +210,7 @@ process_t * spawn_init(void) {
init->status = 0; /* Run status */
init->fds = malloc(sizeof(fd_table_t));
init->fds->refs = 1;
init->fds->length = 3; /* Initialize the file descriptors */
init->fds->length = 0; /* Initialize the file descriptors */
init->fds->capacity = 4;
init->fds->entries = malloc(sizeof(fs_node_t *) * init->fds->capacity);

View File

@ -37,15 +37,6 @@ int validate_safe(void * ptr) {
return 0;
}
/*
* print something to the debug terminal (serial)
*/
static int print(char * s) {
validate((void *)s);
kprintf("%s", s);
return 0;
}
/*
* Exit the current task.
* DOES NOT RETURN!
@ -105,13 +96,6 @@ static int readdir(int fd, int index, struct dirent * entry) {
}
static int write(int fd, char * ptr, int len) {
if ((fd == 1 && !current_process->fds->entries[fd]) ||
(fd == 2 && !current_process->fds->entries[fd])) {
for (uint32_t i = 0; i < (uint32_t)len; ++i) {
kprintf("%c", ptr[i]);
}
return len;
}
if (fd >= (int)current_process->fds->length || fd < 0) {
return -1;
}
@ -698,7 +682,7 @@ static int sys_unlink(char * file) {
static uintptr_t syscalls[] = {
/* System Call Table */
(uintptr_t)&exit, /* 0 */
(uintptr_t)&print,
(uintptr_t)&RESERVED,
(uintptr_t)&open,
(uintptr_t)&read,
(uintptr_t)&write, /* 4 */

View File

@ -10,10 +10,22 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <syscall.h>
#define DEFAULT_HOSTNAME "toaru-test"
void set_console() {
int _stdin = open("/dev/null", O_RDONLY);
int _stdout = open("/dev/ttyS0", O_WRONLY);
int _stderr = open("/dev/ttyS0", O_WRONLY);
if (_stdout < 0) {
_stdout = open("/dev/null", O_WRONLY);
_stderr = open("/dev/null", O_WRONLY):
}
}
/* Set the hostname to whatever is in /etc/hostname */
void set_hostname() {
FILE * _host_file = fopen("/etc/hostname", "r");
@ -43,6 +55,8 @@ int start_options(char * args[]) {
}
int main(int argc, char * argv[]) {
/* stdin/out/err */
set_console();
/* Hostname */
set_hostname();
if (argc > 1) {