2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
5 Desc: I/O routines for bootstrap ELF loader
15 #include "bootstrap.h"
17 #include "filesystem.h"
22 char FullName
[1]; /* We need to store the full pathname */
25 struct ELFNode
*FirstELF
= NULL
;
26 static struct ELFNode
*LastELF
= (struct ELFNode
*)&FirstELF
;
28 int AddKernelFile(char *name
)
32 int len
= sizeof(struct ExtELFNode
) + strlen(name
);
36 l1
= strlen(bootstrapdir
);
47 memcpy(n
->FullName
, bootstrapdir
, l1
);
48 strcpy(n
->FullName
+ l1
, name
);
49 n
->node
.Name
= namepart(n
->FullName
);
51 LastELF
->Next
= &n
->node
;
57 void FreeKernelList(void)
59 struct ELFNode
*n
, *n2
;
61 for (n
= FirstELF
; n
; n
= n2
)
68 void *open_file(struct ELFNode
*n
, unsigned int *err
)
72 f
= fopen(((struct ExtELFNode
*)n
)->FullName
, "rb");
73 *err
= f
? 0 : GetLastError();
78 void close_file(void *file
)
84 * read_block interface. we want to read from files here
86 int read_block(void *file
, unsigned long offset
, void *dest
, unsigned long length
)
90 err
= fseek(file
, offset
, SEEK_SET
);
92 return GetLastError();
94 err
= fread(dest
, length
, 1, file
);
96 return GetLastError();
102 * load_block also allocates the memory
104 void *load_block(void *file
, unsigned long offset
, unsigned long length
, unsigned int *err
)
106 void *dest
= malloc(length
);
110 *err
= read_block(file
, offset
, dest
, length
);
119 *err
= GetLastError();
124 void free_block(void *addr
)