예제 #1
0
void run_printf_test( void )
{
    uint16_t uval = 0;
    int16_t ival = 0;

    hal_initialize();

    gfx_init();
    backlight_init();
    backlight_set_brightness(90);
    tty_enable_view(bTrue);

#ifdef TEST_FOREVER
    for(;;)
#endif
    {
        tiny_sprintf(buffer, "test: %u, %d, %x, %B", ival, ival, ival, ival);

        tiny_printf("uint: %u, int: %d, hex: %x or %X, bhex: %b or %B, escape: %%\n",
                uval, ival, uval, uval, uval, uval);

        tiny_printf("string test %d: %s (OK)\n", uval, buffer);

        uval++;
        ival = ival > 0 ? -uval : uval;

        delay_ms(500);
    }
}
예제 #2
0
void run_rtc_test(void)
{
    hal_initialize();

    gfx_init();
    backlight_init();
    backlight_set_brightness(90);
    tty_enable_view(bTrue);

    rtc_initialize();
    rtc_set(&setupTime);

#ifdef TEST_FOREVER
    for(;;)
#endif
    {
        tty_enable_view(bFalse);
        tty_reset();
        rtc_now(&nowTime);
        rtc_format_time(&nowTime, RTC_FMT_DATE | RTC_FMT_TIME | RTC_FMT_SECONDS | RTC_FMT_WEEK, tty_outchar);
        tty_enable_view(bTrue);

        delay_ms(200);
    }
} 
int _cdecl main () {

	DebugClrScr (0x18);

	DebugGotoXY (0,0);
	DebugSetColor (0x70);
	DebugPrintf (" Sistemas Operativos I - CEUTEC...                       ");
	DebugGotoXY (0,1);
	DebugSetColor (0x19);
	DebugPrintf (" TF141 Iniciando...\n");

	DebugSetColor (0x70);
	DebugGotoXY (0,24);
	DebugPrintf (" Inicializando Capa de Abstraccion de Hardware (HAL.lib)...                           ");

	DebugSetColor (0x19);
	DebugGotoXY (0,2);

	hal_initialize ();

//! uncomment to generate interrupt 0x15. This will call the default exception handler
//	geninterrupt (0x15);

	return 0;
}
예제 #4
0
void run_touch_test( void )
{
    uint16_t ret = 0;

    hal_initialize();

    gfx_init();
    backlight_init();
    backlight_set_brightness(90);
    tty_enable_view(bTrue);

    tty_output_delayed("TOUCH test! Initialization... \n", 1000);

    ret = touch_initialize();
    guard(ret);

    touch_set_event_handler(touchEventFunc);

#ifdef TEST_FOREVER
    for(;;)
#endif
    {
        //tty_enable_view(False);
        //tty_reset();

        ret = touch_process();
        guard(ret);

        //tty_enable_view(True);
        delay_ms(100);
    }
}
예제 #5
0
int KernelMain () {

  //Initialize HAL
  hal_initialize();

  ClearScreen(0x10);
  SetColor(0b01110000);	
  GotoXY(30,5);
  DisplayString((uint8_t*)" <ENGI 3655 Kernel> ");
  SetColor(0b00011111);
  
  __asm__ ( "sti" );
  DisplayString((uint8_t*)"\n\n");
  DisplayString((uint8_t*)"         A fatal exception has not occured at memory location 0x1337.\n");
  DisplayString((uint8_t*)"         The current application will not be terminated.\n");
  DisplayString((uint8_t*)"\n         *  The current application will not be terminated\n");
  DisplayString((uint8_t*)"         *  Press CTRL+ALT+DEL to do nothing, please don't bother. Also,");
  DisplayString((uint8_t*)"                    there are no unsaved changes, so don't worry about it.\n");
  DisplayString((uint8_t*)"\n                          Press any key to do nothing\n");
  
    
  GotoXY(0, GetHeight()-1);

  //Start of test Divide by Zero
  
  SetColor(0x12);
  DisplayString("Start of Divisions");
  DisplayString("\n");
  DisplayInteger(6/0);
  DisplayString("\n");
  DisplayInteger(5/1);
  DisplayString("\n");
  DisplayInteger(6/3);
  DisplayString("\n");
  DisplayInteger(6/0);
  DisplayString("\n");
  DisplayInteger(20/0);
  DisplayString("\n");
  DisplayInteger(7/0);
  DisplayString("\n");
  DisplayInteger(12/4);
  DisplayString("\n");
  DisplayString("End of Divisions");
  //End of test Divide by Zero



  while(1);

  hal_shutdown();

  return 0;
}
예제 #6
0
void setup()
{
	uint32_t memSize = 1024 + bootinfo->m_memoryLo + bootinfo->m_memoryHi*64;

	// All data past the kernel is free to use
	pmmngr_init(memSize,0x100000 + kernelSize * 512);

	memory_region* region = (memory_region*)0x1000;

	for(int i = 0;region[i].startLo != 0 || i == 0;i++)
	{
		if(region[i].type > 4)
			region[i].type = 1;

		if(region[i].type == 1)
			pmmngr_init_region(region[i].startLo,region[i].sizeLo);
	}

	// Kernal location
	pmmngr_deinit_region(0x100000,kernelSize * 512 + pmmngr_get_block_count() / PMMNGR_BLOCKS_PER_BYTE);

	// c++ at exit runtime function pointers
	pmmngr_deinit_region(0x50000,sizeof(unsigned) * 32);
	
	// Boot data retained in bootinfo
	pmmngr_deinit_region((physical_addr)bootinfo,sizeof(multiboot_info));
	
	// Initialize DMA buffer here using deinit, not pmalloc()
	pmmngr_deinit_region((physical_addr)DMA_BUFFER,0x200);

	// Don't corrupt the stack
	mmngr_stack_init(0x90000,0x16000);

	hal_initialize();
	kybrd_init(0x21);
	install_interrupts();
	vmmngr_initialize();
	enable_interrupts();

	flpydsk_set_working_drive(0);
	flpydsk_install(0x26);

	fsysFatInitialize();

	return;
}
예제 #7
0
파일: main.cpp 프로젝트: Danielnkf/KinXOS
int _cdecl kmain (multiboot_info* bootinfo) {

	//! get kernel size passed from boot loader
	uint32_t kernelSize=0;
	_asm mov	word ptr [kernelSize], dx

	//! make demo look nice :)
	DebugClrScr (0x13);
	DebugGotoXY (0,0);

	DebugSetColor (0x3F);
	DebugPrintf ("                    ~[ Physical Memory Manager Demo ]~                          ");

	DebugGotoXY (0,24);
	DebugSetColor (0x3F);
	DebugPrintf ("                                                                                ");

	DebugGotoXY (0,2);
	DebugSetColor (0x17);

	//! initialize hal
	hal_initialize ();

	//! enable interrupts and install exception handlers
	enable ();
	setvect (0,(void (__cdecl &)(void))divide_by_zero_fault);
	setvect (1,(void (__cdecl &)(void))single_step_trap);
	setvect (2,(void (__cdecl &)(void))nmi_trap);
	setvect (3,(void (__cdecl &)(void))breakpoint_trap);
	setvect (4,(void (__cdecl &)(void))overflow_trap);
	setvect (5,(void (__cdecl &)(void))bounds_check_fault);
	setvect (6,(void (__cdecl &)(void))invalid_opcode_fault);
	setvect (7,(void (__cdecl &)(void))no_device_fault);
	setvect (8,(void (__cdecl &)(void))double_fault_abort);
	setvect (10,(void (__cdecl &)(void))invalid_tss_fault);
	setvect (11,(void (__cdecl &)(void))no_segment_fault);
	setvect (12,(void (__cdecl &)(void))stack_fault);
	setvect (13,(void (__cdecl &)(void))general_protection_fault);
	setvect (14,(void (__cdecl &)(void))page_fault);
	setvect (16,(void (__cdecl &)(void))fpu_fault);
	setvect (17,(void (__cdecl &)(void))alignment_check_fault);
	setvect (18,(void (__cdecl &)(void))machine_check_abort);
	setvect (19,(void (__cdecl &)(void))simd_fpu_fault);

	//! get memory size in KB
	uint32_t memSize = 1024 + bootinfo->m_memoryLo + bootinfo->m_memoryHi*64;

	//! initialize the physical memory manager
	//! we place the memory bit map used by the PMM at the end of the kernel in memory
	pmmngr_init (memSize, 0x100000 + kernelSize*512);

	DebugPrintf("pmm initialized with %i KB physical memory; memLo: %i memHi: %i\n\n",
		memSize,bootinfo->m_memoryLo,bootinfo->m_memoryHi);

	DebugSetColor (0x19);
	DebugPrintf ("Physical Memory Map:\n");

	memory_region*	region = (memory_region*)0x1000;

	for (int i=0; i<15; ++i) {

		//! sanity check; if type is > 4 mark it reserved
		if (region[i].type>4)
			region[i].type=1;

		//! if start address is 0, there is no more entries, break out
		if (i>0 && region[i].startLo==0)
			break;

		//! display entry
		DebugPrintf ("region %i: start: 0x%x%x length (bytes): 0x%x%x type: %i (%s)\n", i, 
			region[i].startHi, region[i].startLo,
			region[i].sizeHi,region[i].sizeLo,
			region[i].type, strMemoryTypes[region[i].type-1]);

		//! if region is avilable memory, initialize the region for use
		if (region[i].type==1)
			pmmngr_init_region (region[i].startLo, region[i].sizeLo);
	}

	//! deinit the region the kernel is in as its in use
	pmmngr_deinit_region (0x100000, kernelSize*512);

	DebugSetColor (0x17);

	DebugPrintf ("\npmm regions initialized: %i allocation blocks; used or reserved blocks: %i\nfree blocks: %i\n",
		pmmngr_get_block_count (),  pmmngr_get_use_block_count (), pmmngr_get_free_block_count () );

	//! allocating and deallocating memory examples...

	DebugSetColor (0x12);

	uint32_t* p = (uint32_t*)pmmngr_alloc_block ();
	DebugPrintf ("\np allocated at 0x%x", p);

	uint32_t* p2 = (uint32_t*)pmmngr_alloc_blocks (2);
	DebugPrintf ("\nallocated 2 blocks for p2 at 0x%x", p2);

	pmmngr_free_block (p);
	p = (uint32_t*)pmmngr_alloc_block ();
	DebugPrintf ("\nUnallocated p to free block 1. p is reallocated to 0x%x", p);

	pmmngr_free_block (p);
	pmmngr_free_blocks (p2, 2);
	return 0;
}
예제 #8
0
파일: main.c 프로젝트: BridgeHill/unabto
void main(void)
{
  static nabto_main_setup* nms;
  static char versionString[NABTO_DEVICE_VERSION_MAX_SIZE];
  static char idString[NABTO_DEVICE_NAME_MAX_SIZE];
#if NABTO_ENABLE_UCRYPTO
  static const far rom uint8_t dummySharedSecret[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  static const far rom uint8_t* sharedSecret;
#endif

  // <editor-fold desc="Load information from bootloader and application data areas.">

  // Clear the global TCP/IP data structure and load it with the boards unique preprogrammed MAC address.
  memset((void*) &AppConfig, 0x00, sizeof (AppConfig));
  memcpypgm2ram(&AppConfig.MyMACAddr, (const __ROM uint8_t*) bootloaderData.version1.mac, 6);

  if(bootloaderData.base.bootloaderDataVersion == 1)
  {
    strcpypgm2ram(idString, (const far rom char*) bootloaderData.version1.serialNumber);
    strcatpgm2ram(idString, ".nabduino.net");

#if NABTO_ENABLE_UCRYPTO
    //        sharedSecret = applicationData.sharedSecret; // the old pre-bootloader-version-2 way of storing the shared secret - obsolete!
#endif
  }
  else if(bootloaderData.base.bootloaderDataVersion == 2)
  {
    hardwareVersion = (uint8_t) bootloaderData.version2.hardwareVersionMajor;
    hardwareVersion <<= 8;
    hardwareVersion |= (uint8_t) bootloaderData.version2.hardwareVersionMinor;

    if(hardwareVersion == 0x0004)
    {
      hardwareVersionIndex = 0; // first version of the board that was released.
    }
    else if(hardwareVersion == 0x0102)
    {
      hardwareVersionIndex = 1; // second version of the board that was released (yes we jumped from 0.4 beta to 1.2).
    }
    else if(hardwareVersion == 0x0103)
    {
      hardwareVersionIndex = 2; // third version of the board
    }

    strcpypgm2ram(idString, (const far rom char*) bootloaderData.version2.deviceId);
    strcatpgm2ram(idString, (const far rom char*) bootloaderData.version2.productDomain);

#if NABTO_ENABLE_UCRYPTO
    sharedSecret = bootloaderData.version2.sharedSecret;
#endif
  }
  else
  { // unsupported version so it's probably safe to assume that bootloader data has been wiped - please fill in the appropriate values for your Nabduino board
    hardwareVersionIndex = 0; // hardware version 0.4 = 0, v1.2 = 1, v1.3 = 2

    AppConfig.MyMACAddr.v[0] = 0xBC; // Nabto owned MAC OUI is BC:A4:E1
    AppConfig.MyMACAddr.v[1] = 0xA4;
    AppConfig.MyMACAddr.v[2] = 0xE1;
    AppConfig.MyMACAddr.v[3] = 0x00;
    AppConfig.MyMACAddr.v[4] = 0x00;
    AppConfig.MyMACAddr.v[5] = 0x00; // If using more than one Nabduino on the same network make this byte unique for each board

    strcpypgm2ram(idString, "XXX"); // replace XXX with the id of the Nabduino board
    strcatpgm2ram(idString, ".nabduino.net");

#if NABTO_ENABLE_UCRYPTO
    sharedSecret = dummySharedSecret;
#endif
  }

  // </editor-fold>

  // Initialize IOs etc. taking into account the hardware version.
  hal_initialize();

  // Initialize the platform (timing, TCP/IP stack, DHCP and some PIC18 specific stuff)
  platform_initialize();

  network_initialize();

  nms = unabto_init_context();

  nms->id = (const char*) idString;

  // build version string: <application SVN version>/<bootloader SVN version>/<hardware major version>.<hardware minor version>
  itoa(RELEASE_MINOR, versionString);
  strcatpgm2ram(versionString + strlen(versionString), "/");
  itoa(bootloaderData.base.buildVersion, versionString + strlen(versionString));
  strcatpgm2ram(versionString + strlen(versionString), "/");
  itoa(hardwareVersion >> 8, versionString + strlen(versionString));
  strcatpgm2ram(versionString + strlen(versionString), ".");
  itoa(hardwareVersion & 0xff, versionString + strlen(versionString));
  nms->version = (const char*) versionString;

#if NABTO_ENABLE_UCRYPTO
  memcpypgm2ram(nms->presharedKey, (const __ROM void*) sharedSecret, 16);
  nms->secureAttach = true;
  nms->secureData = true;
  nms->cryptoSuite = CRYPT_W_AES_CBC_HMAC_SHA256;
#endif

  setup((char**) &nms->url);

  unabto_init();

  while(1)
  {
    hal_tick();
    platform_tick();
    network_tick();
    unabto_tick();
    loop();
  }
}