bputc() fix

This commit is contained in:
Julian Barathieu 2019-04-01 11:21:04 +02:00
parent 5c931641ad
commit c34221071d
5 changed files with 31 additions and 1265023 deletions

View File

@ -58,8 +58,28 @@ error_t bputc(Buffer_t *buf, uchar ch)
// That should change; there should be a flag for it
if (buf->flags & BF_LINE) {
// Deal with line feeds by filling the rest of the line with spaces
// We need a field for choosing a different filler, e.g. '\0'
if (ch == '\n') {
assert(buf->lastLF < buf->lineLen);
// Make sure double \n's have effect
//if (buf->lastLF == 0) {
// buf->lastLF = buf->lineLen;
//}
int off = buf->lineLen - buf->lastLF;
while (off > 0) {
*buf->wp++ = ' ';
off--;
}
buf->lastLF = 0;
if (buf->flusher) buf->flusher(buf);
}
// Deal with carriage returns
if (ch == '\r') {
else if (ch == '\r') {
buf->wp -= buf->lastLF;
buf->lastLF = 0;
assert(buf->wp >= buf->buf);
@ -76,17 +96,6 @@ error_t bputc(Buffer_t *buf, uchar ch)
if (rc > 0) return rc;
}
// Deal with line feeds by filling the rest of the line with spaces
// We need a field for choosing a different filler, e.g. '\0'
else if (ch == '\n') {
assert(buf->lastLF < buf->lineLen);
while (buf->lastLF > 0) {
rc = bputc(buf, ' ');
}
if (rc > 0) return rc;
if (buf->flusher) buf->flusher(buf);
}
// Just a regular character
else {
// Do we have to scroll up?
@ -113,7 +122,7 @@ error_t bputc(Buffer_t *buf, uchar ch)
else {
memcpy(buf->buf, buf->buf + bufSize,
buf->size - bufSize);
buf->wp -= buf->lineLen;
buf->wp -= bufSize;
}
}

View File

@ -121,40 +121,37 @@ extern error_t IoInitVGABuffer(void);
//
noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic)
{
int tmp;
// We're not ready to deal with interrupts
KeDisableIRQs();
// Initialize the BootInfo_t structure
BtInitBootInfo(mbInfo);
// Get ready to print things
IoInitVGABuffer();
BARRIER();
// Hello world
KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC);
tmp = (BtGetBootInfo(btldr).kernelEndAddr
- BtGetBootInfo(btldr).kernelAddr) / KB;
KernLog("[Init] Kernel successfully loaded at %p with %x magic\n"
" and it uses %d Kio\n\n",
BtGetBootInfo(btldr).kernelAddr,
mbMagic,
(BtGetBootInfo(btldr).kernelEndAddr - BtGetBootInfo(btldr).kernelAddr)
/ KB
);
mbMagic,tmp);
//Memory mapping
MmInitMemoryMap();
MmInitHeap();
BARRIER();
int i = 0;
while(i < 517) { KernLog("%d\n", i++);}
while(i < 512) { KernLog("%d\n", i++);}
PsInitSched();
// We're out

View File

@ -44,6 +44,8 @@ error_t bvgaflusher(Buffer_t *buf)
ushort *fbp = BtGetBootInfo(video).framebufferAddr;
const uchar color = 0xf;
assert(buf->lastLF == 0);
uchar *currentLine = buf->wp - buf->lineLen;
uchar *ptr = (uchar *)lmax((size_t)buf->buf,
(size_t)currentLine

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff