📄 async.h
字号:
/* openbios/arch/pallas/olivia/async.h, redbios, redbios_iii_1.0 6/14/99 14:34:35 *//*-----------------------------------------------------------------------------+|| This source code has been made available to you by IBM on an AS-IS| basis. Anyone receiving this source is licensed under IBM| copyrights to use it in any way he or she deems fit, including| copying it, modifying it, compiling it, and redistributing it either| with or without modifications. No license under IBM patents or| patent applications is to be implied by the copyright license.|| Any user of this software should understand that IBM cannot provide| technical support for this software and will not be responsible for| any consequences resulting from the use of this software.|| Any person who transfers this source code or any derivative work| must include the IBM copyright notice, this paragraph, and the| preceding two paragraphs in the transferred software.|| COPYRIGHT I B M CORPORATION 1995| LICENSED MATERIAL - PROGRAM PROPERTY OF I B M+-----------------------------------------------------------------------------*//*-----------------------------------------------------------------------------+|| File Name: async.h|| Function: Platform specific asynchronous port basic functions.|| Author: Bill DeStein, Maciej P. Tyrlik.|| Change Activity-|| Date Description of Change BY| --------- --------------------- ---| 13-Aug-93 Created WCD| 27-May-94 Port to Oak MPT| 14-Jun-99 Added s1setbaud pag| 29-Dec-01 Added getline/askchar YYD| 09-Jan-02 Splitted platform specific ones YYD| 30-Jan-02 Ported to use SICC port on Vesta YYD+-----------------------------------------------------------------------------*//*-----------------------------------------------------------------------------+| Line Status Register.+-----------------------------------------------------------------------------*/#define asyncLSRport1 0x40000000 // SICC#define asyncLSRDataReady1 0x80#define asyncLSROverrunError1 0x20#define asyncLSRParityError1 0x10#define asyncLSRFramingError1 0x40#define asyncLSRBreakInterrupt1 0x08#define asyncLSRTxHoldEmpty1 0x04#define asyncLSRTxShiftEmpty1 0x02#define asyncLSRRxFifoError1 0x01/*-----------------------------------------------------------------------------+| Miscellanies defines.+-----------------------------------------------------------------------------*/#define asyncTxBufferport1 0x40000009#define asyncRxBufferport1 0x40000009/*-----------------------------------------------------------------------------+| Getchar.+-----------------------------------------------------------------------------*/int getchar(){ unsigned char status=0; while(1) { status=in8(asyncLSRport1); if ((status&asyncLSRDataReady1)!=0x0) { break; } else if ((status&(asyncLSRFramingError1|asyncLSROverrunError1| asyncLSRParityError1|asyncLSRBreakInterrupt1))!=0) { (void)out8(asyncLSRport1, asyncLSRFramingError1|asyncLSROverrunError1| asyncLSRParityError1|asyncLSRBreakInterrupt1); } } return(0x000000ff&(int)in8(asyncRxBufferport1));}/*-----------------------------------------------------------------------------+| Kbhit.+-----------------------------------------------------------------------------*/int kbhit(){ unsigned char status; status=in8(asyncLSRport1); if ((status&asyncLSRDataReady1)!=0x0) { return(1); } if ((status&(asyncLSRFramingError1|asyncLSROverrunError1|asyncLSRParityError1| asyncLSRBreakInterrupt1))!=0) { (void)out8(asyncLSRport1, asyncLSRFramingError1|asyncLSROverrunError1| asyncLSRParityError1|asyncLSRBreakInterrupt1); } return 0;}unsigned long scc_clk = 20000000;void init_s1port_divisor(){ unsigned long temp_value; unsigned long Mult, RangeA, RangeB, scc_div; /*--------------------------------------------------------------------------+ | Calculate the serial port clock speed. This code really ought to be put | somewhere else (like in ramcheck where the clock computations are done). | The update the baud rate (which will use the new scc_clk variable). +--------------------------------------------------------------------------*/ temp_value = ppcMfclkgpcr();#if 0 Mult = temp_value & 0xf; if (Mult == 0) { Mult = 16; } scc_clk = BOARD_CLOCK * Mult; if ((temp_value & 0x00000080) == 0) { RangeB = 8 - ((temp_value >> 8) & 0x7); RangeA = 8 - ((temp_value >> 4) & 0x7); scc_clk = scc_clk * RangeA / RangeB; } if ((temp_value & 0x00400000) == 0) { scc_clk *= 2; } scc_div = (temp_value >> 18 ) & 0x0000003f; if (scc_div == 0) { scc_div = 16; } scc_clk /= scc_div;#else if(temp_value & 0x00000080) { scc_clk = 324000000; } else { scc_clk = 216000000; } scc_clk = scc_clk/(unsigned long)((temp_value&0x00FC0000)>>18);#endif s1setbaud(1);#if 0 /* debug print out of serial port clock speed */ s1printf("Serial port speed: %d\n", scc_clk); s1printf(" Control reg: 0x%x, Mult: %d, A: %d, B: %d, scc_div: %d\n", temp_value, Mult, RangeA, RangeB, scc_div);#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -