Skip to content

Commit

Permalink
ramdisk loading fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrs committed Oct 16, 2012
1 parent 235e2b1 commit 9c25864
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion atag.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ int atag_build() {
ATAG(ATAG_MEM, settings.phys.size, settings.phys.start);
if (strlen(settings.kernel_cmdline))
ATAG(ATAG_CMDLINE, settings.kernel_cmdline);
if (settings.ramdisk_loaded)
if (settings.ramdisk_loaded) {
ATAG(ATAG_RAMDISK, 0, settings.kernel_ramdisk_size, 0);
ATAG(ATAG_INITRD2, settings.ramdisk.addr, settings.ramdisk.size);
}
/*
End list. Stop here
*/
Expand Down
1 change: 1 addition & 0 deletions cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ int process_cmd(char * cmd) {
DEFINE_COMMAND(free, show_mem);
DEFINE_COMMAND(mach, setget_mach);
DEFINE_COMMAND(phys, setget_phys);
DEFINE_COMMAND(rdsize, setget_rdisksize);
DEFINE_COMMAND(cmdline, kernel_cmdline);
DEFINE_COMMAND(boot, kernel_boot);
/*
Expand Down
10 changes: 10 additions & 0 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <os.h>
#include "macros.h"
#include "common.h"

Expand Down Expand Up @@ -51,6 +52,14 @@ void setget_phys(char * arg) {
printl("Physical memory range is 0x%p-0x%p\n", settings.phys.start, (void*)((char*)settings.phys.start + settings.phys.size));
}

void setget_rdisksize(char * arg) {
unsigned num;
if ( (num = strtol(arg, NULL, 16)) ) {
settings.kernel_ramdisk_size = num;
}
printl("Kernel RAMDISK size set to %uK\n", settings.kernel_ramdisk_size);
}


void dump_settings(char * ignored __attribute__((unused))) {
HEADER_LEVEL0(kernel);
Expand Down Expand Up @@ -80,6 +89,7 @@ void dump_settings(char * ignored __attribute__((unused))) {
FOOTER_LEVEL0();

DUMP_LEVEL0(settings, machine_id);
DUMP_LEVEL0(settings, kernel_ramdisk_size);
DUMP_LEVEL0(settings, ramdisk_loaded);
DUMP_LEVEL0(settings, kernel_loaded);

Expand Down
2 changes: 2 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct params {
int machine_id;

unsigned serialnr[2];
unsigned kernel_ramdisk_size;

unsigned ramdisk_loaded:1;
unsigned kernel_loaded:1;
Expand All @@ -64,5 +65,6 @@ extern struct params settings;
void dump_settings(char*);
void setget_mach(char * arg);
void setget_phys(char * arg);
void setget_rdisksize(char * arg);

#endif
4 changes: 3 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include "cmd.h"
#include "mach.h"

struct params settings;
struct params settings = {
.kernel_ramdisk_size = DEFAULT_RAMDISK_SIZE
};

int main() {
nio_console csl;
Expand Down
2 changes: 2 additions & 0 deletions memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "common.h"

#define MAX_ATAG_SIZE (0x8000-0x100)
#define DEFAULT_RAMDISK_SIZE 0x2000

#define mem_block_size_free() (settings.mem_block.size - settings.kernel.size - settings.ramdisk.size)


Expand Down

0 comments on commit 9c25864

Please sign in to comment.