Esempio n. 1
0
void DebugPuts (char* str) {
	if (!str)
		return;
size_t i = 0;
	for (i=0; i<strlen (str); i++)
		DebugPutc (str[i]);

}
Esempio n. 2
0
/*
 * .KB_C_FN_DEFINITION_START
 * void DebugPrint(char *)
 *  This global function writes a string to the debug uart port.
 * .KB_C_FN_DEFINITION_END
 */
void DebugPrint(char *buffer) {

	if (!buffer) return;

	while(*buffer != '\0') {
		DebugPutc(*buffer++);
	}
}
//! Displays a string
void DebugPuts (char* str) {

	if (!str)
		return;

	//! err... displays a string
    for (unsigned int i=0; i<strlen(str); i++)
        DebugPutc (str[i]);
}
Esempio n. 4
0
/*
 * .KB_C_FN_DEFINITION_START
 * void ReadMem(unsigned address, unsigned length, unsigned size)
 *  This global function displays a block of memory in size increments.
 * .KB_C_FN_DEFINITION_END
 */
void ReadMem(unsigned address, unsigned length, unsigned size) {

	unsigned	i, perLine;
	char		charValue;
	unsigned short	shortValue;
	unsigned	longValue;
	

	perLine = 16 / size;

	while (length) {
		i = perLine;

		if (length < 16) {
			i = (length/size);
			length = 0;
		} else {
			length -= 16;
		}

		DebugPrint("\n\r(R)");
		DebugPrintHex(8, address);
		DebugPrint(" : ");

		while (i--) {
			switch (size) {
				case 1:
					charValue = *(unsigned char*)address;
					DebugPrintHex(2, charValue);
					address += 1;
					break;
				case 2:
					shortValue = *(unsigned short*)address;
					DebugPrintHex(4, shortValue);
					address += 2;
					break;
				case 4:
					longValue = *(unsigned*)address;
					DebugPrintHex(8, longValue);
					address += 4;
					break;
				default:
					return ;
			}

			DebugPutc(' ');
		}
	}
}
Esempio n. 5
0
//! read command
void cmd_read() {

	//! get pathname
	char path[32];
	DebugPrintf("\n\rex: \"file.txt\", \"a:\\file.txt\", \"a:\\folder\\file.txt\"\n\rFilename> ");
	console.GetCommand(path, 30);

	//! open file
	FILE file = volOpenFile(path);

	//! test for invalid file
	if (file.flags == FS_INVALID) {

		DebugPrintf("\n\rUnable to open file");
		return;
	}

	//! cant display directories
	if ((file.flags & FS_DIRECTORY) == FS_DIRECTORY) {

		DebugPrintf("\n\rUnable to display contents of directory.");
		return;
	}

	//! top line
	DebugPrintf("\n\n\r-------[%s]-------\n\r", file.name);

	//! display file contents
	while (file.eof != 1) {

		//! read cluster
		unsigned char buf[512];
		volReadFile(&file, buf, 512);

		//! display file
		for (int i = 0; i<512; i++)
			DebugPutc(buf[i]);

		//! wait for input to continue if not EOF
		if (file.eof != 1) {
			DebugPrintf("\n\r------[Press a key to continue]------");
			console.GetChar();
			DebugPrintf("\r"); //clear last line
		}
	}

	//! done :)
	DebugPrintf("\n\n\r--------[EOF]--------");
}
Esempio n. 6
0
int DebugPrintf (const char* str, ...) {
	
	if(!str)
		return 0;
	va_list		args;
	size_t i;
	va_start (args, str);
	for (i=0; i<strlen(str);i++) {
		switch (str[i]) {
			case '%':
				switch (str[i+1]) {
					case 'c': {
						char c = va_arg (args, char);
						DebugPutc (c);
						i++;		
						break;
					}
					case 's': {
						int c = (int) va_arg (args, char);
						char str[32]={0};
						itoa_s (c, 16, str);
						DebugPuts (str);
						i++;		
						break;
					}

					case 'd':

					case 'i': {

						int c = va_arg (args, int);

						char str[32]={0};

						itoa_s (c, 10, str);

						DebugPuts (str);

						i++;		

						break;

					}




					case 'X':

					case 'x': {

						int c = va_arg (args, int);

						char str[32]={0};

						itoa_s (c,16,str);

						DebugPuts (str);

						i++;		

						break;

					}



					default:

						va_end (args);

						return 1;

				}



				break;



			default:

				DebugPutc (str[i]);

				break;

		}



	}
	va_end (args);
}
//! Displays a formatted string
int DebugPrintf (const char* str, ...) {

	if(!str)
		return 0;

	va_list		args;
	va_start (args, str);
	size_t i;
	for (i=0; i<strlen(str);i++) {

		switch (str[i]) {

			case '%':

				switch (str[i+1]) {

					/*** characters ***/
					case 'c': {
						char c = va_arg (args, char);
						DebugPutc (c);
						i++;		// go to next character
						break;
					}

					/*** address of ***/
					case 's': {
						int c = (int&) va_arg (args, char);
						char str[64];
						strcpy (str,(const char*)c);
						DebugPuts (str);
						i++;		// go to next character
						break;
					}

					/*** integers ***/
					case 'd':
					case 'i': {
						int c = va_arg (args, int);
						char str[32]={0};
						itoa_s (c, 10, str);
						DebugPuts (str);
						i++;		// go to next character
						break;
					}

					/*** display in hex ***/
					case 'X':
					case 'x': {
						int c = va_arg (args, int);
						char str[32]={0};
						itoa_s (c,16,str);
						DebugPuts (str);
						i++;		// go to next character
						break;
					}

					default:
						va_end (args);
						return 1;
				}

				break;

			default:
				DebugPutc (str[i]);
				break;
		}

	}

	va_end (args);
	return i;
}