Subversion Repositories HelenOS

Rev

Rev 4012 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4012 Rev 4014
Line 44... Line 44...
44
/* 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 &. */
45
extern int _hardcoded_unmapped_size;
45
extern int _hardcoded_unmapped_size;
46
 
46
 
47
/** Extract command name from the multiboot module command line.
47
/** Extract command name from the multiboot module command line.
48
 *
48
 *
49
 * @param buf       Destination buffer (will always null-terminate).
49
 * @param buf      Destination buffer (will always null-terminate).
50
 * @param n     Size of destination buffer.
50
 * @param n        Size of destination buffer.
51
 * @param cmd_line  Input string (the command line).           
51
 * @param cmd_line Input string (the command line).
-
 
52
 *
52
 */
53
 */
53
static void extract_command(char *buf, size_t n, const char *cmd_line)
54
static void extract_command(char *buf, size_t n, const char *cmd_line)
54
{
55
{
55
    const char *start, *end, *cp;
56
    const char *start, *end, *cp;
56
    size_t max_len;
57
    size_t max_len;
57
 
58
   
58
    /* Find the first space. */
59
    /* Find the first space. */
59
    end = strchr(cmd_line, ' ');
60
    end = strchr(cmd_line, ' ');
-
 
61
    if (end == NULL)
60
    if (end == NULL) end = cmd_line + strlen(cmd_line);
62
        end = cmd_line + strlen(cmd_line);
61
 
63
   
62
    /*
64
    /*
63
     * Find last occurence of '/' before 'end'. If found, place start at
65
     * Find last occurence of '/' before 'end'. If found, place start at
64
     * next character. Otherwise, place start at beginning of buffer.
66
     * next character. Otherwise, place start at beginning of buffer.
65
     */
67
     */
66
    cp = end;
68
    cp = end;
Line 70... Line 72...
70
            start = cp + 1;
72
            start = cp + 1;
71
            break;
73
            break;
72
        }
74
        }
73
        --cp;
75
        --cp;
74
    }
76
    }
75
 
77
   
76
    /* Copy the command and null-terminate the string. */
78
    /* Copy the command and null-terminate the string. */
77
    max_len = min(n - 1, (size_t) (end - start));
79
    max_len = min(n - 1, (size_t) (end - start));
78
    strncpy(buf, start, max_len + 1);
80
    strncpy(buf, start, max_len + 1);
79
    buf[max_len] = '\0';
81
    buf[max_len] = '\0';
80
}
82
}
81
 
83
 
82
/** C part of ia32 boot sequence.
84
/** C part of ia32 boot sequence.
-
 
85
 *
83
 * @param signature Should contain the multiboot signature.
86
 * @param signature Should contain the multiboot signature.
84
 * @param mi        Pointer to the multiboot information structure.
87
 * @param mi        Pointer to the multiboot information structure.
85
 */
88
 */
86
void ia32_cboot(uint32_t signature, const mb_info_t *mi)
89
void ia32_cboot(uint32_t signature, const mb_info_t *mi)
87
{
90
{
88
    uint32_t flags;
91
    uint32_t flags;
89
    mb_mod_t *mods;
92
    mb_mod_t *mods;
90
    uint32_t i;
93
    uint32_t i;
91
 
94
   
92
    if (signature == MULTIBOOT_LOADER_MAGIC) {
95
    if (signature == MULTIBOOT_LOADER_MAGIC)
93
        flags = mi->flags;
96
        flags = mi->flags;
94
    } else {
97
    else {
95
        /* No multiboot info available. */
98
        /* No multiboot info available. */
96
        flags = 0;
99
        flags = 0;
97
    }
100
    }
98
 
101
   
99
    /* Copy module information. */
102
    /* Copy module information. */
100
 
103
   
101
    if ((flags & MBINFO_FLAGS_MODS) != 0) {
104
    if ((flags & MBINFO_FLAGS_MODS) != 0) {
102
        init.cnt = mi->mods_count;
105
        init.cnt = mi->mods_count;
103
        mods = mi->mods_addr;
106
        mods = mi->mods_addr;
104
 
107
       
105
        for (i = 0; i < init.cnt; i++) {
108
        for (i = 0; i < init.cnt; i++) {
106
            init.tasks[i].addr = mods[i].start + 0x80000000;
109
            init.tasks[i].addr = mods[i].start + 0x80000000;
107
            init.tasks[i].size = mods[i].end - mods[i].start;
110
            init.tasks[i].size = mods[i].end - mods[i].start;
108
 
111
           
109
            /* Copy command line, if available. */
112
            /* Copy command line, if available. */
110
            if (mods[i].string) {
113
            if (mods[i].string) {
111
                extract_command(init.tasks[i].name,
114
                extract_command(init.tasks[i].name,
112
                    CONFIG_TASK_NAME_BUFLEN,
115
                    CONFIG_TASK_NAME_BUFLEN,
113
                    mods[i].string);
116
                    mods[i].string);
114
            } else {
117
            } else
115
                init.tasks[i].name[0] = '\0';
118
                init.tasks[i].name[0] = '\0';
116
            }
-
 
117
        }
119
        }
118
    } else {
120
    } else
119
        init.cnt = 0;
121
        init.cnt = 0;
120
    }
122
   
121
 
-
 
122
    /* Copy memory map. */
123
    /* Copy memory map. */
123
 
124
   
124
    int32_t mmap_length;
125
    int32_t mmap_length;
125
    mb_mmap_t *mme;
126
    mb_mmap_t *mme;
126
    uint32_t size;
127
    uint32_t size;
127
 
128
   
128
    if ((flags & MBINFO_FLAGS_MMAP) != 0) {
129
    if ((flags & MBINFO_FLAGS_MMAP) != 0) {
129
        mmap_length = mi->mmap_length;
130
        mmap_length = mi->mmap_length;
130
        mme = mi->mmap_addr;
131
        mme = mi->mmap_addr;
131
        e820counter = 0;
132
        e820counter = 0;
132
 
133
       
133
        i = 0;
134
        i = 0;
134
        while (mmap_length > 0) {
135
        while (mmap_length > 0) {
135
            e820table[i++] = mme->mm_info;
136
            e820table[i++] = mme->mm_info;
136
 
137
           
137
            /* Compute address of next structure. */
138
            /* Compute address of next structure. */
138
            size = sizeof(mme->size) + mme->size;
139
            size = sizeof(mme->size) + mme->size;
139
            mme = ((void *) mme) + size;
140
            mme = ((void *) mme) + size;
140
            mmap_length -= size;
141
            mmap_length -= size;
141
        }
142
        }
142
 
143
       
143
        e820counter = i;
144
        e820counter = i;
144
    } else {
145
    } else
145
        e820counter = 0;
146
        e820counter = 0;
146
    }
147
   
147
 
-
 
148
#ifdef CONFIG_SMP
148
#ifdef CONFIG_SMP
149
    /* Copy AP bootstrap routines below 1 MB. */
149
    /* Copy AP bootstrap routines below 1 MB. */
150
    memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
150
    memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
151
        (size_t) &_hardcoded_unmapped_size);
151
        (size_t) &_hardcoded_unmapped_size);
152
#endif
152
#endif
153
 
153
   
154
    main_bsp();
154
    main_bsp();
155
}
155
}
156
 
156
 
157
/** @}
157
/** @}
158
 */
158
 */