/* initialize the heap allocation scheme */ void uHALr_InitHeap(void) { unsigned int heap_size; #ifdef DEBUG uHALr_printf("uHALr_InitHeap() called, uHAL_HEAP_BASE = 0x%x\n", uHAL_HEAP_BASE); #endif /* do not initialise more than once */ if (!uHAL_heap_inited) { uHAL_heap_inited = 1; /*Tests to see if the library version of malloc is available */ /*but does not allocate any memory size = 0. */ if ((void *)malloc == NULL) { #ifdef ADS_BUILD heap_size = uHALr_SizeOfFreeRam(); /* set up the free block (one big one to start with) */ first = (chunkHeader_t *) uHALr_StartOfFreeRam(); first->Magic = CHUNK_MAGIC; first->allocatedSize = 0; first->chunkSize = heap_size >> CHUNK_SIZE_IN_BITS; first->next = NULL; /* set up the statistics */ statistics.totalMemory = heap_size; statistics.allocatedMemory = 0; statistics.maxChunks = heap_size >> CHUNK_SIZE_IN_BITS; statistics.totalBlocks = 1; #endif }
void updateTimeTsk(void) { struct watchTime { int hms; int secs; int mins; }; watchTime ETime; int msCntr = 0; ETime.hms = 0; ETime.secs = 0; ETime.mins =0; OSSemPend(UART_sem, 0, &err); uHALr_printf(" Task%c Called.\n\n", *(char *)Id); OSSemPost(UART_sem); while(1) { OSTimeDly(1); if(TimeMode == 1) { msCntr++; if(msCntr == 100) { msCntr = 0; ETime.hms++; if(ETime.hms == 10) { ETime.secs++; ETime.hms = 0; if(ETime.secs == 60) { ETime.mins++; ETime.secs = 0; if(ETime.mins == 999) { ETime.mins =0; } } } OSSemPend(UART_sem, 0, &err); Uart_Printf(" %03x:%02x:%02x\r",ETime.mins,ETime.secs,ETime.hms); OSSemPost(UART_sem); } } } }
/* Sample routine executed when an unexpected IRQ is received */ void uHALir_UnexpectedIRQ(unsigned int irq) { #if 0 struct uHALis_IRQ *action; int i; for (i = 0; i < NR_IRQS; i++) { action = &uHALv_IRQVector[irq]; while (action && action->handler) { uHALr_printf("[%s:%d] ", action->name, i); action = action->next; } } uHALr_printf("\n"); #endif uHALr_SetLED(1); uHALr_SetLED(2); uHALr_SetLED(3); uHALr_printf("Unexpected Interrupt = %d\n", irq); }
/* start the ARM target running */ void ARMTargetStart(void) { /* request the system timer */ if (uHALr_RequestSystemTimer((void *) OSTimeTick, (const unsigned char *)"uCOS-II") <= 0) uHALr_printf("Timer/IRQ busy\n"); // New Way //RegisterIrqHandler(HandlerTIMER0, (void *) TickHandler); //RegisterIrqHandler(HandlerEINT1, (void *) Handle_Eint1); //RegisterIrqHandler(HandlerEINT4567, (void *) Handle_Eint4567); //SysENInterrupt(BIT_TIMER0|BIT_EINT4567);//|BIT_EINT1 // Old Method /* request the system timer */ if (uHALr_RequestSystemTimer((void *) OSTimeTick, (const unsigned char *)"uCOS-II") <= 0) uHALr_printf("Timer/IRQ busy\n"); /* Start system timer & enable the interrupt. */ uHALr_InstallSystemTimer(); SysENInterrupt(BIT_TIMER0|BIT_EINT4567); }
/* Call this routine before trying to change the routine attached to an IRQ */ int uHALr_FreeInterrupt(unsigned int intNum) { if (intNum >= NR_IRQS) { uHALr_printf("Can't free Interrupt %d\n", intNum); return -1; } if (IS_RESERVED_IRQ(intNum)) { uHALr_printf("Can't free reserved Interrupt %d\n", intNum); return -1; } // Disable the interrupt & then remove the handler uHALr_DisableInterrupt(intNum); uHALv_IRQVector[intNum].handler = (PrHandler) 0; #ifdef DEBUG uHALr_printf("free'd Interrupt %d\n", intNum); #endif return 0; }
/* Initialize an ARM Target board */ void ARMTargetInit(void) { sys_init(); /* Initial 44B0X's Interrupt,Port and UART */ /* ---------------- print To UART0 ---------------- */ uHALr_printf("\n Embest S3C44B0X Evaluation Board(S3CEV40)\n"); uHALr_printf(" *==================================*\n"); uHALr_printf(" *= Embest Info&Tech Co.,LTD. =*\n"); uHALr_printf(" *==================================*\n"); uHALr_printf(" *========== R&D CENTER ==========*\n"); uHALr_printf(" *======= 86-755-25631365 ========*\n"); uHALr_printf("*===== [email protected] ======*\n"); uHALr_printf(" uCOS-II Running... \n") ; /* ---------------- interrupts DEMO handler initialization ---------------- */ uHALr_InitInterrupts(); uHALr_InitTimers(); } /* targetInit */
static chunkHeader_t *firstFit(unsigned int chunks) { chunkHeader_t *blockP = first; /* very, very simple algorithm, find the first chunk big enough */ while (blockP) { #ifdef DEBUG if (blockP->Magic != CHUNK_MAGIC) { uHALr_printf("ERROR: corrupt heap @ 0x%x\n", blockP); return NULL; } #endif if ((blockP->chunkSize > chunks) && (blockP->allocatedSize == 0)) { return blockP; } blockP = blockP->next; } return NULL; }