Rev 4011 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4011 | Rev 4012 | ||
---|---|---|---|
Line 37... | Line 37... | ||
37 | #include <arch/boot/cboot.h> |
37 | #include <arch/boot/cboot.h> |
38 | #include <arch/boot/memmap.h> |
38 | #include <arch/boot/memmap.h> |
39 | #include <config.h> |
39 | #include <config.h> |
40 | #include <memstr.h> |
40 | #include <memstr.h> |
41 | #include <string.h> |
41 | #include <string.h> |
- | 42 | #include <macros.h> |
|
42 | 43 | ||
43 | /* This is a symbol so the type is only dummy. Obtain the value using &. */ |
44 | /* This is a symbol so the type is only dummy. Obtain the value using &. */ |
44 | extern int _hardcoded_unmapped_size; |
45 | extern int _hardcoded_unmapped_size; |
45 | 46 | ||
- | 47 | /** Extract command name from the multiboot module command line. |
|
- | 48 | * |
|
- | 49 | * @param buf Destination buffer (will always null-terminate). |
|
- | 50 | * @param n Size of destination buffer. |
|
- | 51 | * @param cmd_line Input string (the command line). |
|
- | 52 | */ |
|
- | 53 | static void extract_command(char *buf, size_t n, const char *cmd_line) |
|
- | 54 | { |
|
- | 55 | const char *start, *end, *cp; |
|
- | 56 | size_t max_len; |
|
- | 57 | ||
- | 58 | /* Find the first space. */ |
|
- | 59 | end = strchr(cmd_line, ' '); |
|
- | 60 | if (end == NULL) end = cmd_line + strlen(cmd_line); |
|
- | 61 | ||
- | 62 | /* |
|
- | 63 | * Find last occurence of '/' before 'end'. If found, place start at |
|
- | 64 | * next character. Otherwise, place start at beginning of buffer. |
|
- | 65 | */ |
|
- | 66 | cp = end; |
|
- | 67 | start = buf; |
|
- | 68 | while (cp != start) { |
|
- | 69 | if (*cp == '/') { |
|
- | 70 | start = cp + 1; |
|
- | 71 | break; |
|
- | 72 | } |
|
- | 73 | --cp; |
|
- | 74 | } |
|
- | 75 | ||
- | 76 | /* Copy the command and null-terminate the string. */ |
|
- | 77 | max_len = min(n - 1, (size_t) (end - start)); |
|
- | 78 | strncpy(buf, start, max_len + 1); |
|
- | 79 | buf[max_len] = '\0'; |
|
- | 80 | } |
|
- | 81 | ||
46 | /** C part of ia32 boot sequence. |
82 | /** C part of ia32 boot sequence. |
47 | * @param signature Should contain the multiboot signature. |
83 | * @param signature Should contain the multiboot signature. |
48 | * @param mi Pointer to the multiboot information structure. |
84 | * @param mi Pointer to the multiboot information structure. |
49 | */ |
85 | */ |
50 | void ia32_cboot(uint32_t signature, const mb_info_t *mi) |
86 | void ia32_cboot(uint32_t signature, const mb_info_t *mi) |
Line 70... | Line 106... | ||
70 | init.tasks[i].addr = mods[i].start + 0x80000000; |
106 | init.tasks[i].addr = mods[i].start + 0x80000000; |
71 | init.tasks[i].size = mods[i].end - mods[i].start; |
107 | init.tasks[i].size = mods[i].end - mods[i].start; |
72 | 108 | ||
73 | /* Copy command line, if available. */ |
109 | /* Copy command line, if available. */ |
74 | if (mods[i].string) { |
110 | if (mods[i].string) { |
75 | strncpy(init.tasks[i].name, mods[i].string, |
111 | extract_command(init.tasks[i].name, |
76 | CONFIG_TASK_NAME_BUFLEN - 1); |
112 | CONFIG_TASK_NAME_BUFLEN, |
77 | init.tasks[i].name[CONFIG_TASK_NAME_BUFLEN - 1] |
- | |
78 | = '\0'; |
113 | mods[i].string); |
79 | } else { |
114 | } else { |
80 | init.tasks[i].name[0] = '\0'; |
115 | init.tasks[i].name[0] = '\0'; |
81 | } |
116 | } |
82 | } |
117 | } |
83 | } else { |
118 | } else { |