Rev 1206 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <kernel/kern.h>
#include <stdlib.h>
#include "parser.h"
int dos_preload
(char *file_name
, long max_size
, void **start_file
, void **end_file
)
{
DOS_FILE
* file
;
void *buf
;
long rd
;
file
= DOS_fopen
(file_name
,"r");
if (file
== NULL
) return -1;
buf
= malloc(max_size
);
*start_file
= buf
;
while(((rd
= DOS_fread
(buf
, sizeof(BYTE
), 2048, file
)) == 2048) &&
((buf
- *start_file
+ rd
) < (max_size
-2048))) {
buf
+= rd
;
}
*end_file
= buf
+ rd
;
DOS_fclose
(file
);
return(0);
}
int line_reader
(void *start_file
, void *end_file
, struct timespec
*total
, struct loader_task
**start_loader_task
)
{
char *pbuf
= start_file
;
int res
,line_num
,total_loader_task
;
struct loader_task
*current
= NULL
;
NULL_TIMESPEC
(total
);
line_num
= 0;
total_loader_task
= 0;
while ((void *)(pbuf
) < end_file
) {
line_num
++;
if (*start_loader_task
== NULL
)
res
= line_parser
(&pbuf
, line_num
, total
, ¤t
);
else
res
= line_parser
(&pbuf
, line_num
, total
, ¤t
->next
);
if (res
== 2) {
total_loader_task
++;
if (*start_loader_task
== NULL
)
*start_loader_task
= current
;
else
current
= current
->next
;
}
if (res
== 3) break;
}
cprintf
("Total decoded lines %d\n",line_num
);
cprintf
("Total loader task %d\n",total_loader_task
);
cprintf
("Simulation time sec = %ld usec = %ld\n",total
->tv_sec
,total
->tv_nsec
/1000);
return 0;
}