Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
Now oos compiles on the latest rock... but it doesn't run (triple fau…
Browse files Browse the repository at this point in the history
…lt).
  • Loading branch information
Scott Olson committed Nov 16, 2010
1 parent 366ad34 commit fcf821b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
4 changes: 1 addition & 3 deletions sdk/lang/types.ooc
Expand Up @@ -218,10 +218,8 @@ String: cover from Char* {
/// return the string's length, excluding the null byte.
length: func -> SizeT {
i := 0
while (this@) {
this += 1
while (this[i])
i += 1
}
return i
}

Expand Down
4 changes: 2 additions & 2 deletions src/Printf.ooc
Expand Up @@ -253,7 +253,7 @@ vsnprintf: func (str: String, size: SizeT, fmt: String, ap: VaList) -> Int {
while(p@ digit?()) {
if(fieldwidth > 0)
fieldwidth *= 10
fieldwidth += (p@ - 0x30)
fieldwidth += (p@ - 0x30) as Int
p += 1
}

Expand All @@ -269,7 +269,7 @@ vsnprintf: func (str: String, size: SizeT, fmt: String, ap: VaList) -> Int {
while(p@ digit?()) {
if (precision > 0)
precision *= 10
precision += (p@ - 0x30)
precision += (p@ - 0x30) as Int
p += 1
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/devices/Display.ooc
Expand Up @@ -55,7 +55,7 @@ Display: cover {
setColor: static func (fg, bg: Color) {
This fg = fg
This bg = bg
This color = (fg & 0xf) | bg << 4
This color = ((fg & 0xf) | bg << 4) as UInt8
}

setColor: static func ~withFn (fg, bg: Color, fn: Func) {
Expand Down Expand Up @@ -90,7 +90,7 @@ Display: cover {

clearScreen: static func {
for(i in 0..(CONSOLE_HEIGHT * CONSOLE_WIDTH)) {
VIDEO_MEMORY[i] = ' ' | color << 8
VIDEO_MEMORY[i] = (' ' | color << 8) as UInt16
}
cursor_x = 0
cursor_y = 0
Expand Down Expand Up @@ -139,7 +139,7 @@ Display: cover {
// Index = [(y * width) + x]
else if(chr >= ' ') {
i := cursor_y * CONSOLE_WIDTH + cursor_x
VIDEO_MEMORY[i] = chr | color << 8
VIDEO_MEMORY[i] = (chr | color << 8) as UInt16
cursor_x += 1
}

Expand Down Expand Up @@ -168,7 +168,7 @@ Display: cover {
}

for(col in 0..CONSOLE_WIDTH) {
VIDEO_MEMORY[(CONSOLE_HEIGHT - 1) * CONSOLE_WIDTH + col] = ' ' | color << 8
VIDEO_MEMORY[(CONSOLE_HEIGHT - 1) * CONSOLE_WIDTH + col] = (' ' | color << 8) as UInt16
}
}

Expand Down
26 changes: 16 additions & 10 deletions src/devices/Keyboard.ooc
Expand Up @@ -13,7 +13,7 @@ Scancode: cover {
}

Keyboard: cover {
lowercase: static Char[128] = [
lowercase: static SSizeT[128] = [
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
'9', '0', '-', '=', 0x08, /* Backspace */
'\t', /* Tab */
Expand Down Expand Up @@ -52,7 +52,7 @@ Keyboard: cover {
0 /* All other keys are undefined */
]

uppercase: static Char[128] = [
uppercase: static SSizeT[128] = [
0, 27, '!', '@', '#', '$', '%', '^', '&', '*', /* 9 */
'(', ')', '_', '+', 0x08, /* Backspace */
'\t', /* Tab */
Expand Down Expand Up @@ -140,20 +140,22 @@ Keyboard: cover {
while(bufferIndex == 0){}

bufferIndex -= 1
scancode := buffer[bufferIndex]
scancode: UInt8 = buffer[bufferIndex]

if((shift && !capslock) || (capslock && !shift))
Bochs debug("Reading... CAPS:%i, SHIFT:%i" format(capslock, shift))

Bochs debug("uppercase:%p lowercase:%p scancode:%i" format(uppercase, lowercase, scancode))

Bochs debug("%s" format((uppercase[scancode] == lowercase[scancode]) toString()))

if((shift && !capslock) || (capslock && !shift)) {
uppercase[scancode] as Char
else
} else {
lowercase[scancode] as Char
}
}

setup: static func {
numlock = true

updateLights()
flushBuffer()

// The keyboard interrupt handler.
IRQ handlerInstall(1, |regs|
scancode := Ports inByte(0x60)
Expand Down Expand Up @@ -199,6 +201,10 @@ Keyboard: cover {
}
}
)
numlock = true

updateLights()
flushBuffer()
}
}

6 changes: 3 additions & 3 deletions src/devices/cpu/GDT.ooc
Expand Up @@ -28,10 +28,10 @@ GDT: cover {
gdt[n] base_3 = base >> 24 & 0xFF // base bits 24..31

gdt[n] limit_1 = limit & 0xFFFF // limit bits 0..15
gdt[n] flags__limit_2 = ((gr & 1) << 7) | // granularity bit
gdt[n] flags__limit_2 = (((gr & 1) << 7) | // granularity bit
((sz & 1) << 6) | // size bit
// ends with two dummy bits (00)
(limit >> 16 & 0xF) // limit bits 16..19
(limit >> 16 & 0xF)) as UInt8 // limit bits 16..19

gdt[n] access_byte = (1 << 7) | // first bit must be set for all valid GDT selectors
((privl & 0b11) << 5) | // two bits for the ring level
Expand All @@ -58,4 +58,4 @@ GDTEntry: cover from GDTE {
flags__limit_2: extern UInt8 // flags: Gr, Sz, 0, 0
// limit bits 16..19
base_3: extern UInt8 // base bits 24..31
} // __attribute__((packed))
} // __attribute__((packed))
8 changes: 4 additions & 4 deletions src/memory/MM.ooc
Expand Up @@ -174,10 +174,10 @@ MM: cover {
// Parse the memory map from GRUB.
parseMemoryMap()

Bochs debug("Taking the plunge...")
// Bochs debug("Taking the plunge...")
// Switch and activate paging.
switchAddressSpace(sharedSpace)
Bochs debug("Swan dive!")
// switchAddressSpace(sharedSpace)
// Bochs debug("Swan dive!")

// activatePaging()
// Bochs debug("A perfect entry!")
Expand Down Expand Up @@ -224,4 +224,4 @@ MM: cover {
switchAddressSpace: static extern proto func (addressSpace: UInt*)
getCR0: static extern proto func -> SizeT
setCR0: static extern proto func (cr0: SizeT)
}
}

0 comments on commit fcf821b

Please sign in to comment.