/* * boot zImage * setup linux parameter , command line, and the boot linux from addr * addr : base address of linux zImage */ int boot_zimage(ulong addr) { int ret __attribute__((unused)); ulong boot_mem_base; /* base address of bootable memory 嘎唱? */ ulong to; ulong mach_type; boot_mem_base = SDRAM_START; to = addr; if (*(ulong *)(to + 9*4) != LINUX_ZIMAGE_MAGIC) { printf("Warning: this binary is not compressed linux kernel image\n"); printf("zImage magic = 0x%08lx\n", *(ulong *)(to + 9*4)); } else { printf("zImage magic = 0x%08lx\n", *(ulong *)(to + 9*4)); } /* Setup linux parameters and linux command line */ setup_linux_param(boot_mem_base + LINUX_PARAM_OFFSET); /* Get machine type */ mach_type = MACH_TYPE_TQ2440; printf("\nnow, booting linux......\n"); call_linux(0, mach_type, to); return 0; }
int boot_zImage(long from, int size) { //puts("BootingLinux2\n\r"); int ret; long boot_mem_base; /* base address of bootable memory */ long to; long mach_type; boot_mem_base = 0x30000000; /* copy kerne image */ to = boot_mem_base + LINUX_KERNEL_OFFSET; puts("Copy linux kernel from 0x00200000 to 0x30008000, size = 0x40000 .....\n\r "); ret = copy_kernel_img(to, (char *)from, size); if (ret) { puts("failed\n\r"); return -1; } else { puts("Copy Kernel to SDRAM done,\n\r"); } if (*(long *)(to + 9*4) != LINUX_ZIMAGE_MAGIC) { puts("Warning: this binary is not compressed linux kernel image\n"); puts("zImage magic = 0x%08lx\n", *(long *)(to + 9*4)); } else { // puts("zImage magic = 0x%08lx\n", *(long *)(to + 9*4)); ; } /* Setup linux parameters and linux command line */ setup_linux_param(boot_mem_base + LINUX_PARAM_OFFSET); /* Get machine type */ mach_type = MACH_TYPE_S3C2440; puts("MACH_TYPE = 168\n\r"); /* Go Go Go */ puts("NOW, Booting Linux......\n"); call_linux(0, mach_type, to); return 0; }
void comdownload(void) { ULONG size; UCHAR *buf; USHORT checksum; puts("\nNow download file from uart0...\n"); downloadAddress = _NONCACHE_STARTADDRESS; buf = (UCHAR *)downloadAddress; temp = buf-4; Uart_GetKey(); #ifdef USE_UART_INT pISR_UART0 = (ULONG)Uart0RxInt; //串口接收数据中断 ClearSubPending(BIT_SUB_RXD0); ClearPending(BIT_UART0); EnableSubIrq(BIT_SUB_RXD0); EnableIrq(BIT_UART0); #endif while((ULONG)temp<(ULONG)buf) { #ifdef USE_UART_INT Led_Display(0); Delay(1000); Led_Display(15); Delay(1000); #else *temp++ = Uart_Getch(); #endif } //接收文件长度,4 bytes size = *(ULONG *)(buf-4); downloadFileSize = size-6; #ifdef USE_UART_INT printf("Download File Size = %d\n", size); #endif while(((ULONG)temp-(ULONG)buf)<(size-4)) { #ifdef USE_UART_INT Led_Display(0); Delay(1000); Led_Display(15); Delay(1000); #else *temp++ = Uart_Getch(); #endif } #ifdef USE_UART_INT DisableSubIrq(BIT_SUB_RXD0); DisableIrq(BIT_UART0); #endif #ifndef USE_UART_INT printf("Download File Size = %d\n", size); #endif checksum = 0; for(size=0; size<downloadFileSize; size++) checksum += buf[size]; if(checksum!=(buf[size]|(buf[size+1]<<8))) { puts("Checksum fail!\n"); return; } puts("Are you sure to run? [y/n]\n"); while(1) { UCHAR key = getch(); if(key=='n') return; if(key=='y') break; } call_linux(0, 193, downloadAddress); }