kout
This commit is contained in:
@@ -40,7 +40,10 @@ char Serial::readReg(RegisterIndex reg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Serial::write(char out) {
|
int Serial::write(char out) {
|
||||||
// TODO: Implement
|
//TODO fix behavior when \r\n ist actually sent
|
||||||
|
if(out == '\n')
|
||||||
|
write('\r');
|
||||||
|
|
||||||
if(readReg(LINE_STATUS_REGISTER) & TRANSMITTER_EMPTY){
|
if(readReg(LINE_STATUS_REGISTER) & TRANSMITTER_EMPTY){
|
||||||
writeReg(TRANSMIT_BUFFER_REGISTER, out);
|
writeReg(TRANSMIT_BUFFER_REGISTER, out);
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ SerialStream::SerialStream(ComPort port, BaudRate baud_rate, DataBits data_bits,
|
|||||||
StopBits stop_bits, Parity parity)
|
StopBits stop_bits, Parity parity)
|
||||||
:Serial(port, baud_rate, data_bits, stop_bits, parity) {}
|
:Serial(port, baud_rate, data_bits, stop_bits, parity) {}
|
||||||
|
|
||||||
|
SerialStream kout = SerialStream();
|
||||||
|
|
||||||
void SerialStream::flush() {
|
void SerialStream::flush() {
|
||||||
print(buffer, strlen(buffer));
|
print(buffer, pos);
|
||||||
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/3440726/what-is-the-proper-way-of-implementing-a-good-itoa-function
|
// https://stackoverflow.com/questions/3440726/what-is-the-proper-way-of-implementing-a-good-itoa-function
|
||||||
|
|||||||
@@ -141,3 +141,6 @@ class SerialStream : public OutputStream, public Serial {
|
|||||||
*/
|
*/
|
||||||
void print(char* str, int length);
|
void print(char* str, int length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern SerialStream kout;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,4 @@ TextStream::TextStream(unsigned from_col,
|
|||||||
void TextStream::flush() {
|
void TextStream::flush() {
|
||||||
print(buffer,pos);
|
print(buffer,pos);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
39
main.cc
39
main.cc
@@ -38,18 +38,33 @@ extern "C" int main() {
|
|||||||
//Serial s = Serial();
|
//Serial s = Serial();
|
||||||
//s.write('a');
|
//s.write('a');
|
||||||
|
|
||||||
// test SerialStream
|
//// test SerialStream
|
||||||
SerialStream ss = SerialStream();
|
//SerialStream ss = SerialStream();
|
||||||
ss.print("test", 4);
|
//ss.print("test", 4);
|
||||||
ss.setAttribute(SerialStream::UNDERSCORE);
|
//ss.setAttribute(SerialStream::UNDERSCORE);
|
||||||
ss.print("test", 4);
|
//ss.print("test", 4);
|
||||||
ss.setAttribute(SerialStream::RESET);
|
//ss.setAttribute(SerialStream::RESET);
|
||||||
ss.setForeground(SerialStream::MAGENTA);
|
//ss.setForeground(SerialStream::MAGENTA);
|
||||||
ss.print("test", 4);
|
//ss.print("test", 4);
|
||||||
ss.setBackground(SerialStream::CYAN);
|
//ss.setBackground(SerialStream::CYAN);
|
||||||
ss.print("test", 4);
|
//ss.print("test", 4);
|
||||||
ss.setPos(10, 10);
|
//ss.setPos(10, 10);
|
||||||
ss.print("test", 4);
|
//ss.print("test", 4);
|
||||||
|
|
||||||
|
kout << "Test <stream result> -> <expected>" << endl;
|
||||||
|
kout << "bool: " << true << " -> true" << endl;
|
||||||
|
kout << "zero: " << 0 << " -> 0" << endl;
|
||||||
|
kout << "binary: " << bin << 42 << dec << " -> 0b101010" << endl;
|
||||||
|
kout << "octal: " << oct << 42 << dec << " -> 052" << endl;
|
||||||
|
kout << "hex: " << hex << 42 << dec << " -> 0x2a" << endl;
|
||||||
|
kout << "uint64_t max: " << ~((uint64_t)0) << " -> 18446744073709551615" << endl;
|
||||||
|
kout << "int64_t max: " << ~(1ll<<63) << " -> 9223372036854775807" << endl;
|
||||||
|
kout << "int64_t min: " << (1ll<<63) << " -> -9223372036854775808" << endl;
|
||||||
|
kout << "some int64_t: " << (-1234567890123456789) << " -> -1234567890123456789" << endl;
|
||||||
|
kout << "some int64_t: " << (1234567890123456789) << " -> 1234567890123456789" << endl;
|
||||||
|
kout << "pointer: " << reinterpret_cast<void*>(1994473406541717165ull)
|
||||||
|
<< " -> 0x1badcafefee1dead" << endl;
|
||||||
|
kout << "smiley: " << static_cast<char>(1) << endl;
|
||||||
|
|
||||||
/* Start application processors
|
/* Start application processors
|
||||||
* To avoid unexpected behaviour, make sure that interrupts are not
|
* To avoid unexpected behaviour, make sure that interrupts are not
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
#include "stringbuffer.h"
|
#include "stringbuffer.h"
|
||||||
|
|
||||||
void Stringbuffer::put(char c) { (void)c; }
|
void Stringbuffer::put(char c) {
|
||||||
|
buffer[pos++] = c;
|
||||||
|
if(pos > 80)
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ kvm: all
|
|||||||
|
|
||||||
# Execute Qemu with activated GDB stub and directly connect GDB to the spawned Qemu.
|
# Execute Qemu with activated GDB stub and directly connect GDB to the spawned Qemu.
|
||||||
gdb: all
|
gdb: all
|
||||||
${VERBOSE} $(GDB) "$(DBGKERNEL)" \
|
${VERBOSE} cgdb -d $(GDB) "$(DBGKERNEL)" \
|
||||||
-ex "set arch $(DBGARCH)" \
|
-ex "set arch $(DBGARCH)" \
|
||||||
-ex "target remote | exec $(QEMU) -gdb stdio $(QEMUKERNEL) -smp $(QEMUCPUS) -S $(QEMUFLAGS) $(DBGFLAGS)"
|
-ex "target remote | exec $(QEMU) -gdb stdio $(QEMUKERNEL) -smp $(QEMUCPUS) -S $(QEMUFLAGS) $(DBGFLAGS)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user