* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "qemu-common.h"
while (nbytes) {
want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;
did = fread(buf, 1, want, f);
- if (did != want) break;
cpu_physical_memory_write_rom(dst_addr, buf, did);
dst_addr += did;
nbytes -= did;
+ if (did != want)
+ break;
}
return dst_addr - dst_begin;
}
(N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
(N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? TARGET_PAGE_SIZE : 0)
-#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
#define _N_SEGMENT_ROUND(x) (((x) + TARGET_PAGE_SIZE - 1) & ~(TARGET_PAGE_SIZE - 1))
#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
if (lseek(fd, offset, SEEK_SET) < 0)
return NULL;
ptr = qemu_malloc(size);
- if (!ptr)
- return NULL;
if (read(fd, ptr, size) != size) {
qemu_free(ptr);
return NULL;
}
/* Load a U-Boot image. */
-int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
- int *is_linux)
+int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+ int *is_linux)
{
int fd;
int size;
if (hdr->ih_magic != IH_MAGIC)
goto out;
- /* TODO: Implement Multi-File images. */
- if (hdr->ih_type == IH_TYPE_MULTI) {
- fprintf(stderr, "Unable to load multi-file u-boot images\n");
+ /* TODO: Implement other image types. */
+ if (hdr->ih_type != IH_TYPE_KERNEL) {
+ fprintf(stderr, "Can only load u-boot image type \"kernel\"\n");
goto out;
}
/* TODO: Check CPU type. */
if (is_linux) {
- if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
+ if (hdr->ih_os == IH_OS_LINUX)
*is_linux = 1;
else
*is_linux = 0;
*ep = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
- if (!data)
- goto out;
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");