Basic VM and other minor improvements.
Not complete, probably not fully debugged or optimized.
This commit is contained in:
@@ -36,4 +36,8 @@
|
||||
#define KIOCSLEDS _IOW('k', 2, struct kio_leds)
|
||||
#define KIOCSMAP _IOW('k', 3, keymap_t)
|
||||
|
||||
/* /dev/video ioctls. */
|
||||
#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm)
|
||||
#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm)
|
||||
|
||||
#endif /* _S_I_TTY_H */
|
||||
|
||||
29
include/sys/mman.h
Executable file
29
include/sys/mman.h
Executable file
@@ -0,0 +1,29 @@
|
||||
|
||||
#ifndef _MMAN_H
|
||||
#define _MMAN_H
|
||||
|
||||
#ifndef _TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* prot argument for mmap() */
|
||||
#define PROT_NONE 0x00 /* no permissions */
|
||||
#define PROT_READ 0x01 /* pages can be read */
|
||||
#define PROT_WRITE 0x02 /* pages can be written */
|
||||
#define PROT_EXEC 0x04 /* pages can be executed */
|
||||
|
||||
/* flags argument for mmap() */
|
||||
#define MAP_SHARED 0x0001 /* share changes */
|
||||
#define MAP_PRIVATE 0x0002 /* changes are private */
|
||||
#define MAP_ANON 0x0004 /* anonymous memory */
|
||||
#define MAP_PREALLOC 0x0008 /* not on-demand */
|
||||
#define MAP_CONTIG 0x0010 /* contiguous in physical memory */
|
||||
#define MAP_LOWER16M 0x0020 /* physically below 16MB */
|
||||
|
||||
/* mmap() error return */
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
|
||||
_PROTOTYPE( void *mmap, (void *, size_t, int, int, int, off_t));
|
||||
_PROTOTYPE( int munmap, (void *, size_t));
|
||||
|
||||
#endif /* _MMAN_H */
|
||||
39
include/sys/video.h
Normal file
39
include/sys/video.h
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
#ifndef _SYS_VIDEO_H
|
||||
#define _SYS_VIDEO_H 1
|
||||
|
||||
/* Definitions used by the console driver. */
|
||||
#define MONO_BASE 0xB0000L /* base of mono video memory */
|
||||
#define COLOR_BASE 0xB8000L /* base of color video memory */
|
||||
#define MONO_SIZE 0x1000 /* 4K mono video memory */
|
||||
#define COLOR_SIZE 0x4000 /* 16K color video memory */
|
||||
#define EGA_SIZE 0x8000 /* EGA & VGA have at least 32K */
|
||||
#define BLANK_COLOR 0x0700 /* determines cursor color on blank screen */
|
||||
#define SCROLL_UP 0 /* scroll forward */
|
||||
#define SCROLL_DOWN 1 /* scroll backward */
|
||||
#define BLANK_MEM ((u16_t *) 0) /* tells mem_vid_copy() to blank the screen */
|
||||
#define CONS_RAM_WORDS 80 /* video ram buffer size */
|
||||
#define MAX_ESC_PARMS 4 /* number of escape sequence params allowed */
|
||||
|
||||
/* Constants relating to the controller chips. */
|
||||
#define M_6845 0x3B4 /* port for 6845 mono */
|
||||
#define C_6845 0x3D4 /* port for 6845 color */
|
||||
#define INDEX 0 /* 6845's index register */
|
||||
#define DATA 1 /* 6845's data register */
|
||||
#define STATUS 6 /* 6845's status register */
|
||||
#define VID_ORG 12 /* 6845's origin register */
|
||||
#define CURSOR 14 /* 6845's cursor register */
|
||||
|
||||
/* Beeper. */
|
||||
#define BEEP_FREQ 0x0533 /* value to put into timer to set beep freq */
|
||||
#define B_TIME 3 /* length of CTRL-G beep is ticks */
|
||||
|
||||
/* definitions used for font management */
|
||||
#define GA_SEQUENCER_INDEX 0x3C4
|
||||
#define GA_SEQUENCER_DATA 0x3C5
|
||||
#define GA_GRAPHICS_INDEX 0x3CE
|
||||
#define GA_GRAPHICS_DATA 0x3CF
|
||||
#define GA_VIDEO_ADDRESS 0xA0000L
|
||||
#define GA_FONT_SIZE 8192
|
||||
|
||||
#endif
|
||||
@@ -2,8 +2,6 @@
|
||||
sys/vm.h
|
||||
*/
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
/* MIOCMAP */
|
||||
struct mapreq
|
||||
{
|
||||
@@ -13,18 +11,14 @@ struct mapreq
|
||||
int readonly;
|
||||
};
|
||||
|
||||
/* i386 paging constants */
|
||||
#define I386_VM_PRESENT 0x001 /* Page is present */
|
||||
#define I386_VM_WRITE 0x002 /* Read/write access allowed */
|
||||
#define I386_VM_USER 0x004 /* User access allowed */
|
||||
#define I386_VM_PWT 0x008 /* Write through */
|
||||
#define I386_VM_PCD 0x010 /* Cache disable */
|
||||
#define I386_VM_ADDR_MASK 0xFFFFF000 /* physical address */
|
||||
|
||||
#define I386_VM_PT_ENT_SIZE 4 /* Size of a page table entry */
|
||||
#define I386_VM_DIR_ENTRIES 1024 /* Number of entries in a page dir */
|
||||
#define I386_VM_DIR_ENT_SHIFT 22 /* Shift to get entry in page dir. */
|
||||
#define I386_VM_PT_ENT_SHIFT 12 /* Shift to get entry in page table */
|
||||
#define I386_VM_PT_ENT_MASK 0x3FF /* Mask to get entry in page table */
|
||||
|
||||
#define I386_CR0_PG 0x80000000 /* Enable paging */
|
||||
/* MIOCMAPVM */
|
||||
struct mapreqvm
|
||||
{
|
||||
int flags; /* reserved, must be 0 */
|
||||
off_t phys_offset;
|
||||
size_t size;
|
||||
int readonly;
|
||||
char reserved[40]; /* reserved, must be 0 */
|
||||
void *vaddr_ret; /* result vaddr */
|
||||
};
|
||||
|
||||
45
include/sys/vm_i386.h
Normal file
45
include/sys/vm_i386.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
sys/vm_i386.h
|
||||
*/
|
||||
|
||||
#define I386_PAGE_SIZE 4096
|
||||
|
||||
/* i386 paging constants */
|
||||
#define I386_VM_PRESENT 0x001 /* Page is present */
|
||||
#define I386_VM_WRITE 0x002 /* Read/write access allowed */
|
||||
#define I386_VM_USER 0x004 /* User access allowed */
|
||||
#define I386_VM_PWT 0x008 /* Write through */
|
||||
#define I386_VM_PCD 0x010 /* Cache disable */
|
||||
#define I386_VM_ACC 0x020 /* Accessed */
|
||||
#define I386_VM_ADDR_MASK 0xFFFFF000 /* physical address */
|
||||
|
||||
/* Page directory specific flags. */
|
||||
#define I386_VM_BIGPAGE 0x080 /* 4MB page */
|
||||
|
||||
/* Page table specific flags. */
|
||||
#define I386_VM_DIRTY 0x040 /* Dirty */
|
||||
#define I386_VM_PTAVAIL1 0x080 /* Available for use. */
|
||||
#define I386_VM_PTAVAIL2 0x100 /* Available for use. */
|
||||
|
||||
#define I386_VM_PT_ENT_SIZE 4 /* Size of a page table entry */
|
||||
#define I386_VM_DIR_ENTRIES 1024 /* Number of entries in a page dir */
|
||||
#define I386_VM_DIR_ENT_SHIFT 22 /* Shift to get entry in page dir. */
|
||||
#define I386_VM_PT_ENT_SHIFT 12 /* Shift to get entry in page table */
|
||||
#define I386_VM_PT_ENT_MASK 0x3FF /* Mask to get entry in page table */
|
||||
#define I386_VM_PT_ENTRIES 1024 /* Number of entries in a page table */
|
||||
#define I386_VM_PFA_SHIFT 22 /* Page frame address shift */
|
||||
|
||||
#define I386_CR0_PG 0x80000000 /* Enable paging */
|
||||
|
||||
/* i386 paging 'functions' */
|
||||
#define I386_VM_PTE(v) (((v) >> I386_VM_PT_ENT_SHIFT) & I386_VM_PT_ENT_MASK)
|
||||
#define I386_VM_PDE(v) ( (v) >> I386_VM_DIR_ENT_SHIFT)
|
||||
#define I386_VM_PFA(e) ( (e) & I386_VM_ADDR_MASK)
|
||||
#define I386_VM_PAGE(v) ( (v) >> I386_VM_PFA_SHIFT)
|
||||
|
||||
/* i386 pagefault error code bits */
|
||||
#define I386_VM_PFE_P 0x01 /* Pagefault caused by non-present page.
|
||||
* (otherwise protection violation.)
|
||||
*/
|
||||
#define I386_VM_PFE_W 0x02 /* Caused by write (otherwise read) */
|
||||
#define I386_VM_PFE_U 0x04 /* CPU in user mode (otherwise supervisor) */
|
||||
Reference in New Issue
Block a user