]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/AmigaOneG3SE/cmd_boota.c
3 #include "../disk/part_amiga.h"
6 DECLARE_GLOBAL_DATA_PTR
;
11 #define PRINTF(fmt,args...) printf (fmt ,##args)
13 #define PRINTF(fmt,args...)
22 extern block_dev_desc_t
*ide_get_dev (int dev
);
23 extern struct bootcode_block
*get_bootcode (block_dev_desc_t
* dev_desc
);
24 extern int sum_block (struct block_header
*header
);
26 struct bootcode_block bblk
;
28 int do_boota (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
30 unsigned char *load_address
= (unsigned char *) CFG_LOAD_ADDR
;
31 unsigned char *base_address
;
34 unsigned long part_number
= 0;
35 block_dev_desc_t
*boot_disk
;
37 struct bootcode_block
*boot_code
;
43 load_address
= (unsigned char *) simple_strtol (argv
[1], NULL
, 16);
47 load_address
= (unsigned char *) simple_strtol (argv
[1], NULL
, 16);
48 part_number
= simple_strtol (argv
[2], NULL
, 16);
52 base_address
= load_address
;
54 PRINTF ("Loading boot code from disk %d to %p\n", part_number
,
57 /* Find the appropriate disk device */
58 boot_disk
= ide_get_dev (part_number
);
60 PRINTF ("Unknown disk %d\n", part_number
);
64 /* Find the bootcode block */
65 boot_code
= get_bootcode (boot_disk
);
67 PRINTF ("Not a bootable disk %d\n", part_number
);
71 /* Only use the offset from the first block */
72 offset
= boot_code
->load_data
[0];
73 memcpy (load_address
, &boot_code
->load_data
[1], 122 * 4);
74 load_address
+= 122 * 4;
76 /* Setup for the loop */
77 bblk
.next
= boot_code
->next
;
80 /* Scan the chain, and copy the loader succesively into the destination area */
81 while (0xffffffff != boot_code
->next
) {
82 PRINTF ("Loading block %d\n", boot_code
->next
);
86 boot_disk
->block_read (boot_disk
->dev
, boot_code
->next
, 1,
88 PRINTF ("Read error\n");
93 if (sum_block ((struct block_header
*) (ulong
*) & bblk
) != 0) {
94 PRINTF ("Checksum error\n");
98 /* Ok, concatenate it to the already loaded code */
99 memcpy (load_address
, boot_code
->load_data
, 123 * 4);
100 load_address
+= 123 * 4;
103 printf ("Bootcode loaded to %p (size %d)\n", base_address
,
104 load_address
- base_address
);
105 printf ("Entry point at %p\n", base_address
+ offset
);
107 flush_cache (base_address
, load_address
- base_address
);
110 s
= getenv ("autostart");
111 if (s
&& strcmp (s
, "yes") == 0) {
112 void (*boot
) (bd_t
*, char *, block_dev_desc_t
*);
115 boot
= (void (*)(bd_t
*, char *, block_dev_desc_t
*)) (base_address
+ offset
);
116 boot (gd
->bd
, getenv ("amiga_bootargs"), boot_disk
);
122 #if defined(CONFIG_AMIGAONEG3SE) && (CONFIG_COMMANDS & CFG_CMD_BSP)
124 boota
, 3, 1, do_boota
,
125 "boota - boot an Amiga kernel\n",
128 #endif /* _CMD_BOOTA_H */