Exemplo n.º 1
0
static ssize_t pmu_reg16_store(struct device *dev,
			       struct device_attribute *attr,
			       const char *buf, size_t count)
{
	int ret;
	int addr;
	uint16_t value;
	char *arg[3] = {}, *para, *buf_work, *p;
	int i;

	buf_work = kstrdup(buf, GFP_KERNEL);
	p = buf_work;
	for (i = 0; i < 3; i++) {
		para = strsep(&p, " ");
		if (para == NULL)
			break;
		arg[i] = para;
	}
	if (i < 2 || i > 3) {
		ret = 1;
		goto error;
	}
	switch (arg[0][0]) {
	case 'r':
		ret = kstrtoint(arg[1], 16, &addr);
		ret = aml1216_read16(addr, &value);
		if (!ret)
			pr_info("reg[0x%03x] = 0x%04x\n", addr, value);
		break;

	case 'w':
		if (i != 3) {   /* parameter is not enough */
			ret = 1;
			break;
		}
		ret = kstrtoint(arg[1], 16, &addr);
		ret = kstrtou16(arg[2], 16, &value);
		ret   = aml1216_write16(addr, value);
		if (!ret)
			pr_info("set reg[0x%03x] to 0x%04x\n", addr, value);
		break;

	default:
		ret = 1;
		break;
	}
error:
	kfree(buf_work);
	if (ret == 1)
		printf_usage();
	return count;
}
Exemplo n.º 2
0
static void usage(void)
{
    printf_usage("outbound viewer",
                 "usage: bfstat [-afhprst] [-n<number>]\n"
                 "\n"
                 "options:\n"
                 "  -a                sort by FTN address (default)\n"
                 "  -c                print incoming/outgoing calls statistic\n"
                 "  -f                disable queue sorting\n"
                 "  -h                print this help message\n"
                 "  -n <number>       don't print more than <number> systems\n"
                 "  -p                print sizes in human readable format\n"
                 "  -r                reverse order while sorting\n"
                 "  -s                sort by total files size\n"
                 "  -t                disable total sizes printing\n"
                 "\n"
                );
}
Exemplo n.º 3
0
static void usage(void)
{
	printf_usage(NULL,
		"call:\n"
		"  use nodelist and config overrides\n"
		"    bforce [-f] [-I<include>] [-p<device>] <node>\n"
		"  use modem\n"
		"    bforce [-f] [-I<include>] -n<phone> [-l<line_number>] \n"
		"              [-p<device>] <node>\n"
		"  use TCP/IP\n"
		"    bforce [-I<include>] [-a<ip_address>] -u proto <node>\n"
		"  start on stdio\n"
		"    bforce [-f] [-I<include>] -o <node>\n"
		"\n"
		"answer:\n"
		"  bforce [-i] [-I<include>] [-S<connect>]\n"
		"     <tsync|yoohoo|emsi|binkp|auto>\n"
		"\n"
		"start daemon:\n"
		"  bforce -d [-C<config>] [-I<include>]\n"
		"\n"
		"stop daemon:\n"
		"  bforce -q [-C<config>] [-I<include>]\n"
		"\n"
		"options:\n"
		"  -i                      run from inetd (for slave mode only)\n"
		"  -f                      ignore system's work time\n"
		"  -C <config>             main config file name (\"%s\")\n"
		"  -I <config>             additional config file name (one allowed)\n"
		"  -n <phone>              override phone number\n"
		"  -l <line_number>        call on this hidden line (default is 0) \n"
		"  -a <ip_address>         override internet address\n"
		"  -S <connect_str>        connect string (for slave mode only)\n"
		"  -p <port>               override modem port (must be defined in config)\n"
		"  -u binkp|ifcico|telnet  protocol to use over TCP/IP\n"
		"  -h                      show this help message\n"
		"\n",
		conf_getconfname()
	);
}
Exemplo n.º 4
0
static ssize_t pmu_reg_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{
	return printf_usage();
}
Exemplo n.º 5
0
int main(int argc, char** argv)
{
#ifdef COMPACT_FILENAME_BUFFER
	const char *inFile = NULL, *outFile = NULL;
#else
	char inFile[80]={0}, outFile[80]={0};
#endif
	int fh, size;
	struct stat status;
	char *buf;
	IMG_HEADER_Tp pHeader;
	unsigned int startAddr;
	unsigned int burnAddr;
	unsigned short checksum=0;
	int is_vmlinux = 0;
	int is_vmlinuxhdr = 0;
    int is_signature = 0;
	unsigned int lchecksum, padding_len=0;
	unsigned int start_addr=0;		

	if (argc == 4 && !strcmp(argv[1], "size_chk")) {
		unsigned int total_size;

#ifdef COMPACT_FILENAME_BUFFER
		inFile = argv[2];
#else
		sscanf(argv[2], "%s", inFile);
#endif
		sscanf(argv[3], "%x", &startAddr);
		if ( stat(inFile, &status) < 0 ) {
			printf("Can't stat file! [%s]\n", inFile );
			exit(1);
		}
		printf("==============================================\n");
		printf("Summary ==>\n");
		printf("Image loading  addr          :0x%x\n", (int)startAddr);
		printf("Image decompress end addr    :0x%x\n", ((unsigned int)DEFAULT_BASE_ADDR)+(unsigned int)status.st_size);

		total_size = startAddr - ((unsigned int)DEFAULT_BASE_ADDR);

		if (status.st_size > (int)total_size)
		{
			printf("Error!!!! : Kernel image decompress will overwirte load image\n");
			exit(1);
		}
		else
			printf("Available size               :0x%08x\n",
					 (unsigned int)(total_size - status.st_size));

		exit(0);
	}

#ifdef CONFIG_RTL_FLASH_MAPPING_ENABLE
	if (argc == 3 && !strcmp(argv[1], "flash_size_chk")) {
		unsigned int total_size;

#ifdef COMPACT_FILENAME_BUFFER
		inFile = argv[2];
#else
		sscanf(argv[2], "%s", inFile);
#endif
		if ( stat(inFile, &status) < 0 ) {
			printf("Can't stat file! [%s]\n", inFile );
			exit(1);
		}
		printf("==============================================\n");
		printf("Summary ==>\n");
		printf("Image flash start  addr          :0x%x\n", (unsigned int)CODE_IMAGE_OFFSET);
		printf("Image flash end addr             :0x%x\n", (unsigned int)CODE_IMAGE_OFFSET+(unsigned int)status.st_size);

#ifdef CONFIG_RTL_802_1X_CLIENT_SUPPORT
		total_size = ROOT_IMAGE_OFFSET - CODE_IMAGE_OFFSET - CERT_SIZE;	// To reserve CERT_SIZE for 802.1x wlan client mode to store 802.1x certs
#else
		total_size = ROOT_IMAGE_OFFSET - CODE_IMAGE_OFFSET;
#endif

		if (status.st_size > (int)total_size)
		{
			printf("Error!!!! : Kernel image too big will overwirte rootfs image, cur size(%d), available size(%d).\n",(int)status.st_size, total_size);
			exit(1);
		}
		else
			printf("Available size               :0x%08x\n",
					 (unsigned int)(total_size - status.st_size));

		exit(0);
	}
#endif

#ifdef RTK_4K_CHKSUM_FIX
	if (argc == 4 && !strcmp(argv[1], "fix_chksum"))
	{
	    rtk_fix_4k_chk(argv[2],argv[3]);
	    return 0;
	}
#endif

	if (argc == 4 && !strcmp(argv[1], "vmlinux"))
		is_vmlinux = 1;

    if (argc == 5 && !strcmp(argv[1], "vmlinuxhdr")) {
		is_vmlinuxhdr = 1;
		start_addr = extractStartAddr(argv[4]);
	}

	if (!strcmp(argv[1], "signature")) {
		is_signature = 1;
		if (argc != 7) {
		    printf_usage();
		    exit(1);
		}
	}
		
	// parse input arguments
	if ( argc != 6 && !is_vmlinux && !is_vmlinuxhdr && !is_signature) {
	    printf_usage();
		exit(1);
	}



#ifdef COMPACT_FILENAME_BUFFER
	inFile = argv[2];
	outFile = argv[3];
#else
	sscanf(argv[2], "%s", inFile);
	sscanf(argv[3], "%s", outFile);
#endif

	if ((!is_vmlinux) && (!is_vmlinuxhdr)) {
		sscanf(argv[4], "%x", &startAddr);
		sscanf(argv[5], "%x", &burnAddr);
	}
	// check input file and allocate buffer
	if ( stat(inFile, &status) < 0 ) {
		printf("Can't stat file! [%s]\n", inFile );
		exit(1);
	}

	if (is_vmlinuxhdr) {
		size = status.st_size + sizeof(padding_len) + sizeof(lchecksum) + sizeof(start_addr);
		padding_len = 4 - (size%4);	
		size += padding_len;
	}
	else if (!is_vmlinux) {
		size = status.st_size + sizeof(IMG_HEADER_T) + sizeof(checksum);
		if (size%2)
			size++; // pad
	}
	else {
		size = status.st_size + sizeof(padding_len) + sizeof(lchecksum);
		padding_len = 4 - (size%4);	
		size += padding_len;
	}

	buf = malloc(size);
	if (buf == NULL) {
		printf("Malloc buffer failed!\n");
		exit(1);
	}
	memset(buf, '\0', size);
	pHeader = (IMG_HEADER_Tp)buf;

    if (is_vmlinuxhdr)
        buf += 8; // skip padding-length field and start-address field
	else if (!is_vmlinux)
		buf += sizeof(IMG_HEADER_T);
	else
		buf += 4; // skip padding-length field

	// Read data and generate header
	fh = open(inFile, O_RDONLY);
	if ( fh == -1 ) {
		printf("Open input file error!\n");
		free( pHeader );
		exit(1);
	}
	lseek(fh, 0L, SEEK_SET);
	if ( read(fh, buf, status.st_size) != status.st_size) {
		printf("Read file error!\n");
		close(fh);
		free(pHeader);
		exit(1);
	}
	close(fh);

	if (is_vmlinuxhdr) {
		*((unsigned int *)pHeader) = DWORD_SWAP(padding_len);
		*((unsigned int *)((char *)pHeader+4)) = start_addr;
		lchecksum = DWORD_SWAP(calculate_long_checksum((unsigned int *)buf, size-12));
		memcpy(&buf[size-12], &lchecksum, 4);		
	}
	else if (!is_vmlinux) {
		if( !strcmp("root", argv[1]))
			memcpy(pHeader->signature, ROOT_HEADER, SIGNATURE_LEN);
		else if ( !strcmp("boot", argv[1]))
			memcpy(pHeader->signature, BOOT_HEADER, SIGNATURE_LEN);
		else if ( !strcmp("linux", argv[1]))
			memcpy(pHeader->signature, FW_HEADER, SIGNATURE_LEN);
		else if ( !strcmp("linux-ro", argv[1]))
			memcpy(pHeader->signature, FW_HEADER_WITH_ROOT, SIGNATURE_LEN);
		else if ( !strcmp("signature", argv[1]))
			memcpy(pHeader->signature, argv[6], SIGNATURE_LEN);
		else{
			printf("not supported signature\n");
			exit(1);
		}
		pHeader->len = DWORD_SWAP((size-sizeof(IMG_HEADER_T)));
		pHeader->startAddr = DWORD_SWAP(startAddr);
		pHeader->burnAddr = DWORD_SWAP(burnAddr);

		if( !strcmp("root", argv[1])) {
			#define SIZE_OF_SQFS_SUPER_BLOCK 640		
			unsigned int fs_len;
			fs_len = DWORD_SWAP((size-sizeof(IMG_HEADER_T) - sizeof(checksum)- SIZE_OF_SQFS_SUPER_BLOCK));
			memcpy(buf + 8, &fs_len, 4);	
		}		
		
		checksum = WORD_SWAP(calculateChecksum(buf, status.st_size));
		*((unsigned short *)&buf[size-sizeof(IMG_HEADER_T)-sizeof(checksum)]) = checksum;
	}
	else { // is_vmlinux=1
		*((unsigned int *)pHeader) = DWORD_SWAP(padding_len);
		lchecksum = DWORD_SWAP(calculate_long_checksum((unsigned int *)buf, size-8));
		memcpy(&buf[size-8], &lchecksum, 4);		
	}
	
	// Write image to output file
	fh = open(outFile, O_RDWR|O_CREAT|O_TRUNC,S_IRWXU); //mark_88
	if ( fh == -1 ) {
		printf("Create output file error! [%s]\n", outFile);
		free(pHeader);
		exit(1);
	}
	write(fh, pHeader, size);
	close(fh);
	chmod(outFile, DEFFILEMODE);
	
	if (is_vmlinuxhdr)
	    printf("Generate image successfully, length=%d, checksum=0x%x, padding=%d, start address=0x%08x\n", size-12-padding_len, lchecksum, padding_len, DWORD_SWAP(start_addr));
	else if (!is_vmlinux)
		printf("Generate image successfully, length=%d, checksum=0x%x\n", (int)DWORD_SWAP(pHeader->len), checksum);
	else
		printf("Generate image successfully, length=%d, checksum=0x%x, padding=%d\n", size-8-padding_len, lchecksum, padding_len);

	free(pHeader);
	return 0;
}