MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / WriteN

Function WriteN

Kernel/src/logging.cpp:76–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 }
75
76 void WriteN(const char* str, size_t n){
77 write_serial_n(str, n);
78
79 if(console){
80 console->PrintN(str, n, 255, 255, 255);
81 }
82
83 if(logBuffer){
84 if(n >= logBufferMaxSize){
85 n -= (n - logBufferMaxSize);
86 }
87
88 if(n + logBufferPos > logBufferMaxSize){
89 size_t discard = (n + logBufferPos) - logBufferMaxSize; // Amount of bytes to discard
90
91 logBufferPos -= discard;
92 memcpy(logBuffer, logBuffer + discard, logBufferPos);
93 }
94
95 if(n + logBufferPos > logBufferSize){
96 logBufferSize += 4096;
97 char* oldBuf = logBuffer;
98 logBuffer = (char*)kmalloc(logBufferSize);
99 memcpy(logBuffer, oldBuf, logBufferPos);
100 kfree(oldBuf);
101 }
102
103 memcpy(logBuffer + logBufferPos, str, n);
104 logBufferPos += n;
105
106 logDevice->size = logBufferPos;
107 }
108 }
109
110 void Write(const char* str, uint8_t r, uint8_t g, uint8_t b){
111 WriteN(str, strlen(str));

Callers 3

WriteMethod · 0.85
WriteFunction · 0.85
WriteFFunction · 0.85

Calls 5

write_serial_nFunction · 0.85
memcpyFunction · 0.85
kmallocFunction · 0.85
kfreeFunction · 0.85
PrintNMethod · 0.80

Tested by

no test coverage detected