⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 download.c

📁 Hermit-at-1.1.3,一款bootloader
💻 C
字号:
/* * Copyright (c) 2000 Blue Mug, Inc.  All Rights Reserved. */#include <stddef.h>#include <target/buffer.h>#include <target/crc.h>#include <target/herrno.h>#include <target/htypes.h>#include <target/io.h>#include <target/scan.h>#include <target/xfer.h>#include <target/str.h>/* * The download command can be used in two ways: it can download * directly to RAM, or it can download to a buffer in the loader, * which can later be written to flash.  If the <addr> argument of the * download command is 'buf', the buffer is chosen. */static int download_cmdfunc(int argc, char *argv[]){	unsigned char *dst;	addr_t addr;	size_t count, hostcrc, nread;	/* crc is optional */	if (argc < 3 || argc > 4)		return -H_EUSAGE;	/* special case download to buffer */	++argv;	if (!strcmp(*argv, "buf"))		dst = dlbuf;	else if (scan(*argv, &addr))		return -H_EADDR;	else		dst = (unsigned char*) addr;	/* buffer download is the only case which allows a size check */	if (scan(*++argv, &count))		return -H_EADDR;	if (dst == dlbuf && count > dlbufsize)		return -H_EOVERFLOW;	if (argc == 4)		if (scan(*++argv, &hostcrc))			return -H_EINVAL;	/* read block to destination */	hprintf("+GO\n");	nread = hgetblock(dst, count);	if (nread > count)		return -H_EOVERFLOW;	if (nread < count)		return -H_EUNDERFLOW;	if (argc == 4) {		uint32_t crc = crc32(dst, count);		if (crc != (uint32_t) hostcrc)			return -H_ECRC;	}	return 0;}const command_t download_command =	{ "download", "<addr> <count> [<crc>]",	  "download data to memory", &download_cmdfunc };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -