1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Remove all locking code

Since the Go runtime is not yet setup there is no support for
spinlocking if a lock cannot be acquired. This makes the locking code
useless for now.
This commit is contained in:
Achilleas Anagnostopoulos 2017-03-30 08:06:43 +01:00
parent 7dac10a23b
commit 50da8ab106
4 changed files with 12 additions and 29 deletions

View File

@ -12,7 +12,7 @@ const (
type Vt struct { type Vt struct {
// Go interfaces will not work before we can get memory allocation working. // Go interfaces will not work before we can get memory allocation working.
// Till then we need to use concrete types instead. // Till then we need to use concrete types instead.
cons *console.Vga cons *console.Ega
width uint16 width uint16
height uint16 height uint16
@ -22,7 +22,9 @@ type Vt struct {
curAttr console.Attr curAttr console.Attr
} }
func (t *Vt) Init(cons *console.Vga) { // AttachTo links the terminal with the specified console device and updates
// the terminal's dimensions to match the ones reported by the attached device.
func (t *Vt) AttachTo(cons *console.Ega) {
t.cons = cons t.cons = cons
t.width, t.height = cons.Dimensions() t.width, t.height = cons.Dimensions()
t.curX = 0 t.curX = 0
@ -30,30 +32,20 @@ func (t *Vt) Init(cons *console.Vga) {
// Default to lightgrey on black text. // Default to lightgrey on black text.
t.curAttr = makeAttr(defaultFg, defaultBg) t.curAttr = makeAttr(defaultFg, defaultBg)
} }
// Clear clears the terminal. // Clear clears the terminal.
func (t *Vt) Clear() { func (t *Vt) Clear() {
t.cons.Lock()
defer t.cons.Unlock()
t.clear() t.clear()
} }
// Position returns the current cursor position (x, y). // Position returns the current cursor position (x, y).
func (t *Vt) Position() (uint16, uint16) { func (t *Vt) Position() (uint16, uint16) {
t.cons.Lock()
defer t.cons.Unlock()
return t.curX, t.curY return t.curX, t.curY
} }
// SetPosition sets the current cursor position to (x,y). // SetPosition sets the current cursor position to (x,y).
func (t *Vt) SetPosition(x, y uint16) { func (t *Vt) SetPosition(x, y uint16) {
t.cons.Lock()
defer t.cons.Unlock()
if x >= t.width { if x >= t.width {
x = t.width - 1 x = t.width - 1
} }
@ -67,9 +59,6 @@ func (t *Vt) SetPosition(x, y uint16) {
// Write implements io.Writer. // Write implements io.Writer.
func (t *Vt) Write(data []byte) (int, error) { func (t *Vt) Write(data []byte) (int, error) {
t.cons.Lock()
defer t.cons.Unlock()
attr := t.curAttr attr := t.curAttr
for _, b := range data { for _, b := range data {
switch b { switch b {

View File

@ -2,6 +2,7 @@ package tty
import ( import (
"testing" "testing"
"unsafe"
"github.com/achilleasa/gopher-os/kernel/driver/video/console" "github.com/achilleasa/gopher-os/kernel/driver/video/console"
) )
@ -18,11 +19,12 @@ func TestVtPosition(t *testing.T) {
{100, 100, 79, 24}, {100, 100, 79, 24},
} }
var cons console.Vga fb := make([]uint16, 80*25)
cons.Init() var cons console.Ega
cons.Init(80, 25, uintptr(unsafe.Pointer(&fb[0])))
var vt Vt var vt Vt
vt.Init(&cons) vt.AttachTo(&cons)
for specIndex, spec := range specs { for specIndex, spec := range specs {
vt.SetPosition(spec.inX, spec.inY) vt.SetPosition(spec.inX, spec.inY)
@ -34,12 +36,11 @@ func TestVtPosition(t *testing.T) {
func TestWrite(t *testing.T) { func TestWrite(t *testing.T) {
fb := make([]uint16, 80*25) fb := make([]uint16, 80*25)
cons := &console.Vga{} var cons console.Ega
cons.OverrideFb(fb) cons.Init(80, 25, uintptr(unsafe.Pointer(&fb[0])))
cons.Init()
var vt Vt var vt Vt
vt.Init(cons) vt.AttachTo(&cons)
vt.Clear() vt.Clear()
vt.SetPosition(0, 1) vt.SetPosition(0, 1)

View File

@ -1,7 +1,5 @@
package console package console
import "sync"
// Attr defines a color attribute. // Attr defines a color attribute.
type Attr uint16 type Attr uint16
@ -36,8 +34,6 @@ const (
// The Console interface is implemented by objects that can function as physical consoles. // The Console interface is implemented by objects that can function as physical consoles.
type Console interface { type Console interface {
sync.Locker
// Dimensions returns the width and height of the console in characters. // Dimensions returns the width and height of the console in characters.
Dimensions() (uint16, uint16) Dimensions() (uint16, uint16)

View File

@ -2,7 +2,6 @@ package console
import ( import (
"reflect" "reflect"
"sync"
"unsafe" "unsafe"
) )
@ -16,8 +15,6 @@ const (
// allocator, each console will use its own framebuffer while the active console // allocator, each console will use its own framebuffer while the active console
// will periodically sync its internal buffer with the physical screen buffer. // will periodically sync its internal buffer with the physical screen buffer.
type Ega struct { type Ega struct {
sync.Mutex
width uint16 width uint16
height uint16 height uint16