ReactOS  0.4.13-dev-464-g6b95727
serial.c File Reference
#include "remods.h"
#include "precomp.h"
#include "serial_port.h"
Include dependency graph for serial.c:

Go to the source code of this file.

Functions

BOOLEAN SerialReadByte (PUCHAR px)
 
void SerialSetSpeed (ULONG baudrate)
 
void SerialSetOthers (ULONG Parity, ULONG Bits, ULONG StopBit)
 
void FlushSerialBuffer (void)
 
void SetupSerial (ULONG port, ULONG baudrate)
 
BOOLEAN SerialSendByte (UCHAR x)
 
UCHAR CheckSum (LPSTR p, ULONG Len)
 
BOOLEAN ReadPacket (PSERIAL_PACKET p)
 
BOOLEAN SendPacket (PSERIAL_PACKET p)
 
BOOLEAN SendPacketTimeout (PSERIAL_PACKET p)
 
PSERIAL_PACKET AssemblePacket (PUCHAR pData, ULONG ulSize)
 
void SetForegroundColorSerial (ECOLORS col)
 
void SetBackgroundColorSerial (ECOLORS col)
 
void PrintGrafSerial (ULONG x, ULONG y, UCHAR c)
 
void FlushSerial (void)
 
void ShowCursorSerial (void)
 
void HideCursorSerial (void)
 
void CopyLineToSerial (USHORT dest, USHORT src)
 
void InvertLineSerial (ULONG line)
 
void HatchLineSerial (ULONG line)
 
void ClrLineSerial (ULONG line)
 
void PrintLogoSerial (BOOLEAN bShow)
 
void PrintCursorSerial (BOOLEAN bForce)
 
void SaveGraphicsStateSerial (void)
 
void RestoreGraphicsStateSerial (void)
 
UCHAR GetKeyPolledSerial (void)
 
void FlushKeyboardQueueSerial (void)
 
BOOLEAN Connect (USHORT xSize, USHORT ySize)
 
BOOLEAN ConsoleInitSerial (void)
 
void ConsoleShutdownSerial (void)
 

Variables

WINDOW wWindowSerial [4]
 
PUCHAR pScreenBufferSerial
 
USHORT usSerialPortBase
 
UCHAR packet [_PAGE_SIZE]
 
UCHAR assemble_packet [_PAGE_SIZE]
 
UCHAR flush_buffer [_PAGE_SIZE]
 
UCHAR g_x
 
UCHAR g_y
 
ULONG ulFlushBufferPos = 0
 
UCHAR ucLastKeyRead
 
ECOLORS eForegroundColor =WHITE
 
ECOLORS eBackgroundColor =BLACK
 

Function Documentation

◆ AssemblePacket()

PSERIAL_PACKET AssemblePacket ( PUCHAR  pData,
ULONG  ulSize 
)

Definition at line 295 of file serial.c.

296 {
298  ULONG ulCheckSum;
299 
301 
302  // fill in header
303  p->header.packet_chksum = CheckSum(pData,ulSize);
304  p->header.packet_size = ulSize;
305  p->header.packet_header_chksum = 0;
306  ulCheckSum = (ULONG)CheckSum((PUCHAR)p,sizeof(SERIAL_PACKET_HEADER));
307  p->header.packet_header_chksum = ulCheckSum;
308  // attach data to packet
309  PICE_memcpy(p->data,pData,ulSize);
310 
311  return p;
312 }
UCHAR assemble_packet[_PAGE_SIZE]
Definition: serial.c:54
unsigned char * PUCHAR
Definition: retypes.h:3
struct _SERIAL_PACKET_HEADER SERIAL_PACKET_HEADER
struct _SERIAL_PACKET * PSERIAL_PACKET
UCHAR CheckSum(LPSTR p, ULONG Len)
Definition: serial.c:197
void PICE_memcpy(void *t, void *s, int sz)
Definition: utils.c:239
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by ClrLineSerial(), Connect(), FlushSerial(), GetKeyPolledSerial(), HideCursorSerial(), InvertLineSerial(), and ShowCursorSerial().

◆ CheckSum()

UCHAR CheckSum ( LPSTR  p,
ULONG  Len 
)

Definition at line 197 of file serial.c.

198 {
199  UCHAR ucCheckSum = 0;
200  ULONG i;
201  for(i=0;i<Len;i++)
202  {
203  ucCheckSum ^= *p++;
204  ucCheckSum += 1;
205  }
206 
207  return ucCheckSum;
208 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define Len
Definition: deflate.h:82
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by AssemblePacket(), check_table_dir(), CheckSumMappedFile(), CreateOutputFile(), FATGetNextDirEntry(), gdb_receive_packet(), HalpAcpiGetTableFromBios(), IMAGEHLP_RecalculateChecksum(), ImgpLoadPEImage(), IopCreateArcNamesCd(), IopCreateArcNamesDisk(), IoReadDiskSignature(), MapFileAndCheckSumA(), MapFileAndCheckSumW(), test_Loader(), test_pack_IMAGE_OPTIONAL_HEADER32(), test_pack_IMAGE_OPTIONAL_HEADER64(), test_pack_IMAGE_SEPARATE_DEBUG_HEADER(), tt_check_trickyness_sfnt_ids(), and WriteOutFile().

◆ ClrLineSerial()

void ClrLineSerial ( ULONG  line)

Definition at line 471 of file serial.c.

472 {
475 
477  pClrLine->type = PACKET_TYPE_CLRLINE;
478  pClrLine->fgcol = eForegroundColor;
479  pClrLine->bkcol = eBackgroundColor;
480  pClrLine->line = line;
481 
482  p = AssemblePacket((PUCHAR)pClrLine,sizeof(SERIAL_DATA_PACKET_CLRLINE));
483  SendPacket(p);
484 }
struct _SERIAL_DATA_PACKET_CLRLINE * PSERIAL_DATA_PACKET_CLRLINE
unsigned char * PUCHAR
Definition: retypes.h:3
#define PACKET_TYPE_CLRLINE
Definition: shared.h:154
BOOLEAN SendPacket(PSERIAL_PACKET p)
Definition: serial.c:225
Definition: dhcpd.h:135
ECOLORS eBackgroundColor
Definition: serial.c:60
char line[200]
Definition: main.c:97
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
GLfloat GLfloat p
Definition: glext.h:8902
ECOLORS eForegroundColor
Definition: serial.c:60

Referenced by ConsoleInitSerial().

◆ Connect()

BOOLEAN Connect ( USHORT  xSize,
USHORT  ySize 
)

Definition at line 563 of file serial.c.

564 {
567 
569  pConnect->type = PACKET_TYPE_CONNECT;
570  pConnect->xsize = xSize;
571  pConnect->ysize = ySize;
572 
573  p = AssemblePacket((PUCHAR)pConnect,sizeof(SERIAL_DATA_PACKET_CONNECT));
574  return SendPacketTimeout(p);
575 }
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN SendPacketTimeout(PSERIAL_PACKET p)
Definition: serial.c:261
Definition: dhcpd.h:135
#define PACKET_TYPE_CONNECT
Definition: shared.h:172
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
struct _SERIAL_DATA_PACKET_CONNECT * PSERIAL_DATA_PACKET_CONNECT
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ConsoleInitSerial(), and ConsoleShutdownSerial().

◆ ConsoleInitSerial()

BOOLEAN ConsoleInitSerial ( void  )

Definition at line 582 of file serial.c.

583 {
584  BOOLEAN bResult = FALSE;
585 
586  ENTER_FUNC();
587 
602 
605 
607 
608  GLOBAL_SCREEN_WIDTH = 80;
610 
612 
614  {
615  bResult = TRUE;
616 
617  EmptyRingBuffer();
618 
619  SetupSerial(1,115200);
620 
621  // connect to terminal, if none's there, we give up
623 
624  if(bResult)
625  {
627  }
628  }
629 
630  LEAVE_FUNC();
631 
632  return bResult;
633 }
void(* PrintLogo)(BOOLEAN bShow)
Definition: hardware.h:47
void PrintGrafSerial(ULONG x, ULONG y, UCHAR c)
Definition: serial.c:340
#define TRUE
Definition: types.h:120
void SetWindowGeometry(PVOID pWindow)
Definition: hardware.c:915
void EmptyRingBuffer(void)
Definition: hardware.c:104
BOOLEAN Connect(USHORT xSize, USHORT ySize)
Definition: serial.c:563
void SaveGraphicsStateSerial(void)
Definition: serial.c:509
void(* FlushKeyboardQueue)(void)
Definition: hardware.h:61
ULONG GLOBAL_SCREEN_WIDTH
Definition: hardware.c:62
ULONG GLOBAL_SCREEN_HEIGHT
Definition: hardware.c:62
void(* HideCursor)(void)
Definition: hardware.h:52
void HatchLineSerial(ULONG line)
Definition: serial.c:461
void CopyLineToSerial(USHORT dest, USHORT src)
Definition: serial.c:433
#define LEAVE_FUNC()
Definition: debug.h:43
WINDOW wWindowSerial[4]
Definition: serial.c:41
#define NONPAGEDPOOL
Definition: utils.h:306
#define FRAMEBUFFER_SIZE
Definition: precomp.h:31
void(* SetBackgroundColor)(ECOLORS)
Definition: hardware.h:54
void(* SetForegroundColor)(ECOLORS)
Definition: hardware.h:53
void(* ClrLine)(ULONG line)
Definition: hardware.h:44
void(* RestoreGraphicsState)(void)
Definition: hardware.h:50
unsigned char BOOLEAN
PUCHAR pScreenBufferSerial
Definition: serial.c:49
void * PICE_malloc(size_t numBytes, BOOLEAN fromPaged)
Definition: utils.c:2212
OUTPUT_HANDLERS ohandlers
Definition: hardware.c:65
void PrintCursorSerial(BOOLEAN bForce)
Definition: serial.c:500
UCHAR(* GetKeyPolled)(void)
Definition: hardware.h:60
void(* PrintGraf)(ULONG x, ULONG y, UCHAR c)
Definition: hardware.h:42
INPUT_HANDLERS ihandlers
Definition: hardware.c:66
void(* PrintCursor)(BOOLEAN bForce)
Definition: hardware.h:48
void(* ShowCursor)(void)
Definition: hardware.h:51
void SetupSerial(ULONG port, ULONG baudrate)
Definition: serial.c:133
void RestoreGraphicsStateSerial(void)
Definition: serial.c:518
void ShowCursorSerial(void)
Definition: serial.c:383
void FlushKeyboardQueueSerial(void)
Definition: serial.c:554
void ClrLineSerial(ULONG line)
Definition: serial.c:471
void(* Flush)(void)
Definition: hardware.h:43
void(* SaveGraphicsState)(void)
Definition: hardware.h:49
void(* HatchLine)(ULONG line)
Definition: hardware.h:46
void PrintLogoSerial(BOOLEAN bShow)
Definition: serial.c:490
void(* CopyLineTo)(USHORT dest, USHORT src)
Definition: hardware.h:41
void HideCursorSerial(void)
Definition: serial.c:409
void(* InvertLine)(ULONG line)
Definition: hardware.h:45
void InvertLineSerial(ULONG line)
Definition: serial.c:443
void SetForegroundColorSerial(ECOLORS col)
Definition: serial.c:321
void FlushSerial(void)
Definition: serial.c:359
#define ENTER_FUNC()
Definition: debug.h:42
UCHAR GetKeyPolledSerial(void)
Definition: serial.c:528
void SetBackgroundColorSerial(ECOLORS col)
Definition: serial.c:330

Referenced by ConsoleInit().

◆ ConsoleShutdownSerial()

void ConsoleShutdownSerial ( void  )

Definition at line 641 of file serial.c.

642 {
643  ENTER_FUNC();
644 
645  Connect(80,25);
646 
648 
651 
652  LEAVE_FUNC();
653 }
BOOLEAN Connect(USHORT xSize, USHORT ySize)
Definition: serial.c:563
#define LEAVE_FUNC()
Definition: debug.h:43
PUCHAR pScreenBufferSerial
Definition: serial.c:49
void FlushSerialBuffer(void)
Definition: serial.c:122
void PICE_free(void *p)
Definition: utils.c:2222
#define ENTER_FUNC()
Definition: debug.h:42

Referenced by ConsoleShutdown().

◆ CopyLineToSerial()

void CopyLineToSerial ( USHORT  dest,
USHORT  src 
)

Definition at line 433 of file serial.c.

434 {
435  NOT_IMPLEMENTED();
436 }
#define NOT_IMPLEMENTED()
Definition: hardware.h:153

Referenced by ConsoleInitSerial().

◆ FlushKeyboardQueueSerial()

void FlushKeyboardQueueSerial ( void  )

Definition at line 554 of file serial.c.

555 {
556  // not implemented
557 }

Referenced by ConsoleInitSerial().

◆ FlushSerial()

void FlushSerial ( void  )

Definition at line 359 of file serial.c.

360 {
363 
365  pPrint->type = PACKET_TYPE_PRINT;
366  pPrint->x = g_x;
367  pPrint->y = g_y;
368  pPrint->fgcol = eForegroundColor;
369  pPrint->bkcol = eBackgroundColor;
372  ulFlushBufferPos = 0;
373 
375  SendPacket(p);
376 }
#define PACKET_TYPE_PRINT
Definition: shared.h:162
unsigned char * PUCHAR
Definition: retypes.h:3
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
char * PICE_strcpy(char *s1, char *s2)
Definition: utils.c:302
BOOLEAN SendPacket(PSERIAL_PACKET p)
Definition: serial.c:225
ULONG ulFlushBufferPos
Definition: serial.c:57
Definition: dhcpd.h:135
UCHAR g_x
Definition: serial.c:56
ECOLORS eBackgroundColor
Definition: serial.c:60
UCHAR g_y
Definition: serial.c:56
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
UCHAR flush_buffer[_PAGE_SIZE]
Definition: serial.c:56
struct _SERIAL_DATA_PACKET_PRINT * PSERIAL_DATA_PACKET_PRINT
GLfloat GLfloat p
Definition: glext.h:8902
ECOLORS eForegroundColor
Definition: serial.c:60

Referenced by ConsoleInitSerial().

◆ FlushSerialBuffer()

void FlushSerialBuffer ( void  )


Definition at line 122 of file serial.c.

123 {
124  UCHAR c;
125 
126  while(SerialReadByte(&c));
127 }
BOOLEAN SerialReadByte(PUCHAR px)
Definition: serial.c:152
const GLubyte * c
Definition: glext.h:8905
unsigned char UCHAR
Definition: xmlstorage.h:181
#define c
Definition: ke_i.h:80

Referenced by ConsoleShutdownSerial(), and SetupSerial().

◆ GetKeyPolledSerial()

UCHAR GetKeyPolledSerial ( void  )

Definition at line 528 of file serial.c.

529 {
530  UCHAR ucResult;
533 
535  pPoll->type = PACKET_TYPE_POLL;
538  pPoll->build_number = PICE_BUILD;
539 
541  SendPacket(p);
542 
543  ucResult = ucLastKeyRead;
544 
545  ucLastKeyRead = 0;
546 
547  return ucResult;
548 }
#define PACKET_TYPE_POLL
Definition: shared.h:193
unsigned char * PUCHAR
Definition: retypes.h:3
#define PICE_MAJOR_VERSION
Definition: pice_ver.h:32
struct _SERIAL_DATA_PACKET_POLL * PSERIAL_DATA_PACKET_POLL
#define PICE_MINOR_VERSION
Definition: pice_ver.h:33
BOOLEAN SendPacket(PSERIAL_PACKET p)
Definition: serial.c:225
Definition: dhcpd.h:135
#define PICE_BUILD
Definition: pice_ver.h:36
unsigned char UCHAR
Definition: xmlstorage.h:181
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
GLfloat GLfloat p
Definition: glext.h:8902
UCHAR ucLastKeyRead
Definition: serial.c:59

Referenced by ConsoleInitSerial().

◆ HatchLineSerial()

void HatchLineSerial ( ULONG  line)

Definition at line 461 of file serial.c.

462 {
463  NOT_IMPLEMENTED();
464 }
#define NOT_IMPLEMENTED()
Definition: hardware.h:153

Referenced by ConsoleInitSerial().

◆ HideCursorSerial()

void HideCursorSerial ( void  )

Definition at line 409 of file serial.c.

410 {
413 
414  ENTER_FUNC();
415 
417 
419  pCursor->type = PACKET_TYPE_CURSOR;
420  pCursor->state = (UCHAR)TRUE;
421 
422  p = AssemblePacket((PUCHAR)pCursor,sizeof(SERIAL_DATA_PACKET_CURSOR));
423  SendPacket(p);
424 
425  LEAVE_FUNC();
426 }
BOOLEAN bCursorEnabled
Definition: hardware.c:51
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
#define LEAVE_FUNC()
Definition: debug.h:43
BOOLEAN SendPacket(PSERIAL_PACKET p)
Definition: serial.c:225
struct _SERIAL_DATA_PACKET_CURSOR * PSERIAL_DATA_PACKET_CURSOR
Definition: dhcpd.h:135
unsigned char UCHAR
Definition: xmlstorage.h:181
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
#define ENTER_FUNC()
Definition: debug.h:42
GLfloat GLfloat p
Definition: glext.h:8902
#define PACKET_TYPE_CURSOR
Definition: shared.h:179

Referenced by ConsoleInitSerial().

◆ InvertLineSerial()

void InvertLineSerial ( ULONG  line)

Definition at line 443 of file serial.c.

444 {
445  PSERIAL_DATA_PACKET_INVERTLINE pInvertLine;
447 
448  pInvertLine = (PSERIAL_DATA_PACKET_INVERTLINE)packet;
449  pInvertLine->type = PACKET_TYPE_INVERTLINE;
450  pInvertLine->line = line;
451 
452  p = AssemblePacket((PUCHAR)pInvertLine,sizeof(SERIAL_DATA_PACKET_INVERTLINE));
453  SendPacket(p);
454 }
struct _SERIAL_DATA_PACKET_INVERTLINE * PSERIAL_DATA_PACKET_INVERTLINE
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN SendPacket(PSERIAL_PACKET p)
Definition: serial.c:225
Definition: dhcpd.h:135
char line[200]
Definition: main.c:97
#define PACKET_TYPE_INVERTLINE
Definition: shared.h:186
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ConsoleInitSerial().

◆ PrintCursorSerial()

void PrintCursorSerial ( BOOLEAN  bForce)

Definition at line 500 of file serial.c.

501 {
502  NOT_IMPLEMENTED();
503 }
#define NOT_IMPLEMENTED()
Definition: hardware.h:153

Referenced by ConsoleInitSerial().

◆ PrintGrafSerial()

void PrintGrafSerial ( ULONG  x,
ULONG  y,
UCHAR  c 
)

Definition at line 340 of file serial.c.

341 {
342  // put this into memory
344 
345  // put this into cache
346  if(ulFlushBufferPos == 0)
347  {
348  g_x = x;
349  g_y = y;
350  }
351 
353 }
ULONG GLOBAL_SCREEN_WIDTH
Definition: hardware.c:62
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
PUCHAR pScreenBufferSerial
Definition: serial.c:49
ULONG ulFlushBufferPos
Definition: serial.c:57
UCHAR g_x
Definition: serial.c:56
UCHAR g_y
Definition: serial.c:56
UCHAR flush_buffer[_PAGE_SIZE]
Definition: serial.c:56
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define c
Definition: ke_i.h:80

Referenced by ConsoleInitSerial().

◆ PrintLogoSerial()

void PrintLogoSerial ( BOOLEAN  bShow)

Definition at line 490 of file serial.c.

491 {
492  NOT_IMPLEMENTED();
493 }
#define NOT_IMPLEMENTED()
Definition: hardware.h:153

Referenced by ConsoleInitSerial().

◆ ReadPacket()

BOOLEAN ReadPacket ( PSERIAL_PACKET  p)


Definition at line 215 of file serial.c.

216 {
217  return TRUE;
218 }
#define TRUE
Definition: types.h:120

◆ RestoreGraphicsStateSerial()

void RestoreGraphicsStateSerial ( void  )

Definition at line 518 of file serial.c.

519 {
520  // not implemented
521 }

Referenced by ConsoleInitSerial().

◆ SaveGraphicsStateSerial()

void SaveGraphicsStateSerial ( void  )

Definition at line 509 of file serial.c.

510 {
511  // not implemented
512 }

Referenced by ConsoleInitSerial().

◆ SendPacket()

BOOLEAN SendPacket ( PSERIAL_PACKET  p)


Definition at line 225 of file serial.c.

226 {
227  PUCHAR pHeader = (PUCHAR)&p->header;
228  ULONG i;
229  UCHAR c;
230  ULONG timeout;
231 
232  do
233  {
234  timeout = 10;
235  pHeader = (PUCHAR)&p->header;
236  for(i=0;i<(sizeof(SERIAL_PACKET_HEADER)+p->header.packet_size);i++)
237  {
238  if(!SerialSendByte(*pHeader++))
239  {
240  return FALSE;
241  }
242  }
243 
244  do
245  {
246  c = 0;
247  SerialReadByte(&c);
248  if(c != ACK)
249  ucLastKeyRead = c;
250  }while(c != ACK && timeout--);
251 
252  }while(c != ACK);
253 
254  return TRUE;
255 }
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
Definition: dhcpd.h:245
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _SERIAL_PACKET_HEADER SERIAL_PACKET_HEADER
BOOLEAN SerialReadByte(PUCHAR px)
Definition: serial.c:152
const GLubyte * c
Definition: glext.h:8905
unsigned char UCHAR
Definition: xmlstorage.h:181
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
BOOLEAN SerialSendByte(UCHAR x)
Definition: serial.c:175
#define ACK
Definition: shared.h:126
UCHAR ucLastKeyRead
Definition: serial.c:59

Referenced by ClrLineSerial(), FlushSerial(), GetKeyPolledSerial(), HideCursorSerial(), InvertLineSerial(), KdpSendWaitContinue(), and ShowCursorSerial().

◆ SendPacketTimeout()

BOOLEAN SendPacketTimeout ( PSERIAL_PACKET  p)


Definition at line 261 of file serial.c.

262 {
263  PUCHAR pHeader = (PUCHAR)&p->header;
264  ULONG i;
265  UCHAR c;
266  ULONG timeout = 20;
267  BOOLEAN bResult = TRUE;
268 
269  pHeader = (PUCHAR)&p->header;
270  for(i=0;i<(sizeof(SERIAL_PACKET_HEADER)+p->header.packet_size);i++)
271  {
272  if(!SerialSendByte(*pHeader++))
273  {
274  return FALSE;
275  }
276  }
277 
278  do
279  {
280  c = 0xFF;
281  SerialReadByte(&c);
282  }while(c != ACK && timeout--);
283 
284  if(c != ACK)
285  bResult = FALSE;
286 
287  return bResult;
288 }
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
Definition: dhcpd.h:245
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _SERIAL_PACKET_HEADER SERIAL_PACKET_HEADER
unsigned char BOOLEAN
BOOLEAN SerialReadByte(PUCHAR px)
Definition: serial.c:152
const GLubyte * c
Definition: glext.h:8905
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
BOOLEAN SerialSendByte(UCHAR x)
Definition: serial.c:175
#define ACK
Definition: shared.h:126

Referenced by Connect().

◆ SerialReadByte()

BOOLEAN SerialReadByte ( PUCHAR  px)

Definition at line 152 of file serial.c.

153 {
154  ULONG timeout;
155 
156  timeout = 0x00FFFFL;
157 
158  // Wait for transmitter to clear
159  while ((inportb((USHORT)(usSerialPortBase + LSR)) & RCVRDY) == 0)
160  if (!(--timeout))
161  {
162  return FALSE;
163  }
164 
165  *px = inportb((USHORT)(usSerialPortBase + RXR));
166 
167  return TRUE;
168 }
#define TRUE
Definition: types.h:120
UCHAR inportb(PUCHAR port)
Definition: utils.c:2174
Definition: dhcpd.h:245
GLbitfield GLuint64 timeout
Definition: glext.h:7164
#define LSR
Definition: serial_port.h:67
#define RCVRDY
Definition: serial_port.h:104
USHORT usSerialPortBase
Definition: serial.c:51
static const WCHAR L[]
Definition: oid.c:1250
unsigned short USHORT
Definition: pedump.c:61
#define RXR
Definition: serial_port.h:61
unsigned int ULONG
Definition: retypes.h:1

Referenced by FlushSerialBuffer(), SendPacket(), and SendPacketTimeout().

◆ SerialSendByte()

BOOLEAN SerialSendByte ( UCHAR  x)

Definition at line 175 of file serial.c.

176 {
177  ULONG timeout;
178 
179  timeout = 0x00FFFFL;
180 
181  // Wait for transmitter to clear
182  while ((inportb((USHORT)(usSerialPortBase + LSR)) & XMTRDY) == 0)
183  if (!(--timeout))
184  {
185  return FALSE;
186  }
187 
189 
190  return TRUE;
191 }
#define TRUE
Definition: types.h:120
UCHAR inportb(PUCHAR port)
Definition: utils.c:2174
#define TXR
Definition: serial_port.h:60
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
Definition: dhcpd.h:245
GLbitfield GLuint64 timeout
Definition: glext.h:7164
#define LSR
Definition: serial_port.h:67
void outportb(PUCHAR port, UCHAR data)
Definition: utils.c:2154
USHORT usSerialPortBase
Definition: serial.c:51
#define XMTRDY
Definition: serial_port.h:109
static const WCHAR L[]
Definition: oid.c:1250
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1

Referenced by SendPacket(), and SendPacketTimeout().

◆ SerialSetOthers()

void SerialSetOthers ( ULONG  Parity,
ULONG  Bits,
ULONG  StopBit 
)

Definition at line 86 of file serial.c.

87 {
88  ULONG setting;
89  UCHAR c;
90 
91  if (usSerialPortBase == 0) return ;
92  if (Bits < 5 || Bits > 8) return ;
93  if (StopBit != 1 && StopBit != 2) return ;
94  if (Parity != NO_PARITY && Parity != ODD_PARITY && Parity != EVEN_PARITY)
95  return;
96 
97  setting = Bits-5;
98  setting |= ((StopBit == 1) ? 0x00 : 0x04);
99  setting |= Parity;
100 
102  outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)(c & ~0x80)); // Reset DLAB
103 
104  // no ints
106 
107  // clear FIFO and disable them
109 
111 
113 
114 
115  return ;
116 }
return
Definition: dirsup.c:529
UCHAR inportb(PUCHAR port)
Definition: utils.c:2174
#define ODD_PARITY
Definition: serial.c:90
#define RTS
Definition: serial_port.h:127
#define IER
Definition: serial_port.h:62
void outportb(PUCHAR port, UCHAR data)
Definition: utils.c:2154
#define MCR
Definition: serial_port.h:66
const GLubyte * c
Definition: glext.h:8905
USHORT usSerialPortBase
Definition: serial.c:51
#define LCR
Definition: serial_port.h:65
unsigned char UCHAR
Definition: xmlstorage.h:181
#define NO_PARITY
Definition: serial.c:89
unsigned short USHORT
Definition: pedump.c:61
#define EVEN_PARITY
Definition: serial.c:91
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
#define DTR
Definition: serial_port.h:126
#define FCR
Definition: serial_port.h:64

Referenced by SetupSerial().

◆ SerialSetSpeed()

void SerialSetSpeed ( ULONG  baudrate)


Definition at line 66 of file serial.c.

67 {
68  UCHAR c;
69  ULONG divisor;
70 
71  divisor = (ULONG) (115200L/baudrate);
72 
74  outportb((USHORT)(usSerialPortBase + LCR), (UCHAR)(c | 0x80)); // Set DLAB
75  outportb((USHORT)(usSerialPortBase + DLL), (UCHAR)(divisor & 0x00FF));
76  outportb((USHORT)(usSerialPortBase + DLH), (UCHAR)((divisor >> 8) & 0x00FF));
77  outportb((USHORT)(usSerialPortBase + LCR), c); // Reset DLAB
78 
79 }
UCHAR inportb(PUCHAR port)
Definition: utils.c:2174
void outportb(PUCHAR port, UCHAR data)
Definition: utils.c:2154
const GLubyte * c
Definition: glext.h:8905
USHORT usSerialPortBase
Definition: serial.c:51
#define LCR
Definition: serial_port.h:65
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define DLH
Definition: serial_port.h:70
GLuint divisor
Definition: glext.h:6313
unsigned short USHORT
Definition: pedump.c:61
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1
#define DLL
Definition: serial_port.h:69

Referenced by SetupSerial().

◆ SetBackgroundColorSerial()

void SetBackgroundColorSerial ( ECOLORS  col)

Definition at line 330 of file serial.c.

331 {
332  eBackgroundColor = col;
333 }
ECOLORS eBackgroundColor
Definition: serial.c:60

Referenced by ConsoleInitSerial().

◆ SetForegroundColorSerial()

void SetForegroundColorSerial ( ECOLORS  col)

Definition at line 321 of file serial.c.

322 {
323  eForegroundColor = col;
324 }
ECOLORS eForegroundColor
Definition: serial.c:60

Referenced by ConsoleInitSerial().

◆ SetupSerial()

void SetupSerial ( ULONG  port,
ULONG  baudrate 
)


Definition at line 133 of file serial.c.

134 {
136 
137  usSerialPortBase = ports[port-1];
139  SerialSetSpeed(baudrate);
140 
141  // clear out received bytes
142  // else we would think there's a terminal connected
144 }
void SerialSetOthers(ULONG Parity, ULONG Bits, ULONG StopBit)
Definition: serial.c:86
#define COM2BASE
Definition: serial_port.h:36
#define COM1BASE
Definition: serial_port.h:35
void SerialSetSpeed(ULONG baudrate)
Definition: serial.c:66
void FlushSerialBuffer(void)
Definition: serial.c:122
#define COM4BASE
Definition: serial_port.h:40
USHORT usSerialPortBase
Definition: serial.c:51
#define NO_PARITY
Definition: serial.c:89
unsigned short USHORT
Definition: pedump.c:61
#define COM3BASE
Definition: serial_port.h:39
USHORT port
Definition: uri.c:227

Referenced by ConsoleInitSerial().

◆ ShowCursorSerial()

void ShowCursorSerial ( void  )

Definition at line 383 of file serial.c.

384 {
387 
388  ENTER_FUNC();
389 
391 
393  pCursor->type = PACKET_TYPE_CURSOR;
394  pCursor->state = (UCHAR)TRUE;
395  pCursor->x = (UCHAR)wWindow[OUTPUT_WINDOW].usCurX;
396  pCursor->y = (UCHAR)wWindow[OUTPUT_WINDOW].usCurY;
397 
398  p = AssemblePacket((PUCHAR)pCursor,sizeof(SERIAL_DATA_PACKET_CURSOR));
399  SendPacket(p);
400 
401  LEAVE_FUNC();
402 }
BOOLEAN bCursorEnabled
Definition: hardware.c:51
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
#define LEAVE_FUNC()
Definition: debug.h:43
BOOLEAN SendPacket(PSERIAL_PACKET p)
Definition: serial.c:225
WINDOW wWindow[4]
Definition: hardware.c:59
struct _SERIAL_DATA_PACKET_CURSOR * PSERIAL_DATA_PACKET_CURSOR
Definition: dhcpd.h:135
unsigned char UCHAR
Definition: xmlstorage.h:181
PSERIAL_PACKET AssemblePacket(PUCHAR pData, ULONG ulSize)
Definition: serial.c:295
#define ENTER_FUNC()
Definition: debug.h:42
GLfloat GLfloat p
Definition: glext.h:8902
#define PACKET_TYPE_CURSOR
Definition: shared.h:179

Referenced by ConsoleInitSerial().

Variable Documentation

◆ assemble_packet

UCHAR assemble_packet[_PAGE_SIZE]

Definition at line 54 of file serial.c.

Referenced by AssemblePacket().

◆ eBackgroundColor

ECOLORS eBackgroundColor =BLACK

Definition at line 60 of file serial.c.

Referenced by ClrLineSerial(), FlushSerial(), and SetBackgroundColorSerial().

◆ eForegroundColor

ECOLORS eForegroundColor =WHITE

Definition at line 60 of file serial.c.

Referenced by ClrLineSerial(), FlushSerial(), and SetForegroundColorSerial().

◆ flush_buffer

UCHAR flush_buffer[_PAGE_SIZE]

Definition at line 56 of file serial.c.

Referenced by FlushSerial(), and PrintGrafSerial().

◆ g_x

UCHAR g_x

Definition at line 56 of file serial.c.

Referenced by FlushSerial(), and PrintGrafSerial().

◆ g_y

UCHAR g_y

Definition at line 56 of file serial.c.

Referenced by FlushSerial(), and PrintGrafSerial().

◆ packet

◆ pScreenBufferSerial

PUCHAR pScreenBufferSerial

Definition at line 49 of file serial.c.

Referenced by ConsoleInitSerial(), ConsoleShutdownSerial(), and PrintGrafSerial().

◆ ucLastKeyRead

UCHAR ucLastKeyRead

Definition at line 59 of file serial.c.

Referenced by GetKeyPolledSerial(), and SendPacket().

◆ ulFlushBufferPos

ULONG ulFlushBufferPos = 0

Definition at line 57 of file serial.c.

Referenced by FlushSerial(), and PrintGrafSerial().

◆ usSerialPortBase

USHORT usSerialPortBase

Definition at line 51 of file serial.c.

Referenced by SerialReadByte(), SerialSendByte(), SerialSetOthers(), SerialSetSpeed(), and SetupSerial().

◆ wWindowSerial

WINDOW wWindowSerial[4]
Initial value:
=
{
{1,3,1,0,FALSE},
{5,8,1,0,FALSE},
{14,26,1,0,FALSE},
{41,18,1,0,FALSE}
}

Definition at line 41 of file serial.c.

Referenced by ConsoleInitSerial().