- libsys multitarget
- apps multitarget

git-svn-id: http://moon:8086/svn/mips@67 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-10 17:50:12 +00:00
parent a67ef9649d
commit 82802139cd
18 changed files with 947 additions and 807 deletions
+101
View File
@@ -0,0 +1,101 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include <assert.h>
#include <stddef.h>
#include <string.h>
#include "console.h"
extern con_if_t con_if;
// Funcs
con_if_entry_t const* con_getPort(int file)
{
assert(file < con_if.length);
return &con_if.con_if_entry[file];
}
int con_open(char const *pName)
{
int i;
assert(pName);
for (i=0; i < con_if.length; i++)
{
if (!strcmp(pName, con_if.con_if_entry->pName))
{
if (con_if.con_if_entry->openFunc)
{
con_if.con_if_entry->openFunc(&con_if.con_if_entry[i].pInst);
return i;
}
}
}
return -1;
}
int con_close(int fd)
{
}
void con_flush(int fd)
{
int c;
con_if_entry_t const *pIF = con_getPort(fd);
do
{
c = pIF->readchar(pIF->pInst);
} while(c > 0);
}
// ---------------------------------------------------------------------------------
int readchar(int fd)
{
int c;
con_if_entry_t const *pIF = con_getPort(fd);
assert(pIF);
// busy read
do
{
c = pIF->readchar(pIF->pInst);
} while(c < 0);
return c;
}
void writechar(int fd, char c)
{
con_if_entry_t const *pIF = con_getPort(fd);
assert(pIF);
pIF->writechar(pIF->pInst, c);
}
void _putchar(int fd, char c)
{
con_if_entry_t const *pIF = con_getPort(fd);
assert(pIF);
if (c == 0x0A)
{
pIF->writechar(pIF->pInst, 0x0D);
}
pIF->writechar(pIF->pInst, c);
}
char _getchar(int fd)
{
return readchar(fd);
}