mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-06-07 08:14:48 +00:00
Added comments to PICInit, fixed some of KernelA.
This commit is contained in:
parent
93fc6abc29
commit
d45d9ecc38
Binary file not shown.
@ -1,4 +1,9 @@
|
||||
$WW,1$$FG,5$$TX+CX,"ChangeLog"$$FG$
|
||||
$IV,1$----04/13/20 13:48:15----$IV,0$
|
||||
* Added $LK,"PIC_INIT",A="MN:PIC_INIT"$ and comments to $LK,"IntPICInit",A="MN:IntPICInit"$().
|
||||
* $LK,"R",A="MN:R"$("IntsInit", "$LK,"IntPICInit",A="MN:IntPICInit"$");
|
||||
* $LK,"R",A="MN:R"$("LAPIC_ARIBITRATION_PRIORITY", "$LK,"LAPIC_ARBITRATION_PRIORITY",A="MN:LAPIC_ARBITRATION_PRIORITY"$");
|
||||
|
||||
$IV,1$----04/12/20 17:06:38----$IV,0$
|
||||
* Added $LK,"CIDTEntry",A="MN:CIDTEntry"$ and rewrote $LK,"IntEntryGet",A="MN:IntEntryGet"$() and $LK,"IntEntrySet",A="MN:IntEntrySet"$(). $LK,"dev",A="MN:CDevGlobals"$.idt is now $LK,"allocated",A="FF:::/Kernel/KInterrupts.CC,CAllocAligned"$ on an 8-byte boundary as per Intel SDM recommendation.
|
||||
* Updated $LK,"OS version",A="MN:sys_os_version"$.
|
||||
|
@ -4,7 +4,7 @@ If a feature cannot be made to work correctly and consistently, professional com
|
||||
|
||||
The PCI bus interface is what modern hardware uses. Before PCI, life was simple and devices used I/O ports. After studying $LK,"PCI Interrupts",A="FI:::/Demo/Lectures/PCIInterrupts.CC"$ and attempting to do a HDAudio driver, I came to realize that modern PCI devices require ten times more code and I cannot even come close to making them work on everyone's machine because with PCI devices there are several models to worry about, unlike with the older ISA bus devices which can be done with one driver.
|
||||
|
||||
Currently, I have no PCI drivers. My drivers use I/O ports and operate in ISA bus mode. At this point, I only have one driver for each type of device and it is delightfully simple that way. I have one $LK,"keyboard",A="FI:::/Kernel/SerialDev/Keyboard.CC"$ driver, one $LK,"mouse",A="FI:::/Kernel/SerialDev/Mouse.CC"$ driver, one $LK,"ATA hard drive",A="FI:::/Kernel/BlkDev/DiskATA.CC"$ driver, one $LK,"ATAPI CD/DVD",A="FI:::/Kernel/BlkDev/DiskATA.CC"$ driver, one $LK,"VGA 640x480 16 color",A="FI:::/Zenith/Gr/GrScreen.CC"$ video driver and one $LK,"PC Speaker",A="MN:Sound"$ driver. I use the $LK,"PIT timer",A="MN:TimerInit"$ and $LK,"PIC Interrupt Controller",A="MN:IntsInit"$. I use IRQ0 for timer, IRQ1 for keyboard, and IRQ12 for mouse. If IRQ12 is not firing, I am able to poll the mouse.
|
||||
Currently, I have no PCI drivers. My drivers use I/O ports and operate in ISA bus mode. At this point, I only have one driver for each type of device and it is delightfully simple that way. I have one $LK,"keyboard",A="FI:::/Kernel/SerialDev/Keyboard.CC"$ driver, one $LK,"mouse",A="FI:::/Kernel/SerialDev/Mouse.CC"$ driver, one $LK,"ATA hard drive",A="FI:::/Kernel/BlkDev/DiskATA.CC"$ driver, one $LK,"ATAPI CD/DVD",A="FI:::/Kernel/BlkDev/DiskATA.CC"$ driver, one $LK,"VGA 640x480 16 color",A="FI:::/Zenith/Gr/GrScreen.CC"$ video driver and one $LK,"PC Speaker",A="MN:Sound"$ driver. I use the $LK,"PIT timer",A="MN:TimerInit"$ and $LK,"PIC Interrupt Controller",A="MN:IntPICInit"$. I use IRQ0 for timer, IRQ1 for keyboard, and IRQ12 for mouse. If IRQ12 is not firing, I am able to poll the mouse.
|
||||
|
||||
In the CPU department, I have state of the art 64-bit $LK,"long mode",A="FI:::/Kernel/KStart64.CC"$ with $LK,"multicore",A="FI:::/Kernel/MultiProc.CC"$ support. I use the $LK,"APIC",A="MN:MPAPICInit"$ and start-up $LK,"multicore",A="MN:Core0StartMP"$ operation.
|
||||
|
||||
|
@ -8,11 +8,12 @@ CDoc *sys_clip_doc;
|
||||
CTask *zenith_task;
|
||||
I64 sys_num_spawned_tasks;
|
||||
|
||||
CTask *sys_winmgr_task,*sys_task_being_screen_updated;
|
||||
CTask *sys_winmgr_task,
|
||||
*sys_task_being_screen_updated;
|
||||
U8 *rev_bits_table; //Table with U8 bits reversed
|
||||
CDate local_time_offset;
|
||||
F64 *pow10_I64,
|
||||
sys_os_version=1.12;
|
||||
sys_os_version = 1.12;
|
||||
|
||||
CAutoCompleteDictGlobals acd;
|
||||
CAutoCompleteGlobals ac;
|
||||
|
@ -125,16 +125,16 @@ U8 *IntEntrySet(I64 irq, U0 (*fp_new_handler)(), I64 type=IDTET_IRQ)
|
||||
return old_handler;
|
||||
}
|
||||
|
||||
U0 IntsInit()
|
||||
U0 IntPICInit()
|
||||
{//Init 8259
|
||||
OutU8(PIC_1, 0x11); //IW1
|
||||
OutU8(PIC_2, 0x11); //IW1
|
||||
OutU8(PIC_1_DATA, 0x20); //IW2
|
||||
OutU8(PIC_2_DATA, 0x28); //IW2
|
||||
OutU8(PIC_1_DATA, 0x04); //IW3
|
||||
OutU8(PIC_2_DATA, 0x02); //IW3
|
||||
OutU8(PIC_1_DATA, 0x0D); //IW4
|
||||
OutU8(PIC_2_DATA, 0x09); //IW4
|
||||
OutU8(PIC_1, PIC_INIT); //IW (Initialization Word) 1
|
||||
OutU8(PIC_2, PIC_INIT); //IW1
|
||||
OutU8(PIC_1_DATA, 0x20); //IW2 Moving IRQ base from 0 -> 32 (beyond Intel reserved faults)
|
||||
OutU8(PIC_2_DATA, 0x28); //IW2 Moving IRQ base from 8 -> 40
|
||||
OutU8(PIC_1_DATA, 0x04); //IW3 Telling PIC_1 PIC_2 exists.
|
||||
OutU8(PIC_2_DATA, 0x02); //IW3 Telling PIC_2 its cascade identity.
|
||||
OutU8(PIC_1_DATA, 0x0D); //IW4 8086 Mode, Buffered Mode (Master PIC)
|
||||
OutU8(PIC_2_DATA, 0x09); //IW4 8086 Mode, Buffered Mode (Slave PIC)
|
||||
OutU8(PIC_1_DATA, 0xFA); //Mask all but IRQ0 (timer) and IRQ2 Cascade.
|
||||
OutU8(PIC_2_DATA, 0xFF);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ U0 KMain()
|
||||
if (MemBIOSTotal < ToI64 (0.95*MEM_MIN_MEG*0x100000) )
|
||||
RawPrint(4000,"!!! Requires $TX,"256Meg",D="DD_MEM_MIN_MEG"$ of RAM Memory !!!");
|
||||
|
||||
IntsInit;
|
||||
IntPICInit;
|
||||
"Enable IRQs\n";
|
||||
RFlagsSet(RFLAGG_NORMAL);
|
||||
Busy(2000);
|
||||
|
@ -59,12 +59,9 @@ extern class CTask;
|
||||
#define eps (0x3CB0000000000000(F64))
|
||||
|
||||
#help_index "Data Types/Simple"
|
||||
/*CosmiC union structure is treated as a
|
||||
whole if no member is specified,
|
||||
similar to bit fields.
|
||||
//CosmiC union structure is treated as a whole if no member is specified, similar to bit fields.
|
||||
//See $LK,"::/Demo/SubIntAccess.CC"$.
|
||||
|
||||
See $LK,"::/Demo/SubIntAccess.CC"$.
|
||||
*/
|
||||
U16i union U16
|
||||
{
|
||||
I8i i8[2];
|
||||
@ -116,55 +113,58 @@ I64i union I64
|
||||
#help_index "Math/Complex;Data Types/Complex"
|
||||
public class Complex
|
||||
{
|
||||
F64 x,y;
|
||||
F64 x, y;
|
||||
};
|
||||
|
||||
#help_index "Data Types/Circular Queue"
|
||||
public class CQueue
|
||||
{
|
||||
CQueue *next,*last;
|
||||
CQueue *next, *last;
|
||||
};
|
||||
|
||||
#help_index "Graphics/Data Types/D3I32;Math/Data Types/D3I32;Data Types/D3I32"
|
||||
public class CD3I32 //Three dimensional I32 pt
|
||||
{
|
||||
I32 x,y,z;
|
||||
I32 x, y, z;
|
||||
};
|
||||
public class CQueueD3I32 //Queue of three dimensional I32 pts
|
||||
{
|
||||
CQueueD3I32 *next,*last;
|
||||
CQueueD3I32 *next, *last;
|
||||
CD3I32 p;
|
||||
};
|
||||
#help_index "Math/Data Types;Data Types"
|
||||
public class CD2I32 //Two dimensional I32 pt
|
||||
{
|
||||
I32 x,y;
|
||||
I32 x, y;
|
||||
};
|
||||
public class CD2I64 //Two dimensional I64 pt
|
||||
{
|
||||
I64 x,y;
|
||||
I64 x, y;
|
||||
};
|
||||
public class CD3I64 //Three dimensional I64 pt
|
||||
{
|
||||
I64 x,y,z;
|
||||
I64 x, y, z;
|
||||
};
|
||||
public class CD2 //Two dimensional F64 pt
|
||||
{
|
||||
F64 x,y;
|
||||
F64 x, y;
|
||||
};
|
||||
|
||||
#help_index "Math/CD3;Data Types/CD3"
|
||||
public class CD3 //Three dimensional F64 pt
|
||||
{
|
||||
F64 x,y,z;
|
||||
F64 x, y, z;
|
||||
};
|
||||
|
||||
#help_index "Data Types/Queue Vector"
|
||||
#define QUE_VECT_U8_COUNT 512
|
||||
public class CQueueVectU8
|
||||
{
|
||||
CQueueVectU8 *next,*last;
|
||||
I64 total_count,node_count,min_idx;
|
||||
CQueueVectU8 *next,
|
||||
*last;
|
||||
I64 total_count,
|
||||
node_count,
|
||||
min_idx;
|
||||
U8 body[QUE_VECT_U8_COUNT];
|
||||
};
|
||||
|
||||
@ -172,12 +172,16 @@ public class CQueueVectU8
|
||||
public class CFifoU8
|
||||
{
|
||||
U8 *buf;
|
||||
I64 mask,in_ptr,out_ptr;
|
||||
I64 mask,
|
||||
in_ptr,
|
||||
out_ptr;
|
||||
};
|
||||
public class CFifoI64
|
||||
{
|
||||
I64 *buf;
|
||||
I64 mask,in_ptr,out_ptr;
|
||||
I64 *buf,
|
||||
mask,
|
||||
in_ptr,
|
||||
out_ptr;
|
||||
};
|
||||
#help_index "Date/CMOS"
|
||||
#define CMOS_SEL 0x70 //select which reg to access using this port
|
||||
@ -211,16 +215,22 @@ public I64 class CDate
|
||||
#help_index "Date;Date/CDate"
|
||||
public class CDateStruct
|
||||
{
|
||||
U8 sec10000,sec100,sec,min,hour,
|
||||
day_of_week,day_of_mon,mon;
|
||||
U8 sec10000,
|
||||
sec100,
|
||||
sec,
|
||||
min,
|
||||
hour,
|
||||
day_of_week,
|
||||
day_of_mon,
|
||||
mon;
|
||||
I32 year;
|
||||
};
|
||||
|
||||
#help_index "Math/ODE"
|
||||
public class COrder2D3
|
||||
{
|
||||
F64 x,y,z,
|
||||
DxDt,DyDt,DzDt;
|
||||
F64 x, y, z,
|
||||
DxDt, DyDt, DzDt;
|
||||
};
|
||||
|
||||
#define MSF_INACTIVE 1
|
||||
@ -232,8 +242,10 @@ public class CMass
|
||||
*DstateDt; //Point to entries in $LK,"CMathODE",A="MN:CMathODE"$.DstateDt[]
|
||||
|
||||
U0 start;
|
||||
U32 flags,num;
|
||||
F64 mass,drag_profile_factor;
|
||||
U32 flags,
|
||||
num;
|
||||
F64 mass,
|
||||
drag_profile_factor;
|
||||
U0 saved_state;
|
||||
F64 x,y,z,
|
||||
DxDt,DyDt,DzDt;
|
||||
@ -484,33 +496,28 @@ class CPatchTableAbsAddr
|
||||
#define IET_ZEROED_DATA_HEAP 24 //Not really used
|
||||
#define IET_MAIN 25
|
||||
|
||||
|
||||
#help_index "Graphics/VBE"
|
||||
|
||||
#define BLACK32 0x000000
|
||||
#define WHITE32 0xFFFFFF
|
||||
|
||||
#define VBE_MODES_NUM 32
|
||||
|
||||
class CVBEInfo
|
||||
{
|
||||
U8 signature[4];
|
||||
|
||||
U16 version;
|
||||
|
||||
U32 oem,
|
||||
capabilities,
|
||||
video_modes;
|
||||
|
||||
U16 total_memory,
|
||||
software_revision;
|
||||
|
||||
U32 vendor,
|
||||
product_name,
|
||||
product_revision;
|
||||
|
||||
U8 reserved[222],
|
||||
oem_data[256];
|
||||
};
|
||||
#assert sizeof(CVBEInfo)==512
|
||||
#assert sizeof(CVBEInfo) == 512
|
||||
|
||||
class CVBEMode
|
||||
{
|
||||
@ -519,22 +526,17 @@ class CVBEMode
|
||||
pitch,
|
||||
width,
|
||||
height;
|
||||
|
||||
U8 pad[3],
|
||||
bpp,
|
||||
pad,
|
||||
memory_model,
|
||||
pad[12];
|
||||
|
||||
U32 framebuffer;
|
||||
|
||||
U16 pad[9];
|
||||
|
||||
U32 max_pixel_clock;
|
||||
|
||||
U8 reserved[190];
|
||||
};
|
||||
#assert sizeof(CVBEMode)==256
|
||||
#assert sizeof(CVBEMode) == 256
|
||||
|
||||
class CVBEModeShort
|
||||
{
|
||||
@ -631,6 +633,7 @@ class CKernel
|
||||
#define PIC_1_DATA 0x21
|
||||
#define PIC_2 0xA0
|
||||
#define PIC_2_DATA 0xA1
|
||||
#define PIC_INIT 0x11
|
||||
#define PIC_EOI 0x20 //End of interrupt
|
||||
|
||||
//Local Advanced Programmable Interrupt Controller
|
||||
@ -638,7 +641,7 @@ class CKernel
|
||||
#define LAPIC_APIC_ID (LAPIC_BASE+0x020)
|
||||
#define LAPIC_APIC_VERSION (LAPIC_BASE+0x030)
|
||||
#define LAPIC_TASK_PRIORITY (LAPIC_BASE+0x080)
|
||||
#define LAPIC_ARIBITRATION_PRIORITY (LAPIC_BASE+0x090)
|
||||
#define LAPIC_ARBITRATION_PRIORITY (LAPIC_BASE+0x090)
|
||||
#define LAPIC_PROCESSOR_PRIORITY (LAPIC_BASE+0x0A0)
|
||||
#define LAPIC_EOI (LAPIC_BASE+0x0B0)
|
||||
#define LAPIC_LOG_DST (LAPIC_BASE+0x0D0)
|
||||
@ -3452,13 +3455,8 @@ public class CKbdStateGlobals
|
||||
new_key_timestamp; //Output: TSCGet when new key event.
|
||||
CFifoU8 *fifo,*fifo2; //Private
|
||||
CFifoI64 *scan_code_fifo;
|
||||
|
||||
//BitTest, $LK,"Bt",A="MN:Bt"$(), with a merged scan code.
|
||||
//(Left and right shift merged, for example.)
|
||||
U32 down_bitmap[8],
|
||||
//BitTest, $LK,"Bt",A="MN:Bt"$(), with an unmerged scan code.
|
||||
down_bitmap2[8];
|
||||
|
||||
U32 down_bitmap[8], //BitTest, $LK,"Bt",A="MN:Bt"$(), with a merged scan code. (Left and right shift merged, for example.)
|
||||
down_bitmap2[8]; //BitTest, $LK,"Bt",A="MN:Bt"$(), with an unmerged scan code.
|
||||
Bool reset, //Private: Reset KbdMouse
|
||||
irqs_working; //Private
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user