This commit is contained in:
2024-03-30 11:28:54 +01:00
parent 22090f2b75
commit 961c9bae6e
5 changed files with 10 additions and 11 deletions

View File

@@ -73,10 +73,9 @@ void SerialTty::this_isr() {
char SerialTty::readchar() {
mutex.lock();
if (buf.empty()) {
while (buf.empty()) {
readercv.wait(mutex);
}
assert(!buf.empty());
char ret = buf.pop_back();
mutex.unlock();
return ret;

View File

@@ -93,13 +93,12 @@ uint64_t syscall_read(uint64_t fd, char *buf, uint64_t len) {
while ((c - buf) < len) {
*c = GlobalTtyManager.get_tty(0)->readchar();
if (*c == '\r') {
*(c) = '\n';
*(++c) = '0';
*(c++) = '\n';
break;
}
c++;
}
return (c-buf);
return (c - buf);
}
auto f = FDT::current()->get(fd);
if (!f) return -1;
@@ -113,6 +112,7 @@ uint64_t syscall_write(uint64_t fd, const char *buf, uint64_t len) {
GlobalTtyManager.all_tty_putchar(*c);
c++;
}
return len;
}
auto f = FDT::current()->get(fd);
if (!f) return -1;

View File

@@ -5,5 +5,5 @@ target_link_libraries(init syscalls_interface)
target_include_directories(init PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(hello2 hello2.c)
add_executable(hello2 hello2.cpp)

View File

@@ -1,5 +0,0 @@
#include "stdio.h"
int main() {
printf("Hi!\n");
}

5
src/test/hello2.cpp Normal file
View File

@@ -0,0 +1,5 @@
#include <iostream>
int main() {
std::cout << "Hi!" << std::endl;
}