예제 #1
0
//
// open com port
//
BOOLEAN BdPortInitialize(__in ULONG Baudrate,__in ULONG PortNum)
{
	if(!BlPortInitialize(Baudrate,PortNum,0,FALSE,&BdFileId))
		return FALSE;

	extern CHAR	DebugMessage[];
	sprintf(DebugMessage,"\nBoot Debugger Using: COM%d (Baud Rate %d)\n",PortNum,Baudrate);

	TextStringOut(DebugMessage);

	//
	// register with kd package
	//
	BdSendPacket										= &BdComSendPacket;
	BdSendControlPacket									= &BdComSendControlPacket;
	BdReceivePacket										= &BdComReceivePacket;
	BdNextPacketIdToSend								= SYNC_PACKET_ID | INITIAL_PACKET_ID;
	BdPacketIdExpected									= INITIAL_PACKET_ID;

	return TRUE;
}
예제 #2
0
VOID
BlPrint(
    PCHAR cp,
    ...
    )

/*++

Routine Description:

    Standard printf function with a subset of formating features supported.

    Currently handles

     %d, %ld - signed short, signed long
     %u, %lu - unsigned short, unsigned long
     %c, %s  - character, string
     %x, %lx - unsigned print in hex, unsigned long print in hex

    Does not do:

     - field width specification
     - floating point.

Arguments:

    cp - pointer to the format string, text string.

Returns:

    Nothing

--*/

{
    USHORT b,c,w,len;
    PUCHAR ap;
    ULONG l;

    //
    // Cast a pointer to the first word on the stack
    //
    ap = (PUCHAR)&cp + sizeof(PCHAR);

    //
    // Process the arguments using the descriptor string
    //
    while(b = *cp++) {
        if(b == '%') {

            c = *cp++;

            switch (c) {

            case 'd':
                puti((long)*((int *)ap));
                ap += sizeof(int);
                break;

            case 's':
                TextStringOut(*((PCHAR *)ap));
                ap += sizeof(char *);
                break;

            case 'c':
                //
                // Does not handle dbcs chars
                //
                pTextCharOut(*((char *)ap));
                ap += sizeof(int);
                break;

            case 'x':
                w = *((USHORT *)ap);
                len = (USHORT)ZLEN_SHORT(w);
                while(len--) pTextCharOut('0');
                putx((ULONG)*((USHORT *)ap));
                ap += sizeof(int);
                break;

            case 'u':
                putu((ULONG)*((USHORT *)ap));
                ap += sizeof(int);
                break;

            case 'w':
                c = *cp++;
                switch (c) {
                case 'S':
                case 'Z':
                    putwS(*((PUNICODE_STRING *)ap));
                    ap += sizeof(PUNICODE_STRING);
                    break;
                }
                break;

            case 'l':
                c = *cp++;

                switch(c) {

                case '0':
                    break;

                case 'u':
                    putu(*((ULONG *)ap));
                    ap += sizeof(long);
                    break;

                case 'x':
                    l = *((ULONG *)ap);
                    len = (USHORT)ZLEN_LONG(l);
                    while(len--) pTextCharOut('0');
                    putx(*((ULONG *)ap));
                    ap += sizeof(long);
                    break;

                case 'd':
                    puti(*((ULONG *)ap));
                    ap += sizeof(long);
                    break;
                }
                break;

            default :
                pTextCharOut((char)b);
                pTextCharOut((char)c);
            }
        } else {
            //
            // Could be a double-byte char.
            //
            cp = TextCharOut(cp-1);
        }
    }
}