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

Each driver should manually register a probe function for use by hal

This commit removes the HWProbes() function from the console and tty
packages and replaces it with a global ProbeFuncs slice which is fetched
by the hal package when the hardware autodetection code runs.

Each driver should provide an init() function that appends a probe function
to the global ProbeFuncs slice.

This approach allows us to support conditional compilation of drivers in
the future (e.g. using build tags)
This commit is contained in:
Achilleas Anagnostopoulos
2017-07-08 12:25:21 +01:00
parent 4845f7a4ca
commit ffb8f86a9c
5 changed files with 27 additions and 27 deletions

View File

@@ -2,10 +2,10 @@ package tty
import "gopheros/device"
// HWProbes returns a slice of device.ProbeFn that can be used by the hal
// package to probe for TTY device hardware.
func HWProbes() []device.ProbeFn {
return []device.ProbeFn{
probeForVT,
}
}
var (
// ProbeFuncs is a slice of device probe functions
// that is used by the hal package to probe for TTY
// hardware. Each driver should use an init() block
// to append its probe function to this list.
ProbeFuncs []device.ProbeFn
)

View File

@@ -260,6 +260,8 @@ func (t *VT) DriverVersion() (uint16, uint16, uint16) {
// DriverInit initializes this driver.
func (t *VT) DriverInit() *kernel.Error { return nil }
func probeForVT() device.Driver {
return NewVT(DefaultTabWidth, DefaultScrollback)
func init() {
ProbeFuncs = append(ProbeFuncs, func() device.Driver {
return NewVT(DefaultTabWidth, DefaultScrollback)
})
}