Changeset 156 for trunk/src/os2ahci/libc.c
- Timestamp:
- May 6, 2013, 7:57:39 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/libc.c
r154 r156 75 75 }; 76 76 77 /* COM port initialization sequence */78 77 static struct { 79 int reg; 80 u8 data; 81 } com_init_sequence[] = { 82 3, 0x80, /* overlay divisor latch register at 0x3f8 and 0x3f9 */ 83 0, 0x01, /* set low byte of divisor to 1 (115200 baud) */ 84 1, 0x00, /* set high byte of divisor to 0 */ 85 3, 0x03, /* reset divisor latch register overlay and set 8,n,1 */ 86 1, 0x00, /* disable interrupts */ 87 4, 0x0f, /* modem control register */ 88 -1, 0x00 78 long Baud; 79 u16 Data; 80 } BaudCodes[] = { 81 115200, 0x0001, 82 57600, 0x0002, 83 38400, 0x0003, 84 19200, 0x0006, 85 9600, 0x000C, 86 4800, 24, 87 2400, 48, 88 1200, 96, 89 600, 192, 90 300, 384, 91 0, 0 /* end of list */ 89 92 }; 90 93 … … 132 135 * to be fixed eventually... 133 136 */ 134 void init_com( void)137 void init_com(long BaudRate) 135 138 { 136 139 int i; 137 138 if (com_base == 0) { 139 /* no com port in use */ 140 return; 141 } 140 u16 RegData; 141 142 if (com_base == 0) return; /* no com port in use */ 143 144 /* Find the baud code for the given baud rate */ 145 for (i = 0; BaudCodes[i].Baud; i++) if (BaudCodes[i].Baud == BaudRate) break; 146 if (BaudCodes[i].Baud == 0) i = 0; /* default to 115200 */ 147 RegData = BaudCodes[i].Data; 142 148 143 149 spin_lock(com_lock); 144 150 145 for (i = 0; com_init_sequence[i].reg != -1; i++) { 146 u16 port = com_base + com_init_sequence[i].reg; 147 u8 data = com_init_sequence[i].data; 148 _asm { 149 mov dx, port; 150 mov al, data; 151 out dx, al; 152 } 151 __asm { 152 mov bx,RegData 153 mov dx,com_base ; Base address 154 cli 155 add dx,3 ; Line Control (+3) 156 mov al,10000000b ; Set baud flag 157 out dx,al ; for speed setting 158 159 ; Set Baud 160 dec dx ; High divisor address 161 dec dx ; (+1) 162 mov al,bh ; High divisor value 163 out dx,al ; set it 164 dec dx ; Low divisor address (+0) 165 mov al,bl ; Low divisor value 166 out dx,al ; set baud rate 167 168 ; Set frame 169 mov al,00000011b ; Set 8 bit, none, none 170 add dx,3 ; Line Control (+3) 171 out dx,al 172 173 inc dx 174 mov al,3 175 out dx,al ; DTR & RTS to High 176 sti 153 177 } 154 178 … … 753 777 ULONG start; 754 778 ULONG end; 779 ULONG event_id; 755 780 756 781 if (gis == NULL) { … … 762 787 start = gis->msecs; 763 788 end = start + millies; 789 event_id = (ULONG)&msleep; 764 790 765 791 if (end < start) { 766 792 /* wrap-around; wait until 'msecs' has wrapped, too */ 767 793 while (gis->msecs >= start) { 768 DevHelp_ Yield();794 DevHelp_ProcBlock(event_id, 1, WAIT_IS_INTERRUPTABLE); 769 795 } 770 796 } 771 797 772 798 while (gis->msecs <= end) { 773 DevHelp_ Yield();799 DevHelp_ProcBlock(event_id, 1, WAIT_IS_INTERRUPTABLE); 774 800 } 775 801 }
Note:
See TracChangeset
for help on using the changeset viewer.