testapp.c 2.16 KB
#include <PR/rcp.h>
#include <PR/rdb.h>

#define DEV_CNSLE_TX_INTR            0x01 /* intr enable / state bits */
#define DEV_CNSLE_RX_INTR            0x02
 
// Type changed from long long to int
//typedef unsigned long long DevRegister;
typedef unsigned int DevRegister;
typedef struct DevConsoleRegisters {
	DevRegister intr_status;      /* r: intr state / w: intr enable */
	DevRegister data;             /* r: current char / w: send char */
} DevConsoleRegisters;

#define K1BASE	(0xA0000000)

#include "skapi.h"

void __putChars(int length, const char *buf);
void __disable_int();

main(int argc, char* argv) 
{
    volatile DevConsoleRegisters* console = (DevConsoleRegisters*)
	                                           (K1BASE+0x01e01000);
    //volatile int* secureReg = (int*)(K1BASE+0x04300010);
    volatile int* secureReg = (int*)(K1BASE+MI_SEC_MODE_REG);
    //static char* s = "hello world\r\n";
    //char* s = "hello world\r\n";
    char* s = "hi\r\n";
    char* p;
    int val;
    char ch;
    char* p1 = "yow";
    char* p2 = "sa!";
    char* p3 = "\r\n";


    for(p = s; *p; p++) {
    	console->data = *p;
    }

    val = sk_entry1(4,4);
    console->data = (char)val+'0';
    console->data = '\r';
    console->data = '\n';

    val = sk_entry2(3,3);
    console->data = (char)val+'0';
    console->data = '\r';
    console->data = '\n';

    val = sk_entry3(4,4);
    console->data = (char)val+'0';
    console->data = '\r';
    console->data = '\n';

    for(;;){
        if( (console->intr_status)==DEV_CNSLE_RX_INTR ){
            ch = (char)console->data;
            console->data = ch;
	    while((console->intr_status)==DEV_CNSLE_RX_INTR );
	    // don't know why I need to read again
            ch = (char)console->data;
        }
    }
}


/* length can only be 1, 2 or 3 */
void __putChars(int length, const char *buf)
{
    int i;

    rdbPacket packet;
    packet.type=RDB_TYPE_GtoH_PRINT;
    packet.length=length;
    for(i=0;i<length;i++)
        packet.buf[i]=buf[i];
//    *( (int *)(PHYS_TO_K1(RDB_BASE_REG)) ) = *((int *)&packet);
    *( (unsigned int *)((RDB_BASE_VIRTUAL_ADDR)) ) = *((unsigned int *)&packet);
//    *( (int *)(RDB_READ_INTR_REG)) ) = 0;    
}