Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2948 → Rev 2949

/branches/dynload/tools/bin2c.py
0,0 → 1,64
#!/usr/bin/python
#
# Copyright (c) 2008 Jiri Svoboda
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
"""
Inline binary file into a C module
"""
import sys
import os
 
INPUT = sys.argv[1]
f = open(INPUT)
line_length = 8
file_size = os.path.getsize(INPUT)
 
print """#include <sys/types.h>'
 
const size_t data_size = %d;
const char data_filename[] = "/test";
const uint8_t data[] = {""" % file_size
 
first_line = True
 
while True:
data = f.read(line_length)
if data == '': break
 
if first_line:
first_line = False
else:
sys.stdout.write(",\n")
 
fields = []
for i in range(len(data)):
field = "0x%02x" % ord(data[i])
fields.append(field)
 
print "\t", ", ".join(fields),
 
print "\n};"
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/branches/dynload/uspace/app/iloader/elf.c
45,6 → 45,7
#include "elf.h"
 
#define RTLD_BIAS 0x80000
//#define RTLD_BIAS 0
 
static char *error_codes[] = {
"no error",
229,7 → 230,8
flags |= AS_AREA_CACHEABLE;
*/
/* FIXME: Kernel won't normally allow this, unless you "patch" it */
flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_EXEC | AS_AREA_CACHEABLE;
// flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_EXEC | AS_AREA_CACHEABLE;
flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE;
 
/*
* Check if the virtual address starts on page boundary.
251,17 → 253,36
return EE_MEMORY;
}
 
printf("as_area_create() -> 0x%x\n", (unsigned)a);
printf("as_area_create(0x%x, 0x%x, %d) -> 0x%x\n",
entry->p_vaddr+bias, entry->p_memsz, flags, (unsigned)a);
 
/*
* Load segment data
*/
printf("seek to %d\n", entry->p_offset);
rc = lseek(fd, entry->p_offset, SEEK_SET);
if (rc < 0) { printf("seek error\n"); return EE_INVALID; }
 
rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
if (rc < 0) { printf("read error\n"); return EE_INVALID; }
printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
/* rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
if (rc < 0) { printf("read error\n"); return EE_INVALID; }*/
unsigned left, now;
uint8_t *dp;
 
left = entry->p_filesz;
dp = (uint8_t *)(entry->p_vaddr + bias);
 
while (left > 0) {
now = 4096;
if (now > left) now=left;
printf("read %d...", now);
rc = read(fd, dp, now);
if (rc < 0) { printf("read error\n"); return EE_INVALID; }
printf("->%d\n", rc);
left -= now;
dp += now;
}
 
return EE_OK;
}
 
/branches/dynload/uspace/app/iloader/Makefile
67,7 → 67,7
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm arch/$(ARCH)/_link.ld Makefile.depend
-rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm arch/$(ARCH)/_link.ld Makefile.depend
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
/branches/dynload/uspace/app/iramfs/data.h
0,0 → 1,47
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup sctrace
* @{
*/
/** @file
*/
 
#ifndef DATA_H_
#define DATA_H_
 
#include <sys/types.h>
 
extern const uint8_t data[];
extern const size_t data_size;
extern const char data_filename[];
 
#endif
 
/** @}
*/
/branches/dynload/uspace/app/iramfs/main.c
0,0 → 1,87
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup iramfs
* @brief Loads inlined data onto tmpfs.
* @{
*/
/**
* @file
*/
 
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <vfs/vfs.h>
#include <sys/types.h>
#include "data.h"
 
#define min(a,b) ((a)>(b) ? (b) : (a))
int main(int argc, char *argv[])
{
int fd;
int cnt;
int rc;
int nbytes;
uint8_t *dp;
int written;
 
printf("This is iramfs\n");
do {
rc = mount("tmpfs", "/", "nulldev0");
printf("mount tmpfs on / -> %d\n", rc);
if (rc == 0) break;
 
usleep(1000 * 1000);
} while (1);
 
fd = open(data_filename, O_CREAT);
if (fd < 0) { printf("open failed\n"); return 1; }
 
printf("write %d bytes...\n", data_size);
nbytes = data_size; dp = data; written = 0;
while (nbytes > 0) {
cnt = write(fd, dp, min(4096, nbytes));
if (cnt < 0) { printf("write failed\n"); return 1; }
dp += cnt;
written += cnt;
nbytes -= cnt;
printf("written: %d, cnt: %d, left: %d\n", written, cnt, nbytes);
}
 
printf("\n\nwritten %d bytes\n", written);
close(fd);
 
printf("done\n");
getchar();
return 0;
}
 
/** @}
*/
/branches/dynload/uspace/app/iramfs/Makefile
0,0 → 1,91
#
# Copyright (c) 2005 Martin Decky
# Copyright (c) 2008 Jiri Svoboda
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# - The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
 
include ../../../version
include ../../Makefile.config
 
## Setup toolchain
#
 
LIBC_PREFIX = ../../lib/libc
SOFTINT_PREFIX = ../../lib/softint
include $(LIBC_PREFIX)/Makefile.toolchain
 
CFLAGS += -I../../srv/kbd/include -D__32_BITS__
 
LIBS = $(LIBC_PREFIX)/libc.a
DEFS += -DRELEASE=\"$(RELEASE)\"
 
ifdef REVISION
DEFS += "-DREVISION=\"$(REVISION)\""
endif
 
ifdef TIMESTAMP
DEFS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
endif
 
## Sources
#
 
OUTPUT = iramfs
SOURCES = \
main.c \
data.c
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
.PHONY: all clean depend disasm
 
all: $(OUTPUT) disasm
 
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) $(OBJECTS) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend data.c
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
 
$(OUTPUT): $(OBJECTS) $(LIBS)
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
 
disasm:
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm
 
%.o: %.S
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
 
%.o: %.s
$(AS) $(AFLAGS) $< -o $@
 
%.o: %.c
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
 
data.c: ../tetris/tetris
../../../tools/bin2c.py $< >$@
/branches/dynload/uspace/Makefile
48,6 → 48,7
srv/devmap \
app/tetris \
app/tester \
app/iramfs \
app/iloader \
app/klog \
app/init
/branches/dynload/boot/arch/ia32/grub/menu.lst
12,8 → 12,10
module /boot/console
module /boot/vfs
module /boot/tmpfs
module /boot/fat
# module /boot/fat
module /boot/devmap
module /boot/tetris
module /boot/tester
# module /boot/tetris
# module /boot/tester
module /boot/iramfs
module /boot/iloader
module /boot/klog
/branches/dynload/boot/arch/ia32/Makefile.inc
39,6 → 39,8
$(USPACEDIR)/app/init/init \
$(USPACEDIR)/app/tetris/tetris \
$(USPACEDIR)/app/tester/tester \
$(USPACEDIR)/app/iramfs/iramfs \
$(USPACEDIR)/app/iloader/iloader \
$(USPACEDIR)/app/klog/klog
 
build: $(BASE)/image.iso