Rev 1203 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1200 | giacomo | 1 | #include <kernel/kern.h> |
2 | #include <stdlib.h> |
||
3 | #include "parser.h" |
||
4 | |||
5 | int dos_preload(char *file_name, long max_size, void **start, void **end) |
||
6 | { |
||
7 | DOS_FILE* file; |
||
8 | void *buf; |
||
9 | long rd; |
||
10 | |||
11 | |||
12 | file = DOS_fopen(file_name,"r"); |
||
13 | if (file == NULL) return -1; |
||
14 | |||
15 | buf = malloc(max_size); |
||
16 | *start = buf; |
||
17 | |||
18 | while(((rd = DOS_fread(buf, sizeof(BYTE), 2048, file)) == 2048) && |
||
19 | ((buf - *start + rd) < (max_size-2048))) { |
||
20 | buf += rd; |
||
21 | } |
||
22 | |||
23 | *end = buf + rd; |
||
24 | |||
25 | DOS_fclose(file); |
||
26 | return(0); |
||
27 | |||
28 | } |
||
29 | |||
1201 | giacomo | 30 | int line_reader(void *start, void *end, struct timespec *total, struct loader_task **start_loader_task) |
1200 | giacomo | 31 | { |
32 | |||
33 | char *pbuf = start; |
||
1206 | giacomo | 34 | int res,line_num,total_loader_task; |
1201 | giacomo | 35 | struct loader_task *current = NULL; |
1200 | giacomo | 36 | |
37 | NULL_TIMESPEC(total); |
||
38 | |||
39 | line_num = 0; |
||
40 | total_loader_task = 0; |
||
41 | while ((void *)(pbuf) < end) { |
||
1206 | giacomo | 42 | |
1200 | giacomo | 43 | line_num++; |
1203 | giacomo | 44 | |
45 | if (*start_loader_task == NULL) |
||
1206 | giacomo | 46 | res = line_parser(&pbuf, line_num, total, ¤t); |
1203 | giacomo | 47 | else |
1206 | giacomo | 48 | res = line_parser(&pbuf, line_num, total, ¤t->next); |
1203 | giacomo | 49 | |
1200 | giacomo | 50 | if (res == 2) { |
51 | total_loader_task++; |
||
1203 | giacomo | 52 | if (*start_loader_task == NULL) |
53 | *start_loader_task = current; |
||
54 | else |
||
55 | current = current->next; |
||
1200 | giacomo | 56 | } |
1206 | giacomo | 57 | |
58 | if (res == 3) break; |
||
59 | |||
1200 | giacomo | 60 | } |
61 | |||
62 | cprintf("Total decoded lines %d\n",line_num); |
||
63 | cprintf("Total loader task %d\n",total_loader_task); |
||
64 | cprintf("Simulation time sec = %ld usec = %ld\n",total->tv_sec,total->tv_nsec/1000); |
||
65 | |||
66 | return 0; |
||
67 | |||
68 | } |