Documentation
¶
Index ¶
- Constants
- Variables
- func AddDomain(d *Domain)
- func AddSegment(base uintptr, limit uintptr, access uint8, flags uint8) int
- func Block()
- func BlockThread(t *Thread)
- func CreateNewPageDirectory() mm.MemSpace
- func CreateNewThread(outThread *Thread, newStack uintptr, cloneThread *Thread, targetDomain *Domain)
- func DisableIRQ(irq uint8)
- func DisableInterrupts()
- func EnableIRQ(irq uint8)
- func EnableInterrupts()
- func ExitDomain(d *Domain)
- func ExitThread(t *Thread)
- func FindFreeTlsSlot() uint32
- func FlushTlsTable(table []GdtEntry)
- func GetSegment(index int, res *GdtSegment) int
- func Hlt()
- func Inb(port uint16) uint8
- func InitATA()
- func InitInterrupts()
- func InitKeyboard()
- func InitMultiboot(info *MultibootInfo)
- func InitPIC()
- func InitPaging()
- func InitPit()
- func InitScheduling()
- func InitSegments()
- func InitSerialDevice()
- func InitSerialDeviceInterrupt()
- func InitUserMode(kernelStackStart uintptr, kernelStackEnd uintptr)
- func Inw(port uint16) uint16
- func JumpUserMode(regs RegisterState, info InterruptInfo)
- func KernelThreadInit()
- func LoadAuxVector(buf []auxVecEntry, elfHdr *elf.Header32, loadAddr uintptr) int
- func LoadElfFile(module *MultibootModule, space *mm.MemSpace) (*elf.Header32, uintptr, uintptr, syscall.Errno)
- func Outb(port uint16, value uint8)
- func Outw(port uint16, value uint16)
- func PICInterruptHandler()
- func RegisterPICHandler(irq uint8, f func())
- func ResumeThread(t *Thread)
- func Schedule()
- func SetInterruptHandler(irq uint8, f InterruptHandler, selector int, priv uint8)
- func SetInterruptStack(addr uintptr)
- func SetTlsSegment(index uint32, desc *UserDesc) bool
- func Shutdown()
- func StartProgram(path string, outDomain *Domain, outMainThread *Thread) syscall.Errno
- func StartProgramUsr(path uintptr, argv uintptr, envp uintptr, outDomain *Domain, ...) syscall.Errno
- func TextModeFlushScreen()
- func TextModeInit()
- func TextModePrintLnCol(s string, attr uint8)
- func UpdateSegment(index int, base uintptr, limit uintptr, access uint8, flags uint8) bool
- type AtaDrive
- type AtaIdentify
- type Domain
- type GdtDescriptor
- type GdtEntry
- type GdtSegment
- type GenericRing
- type IdtDescriptor
- type IdtEntry
- type InterruptHandler
- type InterruptInfo
- type KeyboardRing
- type Keystate
- type MemoryMap
- type Module
- type MultibootInfo
- type MultibootMemoryMap
- type MultibootModule
- type MultibootTag
- type RegisterState
- type SegmentList
- type TextModeErrorWriter
- type TextModeWriter
- type Thread
- type TlsEntry
- type UARTSerialDevice
- type UserDesc
Constants ¶
View Source
const ( AT_NULL = 0 /* end of vector */ AT_IGNORE = 1 /* entry should be ignored */ AT_EXECFD = 2 /* file descriptor of program */ AT_PHDR = 3 /* program headers for program */ AT_PHENT = 4 /* size of program header entry */ AT_PHNUM = 5 /* number of program headers */ AT_PAGESZ = 6 /* system page size */ AT_BASE = 7 /* base address of interpreter */ AT_FLAGS = 8 /* flags */ AT_ENTRY = 9 /* entry point of program */ AT_NOTELF = 10 /* program is not ELF */ AT_UID = 11 /* real uid */ AT_EUID = 12 /* effective uid */ AT_GID = 13 /* real gid */ AT_EGID = 14 /* effective gid */ AT_PLATFORM = 15 /* string identifying CPU for optimizations */ AT_HWCAP = 16 /* arch dependent hints at CPU capabilities */ AT_CLKTCK = 17 /* frequency at which times() increments */ /* values 18 through 22 are reserved */ AT_SECURE = 23 /* secure mode boolean */ AT_BASE_PLATFORM = 24 /* string identifying real platform, may * differ from AT_PLATFORM. */ AT_RANDOM = 25 /* address of 16 random bytes */ AT_HWCAP2 = 26 /* extension of AT_HWCAP */ AT_EXECFN = 31 /* filename of program */ )
View Source
const ( INTERRUPT_GATE = 0xE PRINT_INTERRUPT_DEBUG = false )
View Source
const ( PAGE_DEBUG = false // Reserve memory below 50 MB for kernel image KERNEL_START = 1 << 20 KERNEL_RESERVED = 50 << 20 PAGE_SIZE = 4 << 10 ENTRIES_PER_TABLE = PAGE_SIZE / 4 PAGE_PRESENT = 1 << 0 PAGE_RW = 1 << 1 PAGE_PERM_USER = 1 << 2 PAGE_PERM_KERNEL = 0 << 2 PAGE_WRITETHROUGH = 1 << 3 PAGE_DISABLE_CACHE = 1 << 4 PAGE_FAULT_PRESENT = 1 << 0 PAGE_FAULT_WRITE = 1 << 1 PAGE_FAULT_USER = 1 << 2 PAGE_FAULT_INSTRUCTION_FETCH = 1 << 4 MAX_ALLOC_VIRT_ADDR = 0xf0000000 MIN_ALLOC_VIRT_ADDR = 0x8000000 )
View Source
const ( PIC_PRINT_DEBUG = ENABLE_DEBUG PIC1Port uint16 = 0x20 PIC1Data uint16 = PIC1Port + 1 PIC2Port uint16 = 0xA0 PIC2Data uint16 = PIC2Port + 1 PIC1Offset byte = 0x20 PIC2Offset byte = 0x28 PIC_ICW1_ICW4 byte = 0x01 // ICW4 will be sent PIC_ICW1_Init byte = 0x10 PIC_ICW4_8086 byte = 0x01 // Set 8086/88 mode. unset MCS-80/85 mode PIC_EOI byte = 0x20 // End of interrupt PIC_ReadIRR byte = 0xa PIC_ReadISR byte = 0xb )
View Source
const ( PIT_PORT_DATA = 0x40 PIT_PORT_COMMAND = 0x43 )
View Source
const ( KCS_INDEX = 1 KDS_INDEX = 2 KGS_INDEX = 3 KCS_SELECTOR = KCS_INDEX * 8 KDS_SELECTOR = KDS_INDEX * 8 KGS_SELECTOR = KGS_INDEX * 8 // flags SEG_GRAN_BYTE = 0 << 7 SEG_GRAN_4K_PAGE = 1 << 7 // access SEG_NORW = 0 << 1 SEG_R = 1 << 1 SEG_W = 1 << 1 SEG_SYSTEM = 0 << 4 SEG_NORMAL = 1 << 4 SEG_NOEXEC = 0 << 3 SEG_EXEC = 1 << 3 PRIV_KERNEL = 0 << 5 PRIV_USER = 3 << 5 SEG_BIG_MODE = 1 << 6 PRESENT = 1 << 7 // userDesc flags UDESC_32SEG = 1 << 0 // I ignore this UDESC_CONTENTS = 3 << 1 // don't know what those are UDESC_RX_ONLY = 1 << 3 UDESC_LIMIT_IN_PAGES = 1 << 4 UDESC_SEG_NOT_PRESENT = 1 << 5 UDESC_USABLE = 1 << 6 // Misc GDT_ENTRIES = 256 TLS_START = 16 )
View Source
const ( COM1_PORT uint16 = 0x3F8 COM1_IRQ uint8 = 0x4 )
View Source
const ( TSS_IS_TSS = 1 << 0 TSS_32MODE = 1 << 3 EFLAGS_IF = 0x200 // interrupt flag. enable interrupts EFLAGS_R = 0x2 // Reserved. always 1 )
View Source
const ENABLE_DEBUG = false
View Source
const ESUCCESS = syscall.Errno(0)
TODO: Move somewhere else?
View Source
const (
MEM_MAP_AVAILABLE = 1
)
Variables ¶
View Source
var ( CurrentThread *Thread = &scheduleThread CurrentDomain *Domain = nil )
View Source
var KeycodeTranslation = map[int]uint8{
0: 42,
0x1E: 0x41,
}
View Source
var (
PerformSchedule = false
)
Functions ¶
func BlockThread ¶
func BlockThread(t *Thread)
func CreateNewPageDirectory ¶
func CreateNewThread ¶
func DisableIRQ ¶
func DisableIRQ(irq uint8)
func DisableInterrupts ¶
func DisableInterrupts()
func EnableInterrupts ¶
func EnableInterrupts()
func ExitDomain ¶
func ExitDomain(d *Domain)
func ExitThread ¶
func ExitThread(t *Thread)
func FindFreeTlsSlot ¶
func FindFreeTlsSlot() uint32
func FlushTlsTable ¶
func FlushTlsTable(table []GdtEntry)
func GetSegment ¶
func GetSegment(index int, res *GdtSegment) int
func InitInterrupts ¶
func InitInterrupts()
func InitKeyboard ¶
func InitKeyboard()
func InitMultiboot ¶
func InitMultiboot(info *MultibootInfo)
func InitPaging ¶
func InitPaging()
func InitScheduling ¶
func InitScheduling()
func InitSegments ¶
func InitSegments()
func InitSerialDevice ¶
func InitSerialDevice()
func InitSerialDeviceInterrupt ¶
func InitSerialDeviceInterrupt()
func InitUserMode ¶
func JumpUserMode ¶
func JumpUserMode(regs RegisterState, info InterruptInfo)
func KernelThreadInit ¶
func KernelThreadInit()
func LoadAuxVector ¶
func LoadElfFile ¶
func PICInterruptHandler ¶
func PICInterruptHandler()
func RegisterPICHandler ¶
func RegisterPICHandler(irq uint8, f func())
func ResumeThread ¶
func ResumeThread(t *Thread)
func SetInterruptHandler ¶
func SetInterruptHandler(irq uint8, f InterruptHandler, selector int, priv uint8)
func SetInterruptStack ¶
func SetInterruptStack(addr uintptr)
func SetTlsSegment ¶
func StartProgram ¶
Need pointer as this function should not do any memory allocations
func StartProgramUsr ¶
func TextModeFlushScreen ¶
func TextModeFlushScreen()
func TextModeInit ¶
func TextModeInit()
func TextModePrintLnCol ¶
Types ¶
type AtaDrive ¶
type AtaDrive struct {
IOBase uint16
ControlBase uint16
Initialized bool
IsSlave bool
IdentifyData [512]byte
IdentifyStruct AtaIdentify
}
func (*AtaDrive) Initialize ¶
func (d *AtaDrive) Initialize()
func (*AtaDrive) ReadSectors ¶
func (*AtaDrive) WriteSectors ¶
TODO: Explicit length?
type AtaIdentify ¶
type AtaIdentify struct {
NumSectorsPerTrack [2]uint8
// contains filtered or unexported fields
}
func (*AtaIdentify) InitFromBytes ¶
func (i *AtaIdentify) InitFromBytes(data []byte)
type Domain ¶
type Domain struct {
Pid uint32
Segments SegmentList
MemorySpace mm.MemSpace
ProgramName string
// contains filtered or unexported fields
}
func FindDomainByPid ¶
func (*Domain) RemoveThread ¶
type GdtDescriptor ¶
type GdtEntry ¶
type GdtEntry struct {
// contains filtered or unexported fields
}
type GdtSegment ¶
type GdtSegment struct {
// contains filtered or unexported fields
}
func (*GdtSegment) Clear ¶
func (s *GdtSegment) Clear()
func (*GdtSegment) IsPresent ¶
func (s *GdtSegment) IsPresent() bool
type GenericRing ¶
type GenericRing struct {
Cap int // Cannot use function as it requires memory allocation for a method reference
// contains filtered or unexported fields
}
func (*GenericRing) Len ¶
func (r *GenericRing) Len() int
func (*GenericRing) Pop ¶
func (r *GenericRing) Pop() int
func (*GenericRing) Push ¶
func (r *GenericRing) Push() int
type IdtDescriptor ¶
type InterruptHandler ¶
type InterruptHandler func()
type InterruptInfo ¶
type KeyboardRing ¶
type KeyboardRing struct {
Ring GenericRing
Buffer [32]Keystate
}
func (*KeyboardRing) Cap ¶
func (r *KeyboardRing) Cap() int
func (*KeyboardRing) Init ¶
func (r *KeyboardRing) Init()
func (*KeyboardRing) Len ¶
func (r *KeyboardRing) Len() int
func (*KeyboardRing) Pop ¶
func (r *KeyboardRing) Pop() *Keystate
func (*KeyboardRing) Push ¶
func (r *KeyboardRing) Push(s Keystate)
type MultibootInfo ¶
type MultibootInfo struct {
TotalSize uint32
// contains filtered or unexported fields
}
type MultibootMemoryMap ¶
type MultibootMemoryMap struct {
MultibootTag // Type is 6
EntrySize uint32
EntryVersion uint32
Entries MemoryMap // Take pointer of it and use it as slice with
}
type MultibootModule ¶
type MultibootModule struct {
MultibootTag
// Start is the inclusive start of the Module memory location
Start uint32
// End is the exclusive end of the Module memory location.
End uint32
// contains filtered or unexported fields
}
A module represents a module to be loaded along with the kernel.
func FindMultibootModule ¶
func FindMultibootModule(multibootModuleName string) (*MultibootModule, syscall.Errno)
func FindMultibootModuleUsr ¶
func FindMultibootModuleUsr(multibootModuleName uintptr) (*MultibootModule, syscall.Errno)
func (*MultibootModule) Cmdline ¶
func (m *MultibootModule) Cmdline() string
type MultibootTag ¶
type RegisterState ¶
type RegisterState struct {
GS uint32
FS uint32
ES uint32
DS uint32
EDI uint32
ESI uint32
EBP uint32
KernelESP uint32
EBX uint32
EDX uint32
ECX uint32
EAX uint32
}
Reverse of stack pushing
type SegmentList ¶
type SegmentList struct {
// contains filtered or unexported fields
}
type TextModeErrorWriter ¶
type TextModeErrorWriter struct {
}
type TextModeWriter ¶
type TextModeWriter struct {
}
type Thread ¶
type Thread struct {
Next *Thread
Domain *Domain
Tid uint32
// Currently ignored '^^ I don't have to do it thanks to spurious wakeups
IsBlocked bool
WaitAddress *uint32
Regs RegisterState
KernelRegs RegisterState
IsKernelInterrupt bool
// contains filtered or unexported fields
}
type UARTSerialDevice ¶
type UARTSerialDevice struct {
BasePort uint16
// contains filtered or unexported fields
}
var (
SerialDevice UARTSerialDevice
)
func (UARTSerialDevice) HasReceivedData ¶
func (d UARTSerialDevice) HasReceivedData() bool
func (*UARTSerialDevice) Initialize ¶
func (d *UARTSerialDevice) Initialize() syscall.Errno
func (UARTSerialDevice) Read ¶
func (d UARTSerialDevice) Read() uint8
func (UARTSerialDevice) WriteChar ¶
func (d UARTSerialDevice) WriteChar(arg byte)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
This package exists so that there is a main.main symbol This will cause the go compiler to emit an ELF file instead of a go archive I need an ELF file to build the kernel
|
This package exists so that there is a main.main symbol This will cause the go compiler to emit an ELF file instead of a go archive I need an ELF file to build the kernel |
Click to show internal directories.
Click to hide internal directories.