mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-24 22:50:28 +00:00
Fix USB.ZC enough to compile.
This commit is contained in:
parent
9182775637
commit
e3f3c7cd09
1 changed files with 207 additions and 217 deletions
|
@ -1,217 +1,207 @@
|
||||||
/*
|
|
||||||
You can play with this if you are
|
#help_index "USB"
|
||||||
interested in USB.I'm not planning
|
|
||||||
on doing USB unless the legacy PS2
|
extern I64 sys_num_usb;
|
||||||
keyboard/mouse mode disappears.
|
extern CUSB sys_usb_devs[USB_NUM];
|
||||||
There EHCI UHCI in various ICH chips and
|
extern CUSBTD *USBAllocTD();
|
||||||
others and God knows how many custom packet
|
extern U0 USBFreeTD(CUSBTD *tmptd);
|
||||||
formats for different keyboards and mice.Okay,
|
extern U0 USBEndAll();
|
||||||
I suppose if BIOS can make a universal
|
extern U0 USBInitAll();
|
||||||
packet, it is done just one way for
|
extern U32 *USBAllocFrameLst(I64 usb_num, I64 size);
|
||||||
different mice.PS2 is more compatible.
|
|
||||||
|
U8 *StatCB(CDoc *, CDocEntry *doc_e, CTask *mem_task)
|
||||||
*/
|
{
|
||||||
#help_index "USB"
|
//This routine shows the stat of the USB ports
|
||||||
extern I64 sys_num_usb;
|
U8 *st = MAlloc(128, mem_task);
|
||||||
extern CUSB sys_usb_devs[USB_NUM];
|
U16 w1, w2, w3, w4;
|
||||||
extern CUSBTD *USBAllocTD();
|
U32 d1;
|
||||||
extern U0 USBFreeTD(CUSBTD *tmptd);
|
CUSB *u = doc_e->user_data;
|
||||||
extern U0 USBEndAll();
|
I64 d = u->ports;
|
||||||
extern U0 USBInitAll();
|
w3 = InU16(d + USBP_STS);
|
||||||
extern U32 *USBAllocFrameLst(I64 usb_num, I64 size);
|
w1 = InU16(d + USBP_PORTSC0);
|
||||||
|
w2 = InU16(d + USBP_PORTSC1);
|
||||||
U8 *StatCB(CDoc *, CDocEntry *doc_e, CTask *mem_task)
|
w4 = InU16(d + USBP_FRNUM);
|
||||||
{
|
d1 = InU32(d + USBP_FRBASEADD);
|
||||||
//This routine shows the stat of the USB ports
|
StrPrint(st, "%X:Stat:%04X P0:%04X P1:%04X FRAME:%04X", d1, w3, w1, w2, w4);
|
||||||
U8 *st = MAlloc(128, mem_task);
|
return st;
|
||||||
U16 w1, w2, w3, w4;
|
}
|
||||||
U32 d1;
|
|
||||||
CUSB *u = doc_e->user_data;
|
U0 PutStat()
|
||||||
I64 d = u->ports;
|
{
|
||||||
w3 = InU16(d + USBP_STS);
|
I64 i;
|
||||||
w1 = InU16(d + USBP_PORTSC0);
|
CDocEntry *doc_e;
|
||||||
w2 = InU16(d + USBP_PORTSC1);
|
CUSB *u;
|
||||||
w4 = InU16(d + USBP_FRNUM);
|
WinMax;
|
||||||
d1 = InU32(d + USBP_FRBASEADD);
|
|
||||||
StrPrint(st, "%X:Stat:%04X P0:%04X P1:%04X FRAME:%04X", d1, w3, w1, w2, w4);
|
"$$FG,GREEN$$Dev Stat Bits\n$$FG$$"
|
||||||
return st;
|
" 0:IRQ\n"
|
||||||
}
|
" 1:IRQ err\n"
|
||||||
|
" 2:Resume\n"
|
||||||
U0 PutStat()
|
" 3:Host Sys Err\n"
|
||||||
{
|
" 4:Host Process Err\n"
|
||||||
I64 i;
|
" 5:Halted\n"
|
||||||
CDocEntry *doc_e;
|
"$$FG,GREEN$$Port Stat Bits\n$$FG$$"
|
||||||
CUSB *u;
|
" 0:Connection Stat\n"
|
||||||
WinMax;
|
" 1:Connection Stat Change\n"
|
||||||
|
" 2:Port Enabled\n"
|
||||||
"$$FG,GREEN$$Dev Stat Bits\n$$FG$$"
|
" 3:Port Enabled Change\n"
|
||||||
" 0:IRQ\n"
|
"4-5:Line Stat\n"
|
||||||
" 1:IRQ err\n"
|
" 6:Resume Detect\n"
|
||||||
" 2:Resume\n"
|
" 8:Low Speed\n"
|
||||||
" 3:Host Sys Err\n"
|
" 9:Port Rst\n"
|
||||||
" 4:Host Process Err\n"
|
" 10:Overcurrent Active\n"
|
||||||
" 5:Halted\n"
|
" 11:Overcurrent Indicator\n"
|
||||||
"$$FG,GREEN$$Port Stat Bits\n$$FG$$"
|
" 12:Suspend\n\n";
|
||||||
" 0:Connection Stat\n"
|
|
||||||
" 1:Connection Stat Change\n"
|
for (i = 0; i < sys_num_usb; i++)
|
||||||
" 2:Port Enabled\n"
|
{
|
||||||
" 3:Port Enabled Change\n"
|
u = &sys_usb_devs[i];
|
||||||
"4-5:Line Stat\n"
|
"$$FG,LTRED$$Dev%d:%X:", i, u->ports;
|
||||||
" 6:Resume Detect\n"
|
doc_e = DocPrint(DocPut, "$$TX+TC,\" \"$$");
|
||||||
" 8:Low Speed\n"
|
doc_e->user_data = &sys_usb_devs[i];
|
||||||
" 9:Port Rst\n"
|
doc_e->tag_cb = &StatCB;
|
||||||
" 10:Overcurrent Active\n"
|
"$$FG$$\n";
|
||||||
" 11:Overcurrent Indicator\n"
|
}
|
||||||
" 12:Suspend\n\n";
|
|
||||||
|
// NewLine;
|
||||||
for (i = 0; i < sys_num_usb; i++)
|
"\n";
|
||||||
{
|
}
|
||||||
u = &sys_usb_devs[i];
|
|
||||||
"$$FG,LTRED$$Dev%d:%X:", i, u->ports;
|
extern U0 PutQH(U32 h);
|
||||||
doc_e = DocPrint(DocPut, "$$TX+TC,\" \"$$");
|
|
||||||
doc_e->user_data = &sys_usb_devs[i];
|
U32 *P(U32 d)
|
||||||
doc_e->tag_cb = &StatCB;
|
{
|
||||||
"$$FG$$\n";
|
return d & ~3;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewLine;
|
U0 PutTD(U32 t)
|
||||||
}
|
{
|
||||||
|
"TD:$$FG,GREEN$$%08X$$FG$$\n", t;
|
||||||
extern U0 PutQH(U32 h);
|
"%08X\n", *P(t);
|
||||||
|
DocDumpMem(t + 4, 8);
|
||||||
U32 *P(U32 d)
|
if (*P(t + 12))
|
||||||
{
|
DocDumpMem(*P(t + 12), 16);
|
||||||
return d & ~3;
|
// DocDumpMem(*P(t+12), *P(t+4) >> 21 & 0x7FF);
|
||||||
}
|
if (!(*P(t) & 1))
|
||||||
|
{
|
||||||
U0 PutTD(U32 t)
|
if (*P(t) & 2)
|
||||||
{
|
PutQH(*P(t));
|
||||||
"TD:$$FG,GREEN$$%08X$$FG$$\n", t;
|
else
|
||||||
"%08X\n", *P(t);
|
PutTD(*P(t));
|
||||||
DocDm(t + 4, 8);
|
}
|
||||||
if (*P(t + 12))
|
}
|
||||||
DocDm(*P(t + 12), 16);
|
|
||||||
// DocDm(*P(t+12), *P(t+4) >> 21 & 0x7FF);
|
U0 PutQH(U32 h)
|
||||||
if (!(*P(t) & 1))
|
{
|
||||||
{
|
"QH:$$FG,RED$$%08X$$FG$$\n", h;
|
||||||
if (*P(t) & 2)
|
"%08X\n", *P(h);
|
||||||
PutQH(*P(t));
|
"%08X\n", *P(h + 4);
|
||||||
else
|
|
||||||
PutTD(*P(t));
|
if (!(*P(h) & 1))
|
||||||
}
|
{
|
||||||
}
|
if (*P(h) & 2)
|
||||||
|
PutQH(*P(h));
|
||||||
U0 PutQH(U32 h)
|
else
|
||||||
{
|
PutTD(*P(h));
|
||||||
"QH:$$FG,RED$$%08X$$FG$$\n", h;
|
}
|
||||||
"%08X\n", *P(h);
|
|
||||||
"%08X\n", *P(h + 4);
|
if (!(*P(h + 4) & 1))
|
||||||
|
{
|
||||||
if (!(*P(h) & 1))
|
if (*P(h + 4) & 2)
|
||||||
{
|
PutQH(*P(h + 4));
|
||||||
if (*P(h) & 2)
|
else
|
||||||
PutQH(*P(h));
|
PutTD(*P(h + 4));
|
||||||
else
|
}
|
||||||
PutTD(*P(h));
|
}
|
||||||
}
|
|
||||||
|
U0 PutFrame(U32 f)
|
||||||
if (!(*P(h + 4) & 1))
|
{
|
||||||
{
|
PutQH(f);
|
||||||
if (*P(h + 4) & 2)
|
}
|
||||||
PutQH(*P(h + 4));
|
|
||||||
else
|
U0 PutFrames()
|
||||||
PutTD(*P(h + 4));
|
{
|
||||||
}
|
I64 i, d, f, w1, w2;
|
||||||
}
|
CUSB *u;
|
||||||
|
for (i = 0; i < sys_num_usb; i++)
|
||||||
U0 PutFrame(U32 f)
|
{
|
||||||
{
|
u = &sys_usb_devs[i];
|
||||||
PutQH(f);
|
d = u->ports;
|
||||||
}
|
w1 = InU16(d + USBP_PORTSC0);
|
||||||
|
w2 = InU16(d + USBP_PORTSC1);
|
||||||
U0 PutFrames()
|
if (w1 & 1 || w2 & 1)
|
||||||
{
|
{
|
||||||
I64 i, d, f, w1, w2;
|
f = InU32(d + USBP_FRBASEADD);
|
||||||
CUSB *u;
|
PutFrame(f);
|
||||||
for (i = 0; i < sys_num_usb; i++)
|
}
|
||||||
{
|
}
|
||||||
u = &sys_usb_devs[i];
|
}
|
||||||
d = u->ports;
|
|
||||||
w1 = InU16(d + USBP_PORTSC0);
|
U0 Main()
|
||||||
w2 = InU16(d + USBP_PORTSC1);
|
{
|
||||||
if (w1 & 1 || w2 & 1)
|
USBInitAll;
|
||||||
{
|
PutStat;
|
||||||
f = InU32(d + USBP_FRBASEADD);
|
PutFrames;
|
||||||
PutFrame(f);
|
"$$FG,RED$$The BIOS sets-up the USB in PS/2 legacy mode.$$FG$$\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
Main;
|
||||||
|
|
||||||
U0 Main()
|
///* Not Finished
|
||||||
{
|
#define PORT 5
|
||||||
USBInitAll;
|
#define DEV_ADD_INIT 1
|
||||||
PutStat;
|
#define DEV_ADD 1
|
||||||
PutFrames;
|
#define END_PT0 0
|
||||||
"$$FG,RED$$The BIOS sets-up the USB in PS/2 legacy mode.$$FG$$\n";
|
#define END_PT1 1
|
||||||
}
|
#define END_PT2 2
|
||||||
|
#define LEN_MAX 8
|
||||||
Main;
|
#define TERMINATE 1
|
||||||
|
|
||||||
/* Not Finished
|
U0 SetUpTD()
|
||||||
#define PORT 5
|
{
|
||||||
#define DEV_ADD_INIT 1
|
CUSB *u = &sys_usb_devs[PORT];
|
||||||
#define DEV_ADD 1
|
I64 i, d = u->ports;
|
||||||
#define END_PT0 0
|
U32 *frm = CAllocAligned(0x1000, 0x1000, Fs->code_heap),
|
||||||
#define END_PT1 1
|
*tds = CAllocAligned(256, 16, Fs->code_heap),
|
||||||
#define END_PT2 2
|
*buf = CAlloc(128, Fs->code_heap);
|
||||||
#define LEN_MAX 8
|
DocDump(buf, 128);
|
||||||
#define TERMINATE 1
|
|
||||||
|
"<0>\n"; Sleep(100);
|
||||||
U0 SetUpTD()
|
OutU16(d + USBP_CMD, 2); //Reset
|
||||||
{
|
"<1>\n"; Sleep(100);
|
||||||
CUSB *u = &sys_usb_devs[PORT];
|
OutU16(d + USBP_CMD, 0);
|
||||||
I64 i, d = u->ports;
|
"<2>\n"; Sleep(100);
|
||||||
U32 *frm = CAllocAligned(0x1000, 0x1000, Fs->code_heap),
|
OutU16(d + USBP_PORTSC0, 4); //Enable
|
||||||
*tds = CAllocAligned(256, 16, Fs->code_heap),
|
OutU16(d + USBP_PORTSC1, 4);
|
||||||
*buf = CAlloc(128, Fs->code_heap);
|
"<3>\n"; Sleep(100);
|
||||||
DocD(buf, 128);
|
|
||||||
|
tds[0] = &tds[4](U8 *);
|
||||||
"<0>\n"; Sleep(100);
|
tds[1] = 0;
|
||||||
OutU16(d + USBP_CMD, 2); //Reset
|
tds[2] = PID_SETUP + DEV_ADD_INIT << 8 + END_PT0 << 15 + LEN_MAX << 21;
|
||||||
"<1>\n"; Sleep(100);
|
tds[3] = buf;
|
||||||
OutU16(d + USBP_CMD, 0);
|
buf[0] = 0 + RQ_SET_ADDR << 8 + DEV_ADD << 16;
|
||||||
"<2>\n"; Sleep(100);
|
buf[1] = 0 + 0 << 16;
|
||||||
OutU16(d + USBP_PORTSC0, 4); //Enable
|
|
||||||
OutU16(d + USBP_PORTSC1, 4);
|
tds[4] = TERMINATE;
|
||||||
"<3>\n"; Sleep(100);
|
tds[5] = 0;
|
||||||
|
tds[6] = PID_SETUP + DEV_ADD_INIT << 8 + END_PT0 << 15 + LEN_MAX << 21;
|
||||||
tds[0] = &tds[4](U8 *);
|
tds[7] = buf(U8 *) + 8;
|
||||||
tds[1] = 0;
|
buf[2] = 0 + RQ_SET_ADDR << 8 + DEV_ADD << 16;
|
||||||
tds[2] = PID_SETUP + DEV_ADD_INIT << 8 + END_PT0 << 15 + LEN_MAX << 21;
|
buf[3] = 0 + 0 << 16;
|
||||||
tds[3] = buf;
|
|
||||||
buf[0] = 0 + RQ_SET_ADDR << 8 + DEV_ADD << 16;
|
frm[0] = &tds[0](U8 *);
|
||||||
buf[1] = 0 + 0 << 16;
|
for (i = 1; i < 0x1000 / 4; i++)
|
||||||
|
frm[i] = TERMINATE;
|
||||||
tds[4] = TERMINATE;
|
|
||||||
tds[5] = 0;
|
OutU16(d + USBP_FRNUM, frm);
|
||||||
tds[6] = PID_SETUP + DEV_ADD_INIT << 8 + END_PT0 << 15 + LEN_MAX << 21;
|
OutU32(d + USBP_FRBASEADD, frm);
|
||||||
tds[7] = buf(U8 *) + 8;
|
"<4>\n"; Sleep(200);
|
||||||
buf[2] = 0 + RQ_SET_ADDR << 8 + DEV_ADD << 16;
|
OutU16(d + USBP_CMD,1);
|
||||||
buf[3] = 0 + 0 << 16;
|
"<5>\n"; Sleep(1000);
|
||||||
|
OutU16(d + USBP_CMD,0);
|
||||||
frm[0] = &tds[0](U8 *);
|
"<6>\n"; Sleep(200);
|
||||||
for (i = 1; i < 0x1000 / 4; i++)
|
}
|
||||||
frm[i] = TERMINATE;
|
|
||||||
|
SetUpTD;
|
||||||
OutU16(d + USBP_FRNUM, frm);
|
|
||||||
OutU32(d + USBP_FRBASEADD, frm);
|
//*/
|
||||||
"<4>\n"; Sleep(200);
|
|
||||||
OutU16(d + USBP_CMD,1);
|
|
||||||
"<5>\n"; Sleep(1000);
|
|
||||||
OutU16(d + USBP_CMD,0);
|
|
||||||
"<6>\n"; Sleep(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetUpTD;
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in a new issue