]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/AmigaOneG3SE/cmd_boota.c
3 #include "../disk/part_amiga.h"
10 #define PRINTF(fmt,args...) printf (fmt ,##args)
12 #define PRINTF(fmt,args...)
21 extern block_dev_desc_t
*ide_get_dev (int dev
);
22 extern struct bootcode_block
*get_bootcode (block_dev_desc_t
* dev_desc
);
23 extern int sum_block (struct block_header
*header
);
25 struct bootcode_block bblk
;
27 int do_boota (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
29 unsigned char *load_address
= (unsigned char *) CFG_LOAD_ADDR
;
30 unsigned char *base_address
;
33 unsigned long part_number
= 0;
34 block_dev_desc_t
*boot_disk
;
36 struct bootcode_block
*boot_code
;
42 load_address
= (unsigned char *) simple_strtol (argv
[1], NULL
, 16);
46 load_address
= (unsigned char *) simple_strtol (argv
[1], NULL
, 16);
47 part_number
= simple_strtol (argv
[2], NULL
, 16);
51 base_address
= load_address
;
53 PRINTF ("Loading boot code from disk %d to %p\n", part_number
,
56 /* Find the appropriate disk device */
57 boot_disk
= ide_get_dev (part_number
);
59 PRINTF ("Unknown disk %d\n", part_number
);
63 /* Find the bootcode block */
64 boot_code
= get_bootcode (boot_disk
);
66 PRINTF ("Not a bootable disk %d\n", part_number
);
70 /* Only use the offset from the first block */
71 offset
= boot_code
->load_data
[0];
72 memcpy (load_address
, &boot_code
->load_data
[1], 122 * 4);
73 load_address
+= 122 * 4;
75 /* Setup for the loop */
76 bblk
.next
= boot_code
->next
;
79 /* Scan the chain, and copy the loader succesively into the destination area */
80 while (0xffffffff != boot_code
->next
) {
81 PRINTF ("Loading block %d\n", boot_code
->next
);
85 boot_disk
->block_read (boot_disk
->dev
, boot_code
->next
, 1,
87 PRINTF ("Read error\n");
92 if (sum_block ((struct block_header
*) (ulong
*) & bblk
) != 0) {
93 PRINTF ("Checksum error\n");
97 /* Ok, concatenate it to the already loaded code */
98 memcpy (load_address
, boot_code
->load_data
, 123 * 4);
99 load_address
+= 123 * 4;
102 printf ("Bootcode loaded to %p (size %d)\n", base_address
,
103 load_address
- base_address
);
104 printf ("Entry point at %p\n", base_address
+ offset
);
106 flush_cache (base_address
, load_address
- base_address
);
109 s
= getenv ("autostart");
110 if (s
&& strcmp (s
, "yes") == 0) {
111 DECLARE_GLOBAL_DATA_PTR
;
113 void (*boot
) (bd_t
*, char *, block_dev_desc_t
*);
116 boot
= (void (*)(bd_t
*, char *, block_dev_desc_t
*)) (base_address
+ offset
);
117 boot (gd
->bd
, getenv ("amiga_bootargs"), boot_disk
);
123 #if defined(CONFIG_AMIGAONEG3SE) && (CONFIG_COMMANDS & CFG_CMD_BSP)
124 cmd_tbl_t
U_BOOT_CMD(BOOTA
) = MK_CMD_ENTRY(
125 "boota", 3, 1, do_boota
,
126 "boota - boot an Amiga kernel\n",
129 #endif /* _CMD_BOOTA_H */