/NetOSr0/kernel/devices.c - documentation
Ok, NetOSr0 is a short. The full name is New Technology Operating System release 0.
All tasks in scheduler managment are called system_structure_t.
This is the code:
struct system_structure_s
{
/* SYSTEM_STRUCTURE MUST HAVE 900 (+-4) byte! */
tss_t tss;
uint16 gdt_entry;
uint32 pid;
uint8 name[100];
uint8 granularity[596]; /* we sets structure granularities [900 - ... = granularity] */
uint8 reqversion;
uint8 version;
uint8 author[50];
uint8 type; /* is task, driver, anything else ? */
uint8 active;
uint8 enabled;
uint8 privilage; /* 0 - su, 1 - user, 2 - slave */
uint32 begin_adress;
uint32 end_adress;
uint32 buf_in;
uint32 buf_out;
system_structure_t *next; /* for scheduling */
system_structure_t *prev;
uint8 priv_type; /* private system structure type */
uint32 ip_list;
uint32 op_list;
};
Devices driver is represent in system by driver (system_structure_t).
If i want make driver i write in my o.s code for example that:
/************************************************************
system_structure_t *drv;
module_t *drv_module; (for now - modules are only from grub)
drv = craete_driver(drv_module,"Generic keyboard driver"); /* first - module, second - name */
drv -> type = KEYB_DRV; /* (0x21) */
drv -> pid = get_driver_pid(drv); /* 1024 + type_of_driver example: KEYB_DRV_PID = (uint32) 1024 + (uint32) 0x21 */
add_driver(drv);
************************************************************/
Function add_driver(system_structure_t *driver) adds driver to SSDB (System Structures Data Base)
and to SDDB (System Drivers Data Base). This Data Bases are tables in memory with 1024 slots.
Evry Slot has adress of system_structure_t structure. Next, add_driver(...) calling functions
register_user_buffers(...) - this function allocates 2 * 4096 byte for driver buffers (this buffers are
creates with evry structure - task, drivers ...
There are two buffers for every system_structure: input buffer and output buffer.
In input buffer drivers has request from other tasks to execute some functions, tasks has answeres from driver
To the output buffer system structures sends requests for drivers. The ASM (Advanced Syscalls Manager) getting
requests from task output buffer to the driver input buffer. Driver getting request from
input buffer executes request and answered to the output buffer. The ASM getting answer from driver
output buffer and sends it to the task input buffer. If task got answer for request continuing executing code.
The requests are sending in 16KiB packets. Every packets has 4 entry:
1: sending_task_pid
2: value 1
3: value 2
4: value 3
The values are like as registers in real mode.
Example, I'am in user task (ring3) and I would sends putchar('c') request to the terminal driver.
in task code i write that:
putchar('c')
but in library this function is defined that:
fill_user_packet(2,'c',0) - first argument sends that function number 2 must be executing for task request.
- second argument has what we want put on screen
- argument number 3 is empty (not used)
send_user_packet(TERM_DRV); /* 0x100 */
i = count_input_answers();
while(i == count_input_answers())
{
}
The task pid adds ASM.
And of course drivers had i/o ports list.
If in driver i/o list is requested port - driver can uses it.
Ok, This work perfectly:) but veryyyyyyy slowly:(
If you have any questions for me - write on
[email protected]