Changeset 157 for trunk/src/os2ahci/libc.c
- Timestamp:
- May 8, 2013, 5:10:33 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/os2ahci/libc.c
r156 r157 40 40 /* ------------------------ typedefs and structures ------------------------ */ 41 41 42 #ifdef NOT_USED 42 43 /* mdelay() calibration status */ 43 44 typedef enum { … … 47 48 MD_CALIBRATION_DONE /* calibration complete */ 48 49 } MDCAL; 50 static void _cdecl _far mdelay_timer_callback (ULONG timer_handle, 51 ULONG parm1, 52 ULONG parm2); 53 static int mdelay_cal_end (void); 54 #endif 49 55 50 56 /* -------------------------- function prototypes -------------------------- */ … … 54 60 int base, 55 61 int zero, int flen); 56 static void _cdecl _far mdelay_timer_callback (ULONG timer_handle,57 ULONG parm1,58 ULONG parm2);59 static int mdelay_cal_end (void);60 62 61 63 /* ------------------------ global/static variables ------------------------ */ … … 92 94 }; 93 95 96 #ifdef NOT_USED 94 97 /* delay loop calibration data */ 95 98 volatile MDCAL mdelay_cal_status = 0; /* delay loop calibration status */ 96 99 volatile u32 mdelay_loops_per_ms = 0; /* delay loop counter */ 100 #endif 97 101 98 102 /* very small heap for dynamic memory management */ … … 684 688 } 685 689 690 #ifdef NOT_USED 686 691 /****************************************************************************** 687 692 * Calibrate 'mdelay()' loop. This is done by setting up a 1 second timer … … 764 769 mdelay_cal_status = MD_CALIBRATION_DONE; 765 770 } 766 767 /****************************************************************************** 768 * Sleep specified number of milliseonds. This is implemented by yielding the 769 * CPU until the system timer value indicates we're done. This function can 771 #endif 772 773 /****************************************************************************** 774 * Setup the millisecond timer. This is implemented by blocking (yielding the 775 * CPU) until the system timer value indicates we're done. This function can 770 776 * only be called at task time, or from a context hook. 771 777 * … … 773 779 * can lead to intervals up to 55ms (18.2 timer interrupts per second). 774 780 */ 781 void timer_init(TIMER far *pTimer, u32 Milliseconds) 782 { 783 pTimer->Start = gis->msecs; 784 pTimer->End = pTimer->Start + Milliseconds; 785 } 786 787 /****************************************************************************** 788 * Check the millisecond timer. Block if not done. 789 */ 790 int timer_check_and_block(TIMER far *pTimer) 791 { 792 u32 current; 793 794 current = gis->msecs; 795 if (pTimer->Start < pTimer->End) { 796 if ((current >= pTimer->End) || (current < pTimer->Start)) return 1; 797 } else { 798 if ((current >= pTimer->End) && (current < pTimer->Start)) return 1; 799 } 800 DevHelp_ProcBlock((ULONG)&timer_check_and_block, 1, WAIT_IS_INTERRUPTABLE); 801 return 0; 802 } 803 804 /****************************************************************************** 805 * Sleep specified number of milliseonds. 806 */ 775 807 void msleep(u32 millies) 776 808 { 777 ULONG start; 778 ULONG end; 779 ULONG event_id; 780 781 if (gis == NULL) { 782 /* no global info segment; use mdelay() */ 783 mdelay(millies); 784 return; 785 } 786 787 start = gis->msecs; 788 end = start + millies; 789 event_id = (ULONG)&msleep; 790 791 if (end < start) { 792 /* wrap-around; wait until 'msecs' has wrapped, too */ 793 while (gis->msecs >= start) { 794 DevHelp_ProcBlock(event_id, 1, WAIT_IS_INTERRUPTABLE); 795 } 796 } 797 798 while (gis->msecs <= end) { 799 DevHelp_ProcBlock(event_id, 1, WAIT_IS_INTERRUPTABLE); 800 } 809 TIMER Timer; 810 811 timer_init(&Timer, millies); 812 while (!timer_check_and_block(&Timer)); 801 813 } 802 814 … … 885 897 } 886 898 899 #ifdef NOT_USED 887 900 /****************************************************************************** 888 901 * Timer callback handler for 'mdelay_calibrate()' … … 904 917 return(mdelay_cal_status == MD_CALIBRATION_END); 905 918 } 906 919 #endif
Note:
See TracChangeset
for help on using the changeset viewer.