forked from tavip/lkl-lua
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it boots the kernel, and runs a simple script
- Loading branch information
Showing
30 changed files
with
4,172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,108 @@ | ||
#uncoment the next 2 lines to get LKL's file APIs. This currently works on linux only | ||
.PHONY=clean | ||
LKL_DEFINES+=-DLKL_FILE_APIS | ||
LKL=lkl/vmlinux | ||
|
||
APR_LIN_CFLAGS=`apr-config --includes --cppflags` | ||
APR_WIN_CFLAGS=-Iapr_win/include/ | ||
|
||
APR_LIN_LIB=-lapr-1 | ||
APR_WIN_LIB=apr_win/Debug/libapr-1.lib | ||
|
||
#LUA_LIN_CFLAGS=`lua-config --include` | ||
#Ubuntu misses lua-config for lua5.1, thus the hardcoded path | ||
LUA_LIN_CFLAGS=-I/usr/include/lua5.1 | ||
LUA_WIN_CFLAGS=TODO: add INCLUDE for Windows LUA | ||
|
||
#LUA_LIN_LIB=`lua-config --libs` | ||
#Ubuntu misses lua-config for lua5.1, thus the hardcoded path | ||
LUA_LIN_LIB=/usr/lib/liblua5.1.a -lm | ||
LUA_WIN_LIB=TODO: add LIB for Windows LUA | ||
|
||
CFLAGS_OS=$(LUA_LIN_CFLAGS) $(APR_LIN_CFLAGS) | ||
#CFLAGS_OS=$(LUA_WIN_CFLAGS) $(APR_WIN_CFLAGS) | ||
|
||
HERE=$(PWD) | ||
LINUX=$(HERE)/../linux-2.6 | ||
|
||
SRCS=$(shell ls *.c) | ||
OBJS=$(patsubst %.c,%.o,$(SRCS)) | ||
DEPS=$(patsubst %.c,.deps/%.d,$(SRCS)) | ||
|
||
MKDIR=mkdir -p | ||
|
||
all: daemon.out | ||
|
||
include/asm: | ||
-$(MKDIR) `dirname $@` | ||
ln -s $(LINUX)/include/asm-lkl include/asm | ||
|
||
include/asm-i386: | ||
-$(MKDIR) `dirname $@` | ||
ln -s $(LINUX)/include/asm-i386 include/asm-i386 | ||
|
||
include/asm-generic: | ||
-$(MKDIR) `dirname $@` | ||
ln -s $(LINUX)/include/asm-generic include/asm-generic | ||
|
||
include/linux: | ||
-$(MKDIR) `dirname $@` | ||
ln -s $(LINUX)/include/linux include/linux | ||
|
||
%.config: $(LINUX)/arch/lkl/defconfig | ||
-mkdir `dirname $@` | ||
cp $^ $@ | ||
|
||
INC=include/asm include/asm-generic include/asm-i386 include/linux | ||
|
||
lkl/vmlinux: lkl/.config drivers/*.c drivers/Makefile | ||
cd $(LINUX) && \ | ||
$(MAKE) O=$(HERE)/`dirname $@` ARCH=lkl \ | ||
LKL_DRIVERS=$(HERE)/drivers \ | ||
vmlinux | ||
|
||
lkl-nt/vmlinux: lkl-nt/.config | ||
cd $(LINUX) && \ | ||
$(MAKE) O=$(HERE)/`dirname $@` ARCH=lkl CROSS_COMPILE=i586-mingw32msvc- \ | ||
LKL_DRIVERS=$(HERE)/drivers \ | ||
vmlinux | ||
|
||
CFLAGS=-Wall -g -DFILE_DISK_MAJOR=42 $(LKL_DEFINES) $(CFLAGS_OS) | ||
|
||
syscalls.o: syscalls.c $(INC) | ||
$(CC) -c $(CFLAGS) -Iinclude $< | ||
|
||
|
||
%.o: %.c $(INC) | ||
$(CC) -c $(CFLAGS) $< | ||
|
||
|
||
AOUT=$(OBJS) lkl/vmlinux | ||
AEXE=$(OBJS) lkl-nt/vmlinux | ||
|
||
clean: | ||
-rm -rf daemon.out daemon.exe include | ||
-rm -rf *.o drivers/*.o drivers/built-in* | ||
-rm -rf drivers/.*.cmd .deps/ *~ | ||
|
||
clean-all: clean | ||
-rm -rf lkl lkl-nt | ||
|
||
TAGS: | ||
etags *.c drivers/*.c | ||
|
||
daemon.out: $(AOUT) $(INC) include/asm | ||
$(CC) $(CFLAGS) $(AOUT) $(APR_LIN_LIB) $(LUA_LIN_LIB) -o $@ | ||
|
||
daemon.exe: $(AEXE) $(INC) | ||
i586-mingw32msvc-gcc $(CFLAGS) $(AEXE) $(APR_WIN_LIB) $(LUA_WIN_LIB) -o $@ | ||
|
||
.deps/%.d: %.c | ||
mkdir -p .deps/$(dir $<) | ||
$(CC) $(CFLAGS) -MM -MT $(patsubst %.c,%.o,$<) $< > $@.$$$$; \ | ||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ | ||
rm -f $@.$$$$ | ||
|
||
include $(DEPS) | ||
|
||
|
||
# nothing here | ||
# more nothingness |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
A LUA and APR based LKL scriptable tester. | ||
|
||
|
||
Prerequisites: | ||
a) APR library - The Apache Portable Runtime Library. | ||
- a set of minimalistic C wrappers over system calls | ||
that permits writing portable and fast code in C. | ||
- on Debian/Ubuntu just do [sudo] apt-get install libapr1-dev. | ||
You'll need to install the "-dev" package to get the header files. | ||
LKLFTPD (currently) looks for the headers in /usr/include/apr-1.0/; | ||
you may need to tweak this on your system. | ||
- a 1.2.1 or better version will do just fine (but later versions | ||
have more bugfixes and better support for some platforms). | ||
b) LUA 5.0 | ||
|
||
c) LKL - if you want to run LKLFTPD through LKL you'll obviously need LKL. | ||
- check on http://ixlabs.cs.pub.ro/linux-kernel-library/ for details about LKL. | ||
|
||
Documentation: | ||
a) APR - http://apr.apache.org/docs/apr/1.2/modules.html | ||
b) LUA - http://www.lua.org | ||
c) LKL - http://ixlabs.cs.pub.ro/linux-kernel-library/ | ||
|
||
|
||
|
||
|
||
|
||
LKL: | ||
To aid developement and o give the tester more functionality we have wrapped | ||
all file IO functions under lkl_file_t based operations. | ||
These are by default mapped "1-1" to apr_file_t, but by defining LKL_FILE_APIS at | ||
compile time you can use lkl based file IO. | ||
a) If LKL_FILE_APIS is NOT DEFINED (which means lkl_file_t is defined as apr_file_t) | ||
you will use the OS APIs to access files. | ||
No LKL code is run/called. You need not link to liblkl. | ||
In this mode you can use LKLFTPD as a standalone ftp server. | ||
b) If LKL_FILE_APIS is DEFINED, lkl_file_t is implemented as a wrapper | ||
over LKL's sys_* functions. In this mode you'll need to link to LKL. | ||
You'll be bound to Linux' licence (currently GPLv2) by linking | ||
directly to Linux code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
|
||
dirops.c,594 | ||
#define BUF_SIZE BUF_SIZE6,66 | ||
static apr_status_t dir_cleanup(void *thedir)dir_cleanup9,90 | ||
apr_status_t lkl_dir_open(lkl_dir_t **new, const char *dirname,lkl_dir_open18,232 | ||
apr_status_t lkl_dir_close(lkl_dir_t *thedir)lkl_dir_close39,865 | ||
apr_status_t lkl_dir_make(const char *path, apr_fileperms_t perm,lkl_dir_make45,982 | ||
apr_status_t lkl_dir_remove(const char *path, apr_pool_t *pool)lkl_dir_remove55,1208 | ||
struct dirent * lkl_readdir(lkl_dir_t *thedir)lkl_readdir64,1341 | ||
apr_status_t lkl_dir_read(apr_finfo_t * finfo, apr_int32_t wanted, lkl_dir_t * thedir)lkl_dir_read83,1767 | ||
|
||
disk.c,170 | ||
unsigned long lkl_disk_get_sectors(void *file)lkl_disk_get_sectors5,53 | ||
int lkl_disk_do_rw(void *_file, unsigned long sector, unsigned long nsect,lkl_disk_do_rw16,246 | ||
|
||
fileops.c,1789 | ||
#define APR_FILE_BUFSIZE APR_FILE_BUFSIZE8,139 | ||
apr_status_t lkl_file_flush_locked(lkl_file_t *thefile)lkl_file_flush_locked10,170 | ||
apr_status_t lkl_file_flush(lkl_file_t *thefile)lkl_file_flush34,591 | ||
static apr_status_t file_cleanup(lkl_file_t *file)file_cleanup50,901 | ||
apr_status_t lkl_unix_file_cleanup(void *thefile)lkl_unix_file_cleanup71,1254 | ||
apr_status_t lkl_unix_child_file_cleanup(void *thefile)lkl_unix_child_file_cleanup83,1521 | ||
apr_status_t lkl_file_open(lkl_file_t **new, const char *fname,lkl_file_open89,1614 | ||
apr_status_t lkl_file_close(lkl_file_t *file)lkl_file_close207,3698 | ||
static apr_status_t lkl_wait_for_io_or_timeout(lkl_file_t *f, int for_read)lkl_wait_for_io_or_timeout212,3821 | ||
static apr_status_t file_read_buffered(lkl_file_t *thefile, void *buf,file_read_buffered234,4205 | ||
apr_status_t lkl_file_read(lkl_file_t *thefile, void *buf,lkl_file_read295,5452 | ||
apr_status_t lkl_file_write(lkl_file_t *thefile, const void *buf,lkl_file_write370,6698 | ||
apr_status_t lkl_file_read_full(lkl_file_t *thefile, void *buf,lkl_file_read_full461,8556 | ||
apr_status_t lkl_file_write_full(lkl_file_t *thefile, const void *buf,lkl_file_write_full484,8990 | ||
static apr_status_t setptr(lkl_file_t *thefile, apr_off_t pos )setptr507,9449 | ||
apr_status_t lkl_file_seek(lkl_file_t *thefile, apr_seek_where_t where, apr_off_t *offset)lkl_file_seek541,10095 | ||
apr_status_t lkl_file_eof(lkl_file_t *fptr)lkl_file_eof593,10985 | ||
apr_status_t lkl_file_remove(const char *path, apr_pool_t *pool)lkl_file_remove601,11099 | ||
apr_status_t lkl_file_rename(const char *from_path, const char *to_path,lkl_file_rename609,11233 | ||
apr_status_t lkl_file_lock(lkl_file_t *thefile, int type)lkl_file_lock618,11410 | ||
apr_status_t lkl_file_unlock(lkl_file_t *thefile)lkl_file_unlock639,11844 | ||
|
||
filestat.c,1031 | ||
#define __KERNEL____KERNEL__3,22 | ||
apr_fileperms_t lkl_unix_mode2perms(mode_t mode)lkl_unix_mode2perms12,134 | ||
mode_t lkl_unix_perms2mode(apr_fileperms_t perms)lkl_unix_perms2mode46,787 | ||
static apr_filetype_e filetype_from_mode(mode_t mode)filetype_from_mode80,1430 | ||
static void fill_out_finfo(apr_finfo_t *finfo, struct stat *info,apr_int32_t wanted)fill_out_finfo114,1960 | ||
apr_status_t lkl_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted,lkl_file_info_get_locked132,2675 | ||
apr_status_t lkl_file_info_get(apr_finfo_t *finfo, apr_int32_t wanted, lkl_file_t *thefile)lkl_file_info_get156,3228 | ||
apr_status_t lkl_file_perms_set(const char *fname, apr_fileperms_t perms)lkl_file_perms_set178,3723 | ||
apr_status_t lkl_file_attrs_set(const char *fname, apr_fileattrs_t attributes,lkl_file_attrs_set190,3947 | ||
apr_status_t lkl_file_mtime_set(const char *fname, apr_time_t mtime,lkl_file_mtime_set243,5201 | ||
apr_status_t lkl_stat(apr_finfo_t *finfo,const char *fname, apr_int32_t wanted, apr_pool_t *pool)lkl_stat268,5730 | ||
|
||
lklops.c,2060 | ||
volatile int shutting_down = 0;shutting_down19,348 | ||
static apr_pool_t *pool;pool20,380 | ||
struct _thread_info {_thread_info22,406 | ||
apr_thread_t *thread;thread23,428 | ||
apr_thread_mutex_t *sched_mutex;sched_mutex24,458 | ||
int dead;dead25,499 | ||
struct kernel_thread_helper_arg {kernel_thread_helper_arg28,514 | ||
int (*fn)(void*);fn29,548 | ||
void *arg;arg30,574 | ||
struct _thread_info *pti;pti31,593 | ||
static int debug_thread_count=0;debug_thread_count34,631 | ||
void* linux_thread_info_alloc(void)linux_thread_info_alloc36,665 | ||
void linux_context_switch(void *prev, void *next)linux_context_switch49,968 | ||
apr_thread_mutex_t *kth_mutex;kth_mutex65,1440 | ||
void* APR_THREAD_FUNC kernel_thread_helper(apr_thread_t *thr, void *arg)kernel_thread_helper67,1472 | ||
void linux_free_thread(void *arg)linux_free_thread79,1870 | ||
int linux_new_thread(int (*fn)(void*), void *arg, void *pti)linux_new_thread86,2041 | ||
apr_thread_mutex_t *lock;lock102,2489 | ||
int count;count103,2516 | ||
apr_thread_cond_t *cond;cond104,2528 | ||
} apr_sem_t;apr_sem_t105,2554 | ||
unsigned long long linux_time(void)linux_time107,2568 | ||
static unsigned long long timer_exp;timer_exp116,2711 | ||
static apr_file_t *events_pipe_in, *events_pipe_out;events_pipe_in117,2748 | ||
static apr_file_t *events_pipe_in, *events_pipe_out;events_pipe_out117,2748 | ||
static apr_pollset_t *pollset;pollset118,2801 | ||
void linux_timer(unsigned long delta)linux_timer120,2833 | ||
void linux_exit_idle(void)linux_exit_idle128,2941 | ||
void linux_enter_idle(int halted)linux_enter_idle136,3047 | ||
long linux_panic_blink(long time)linux_panic_blink162,3550 | ||
static void *_phys_mem;_phys_mem168,3612 | ||
void linux_mem_init(unsigned long *phys_mem, unsigned long *phys_mem_size)linux_mem_init170,3637 | ||
void linux_halt(void)linux_halt176,3797 | ||
static struct linux_native_operations lnops = {lnops180,3841 | ||
void* APR_THREAD_FUNC init_thread(apr_thread_t *thr, void *arg)init_thread196,4243 | ||
void lkl_init(int (*init_2)(void))lkl_init203,4393 | ||
void lkl_fini(unsigned int flag)lkl_fini235,5114 | ||
|
||
lua_main.c,396 | ||
lua_State* L;L8,128 | ||
apr_pool_t * gp;gp9,142 | ||
int luk_stat(lua_State * L)luk_stat10,159 | ||
int luk_get_pid(lua_State * L)luk_get_pid40,816 | ||
static const struct luaL_reg fslib[] = {fslib57,1182 | ||
static apr_status_t lua_lkl_register(lua_State * L, apr_pool_t * root_pool)lua_lkl_register73,1501 | ||
apr_status_t lua_lkl_main(const char * script_file, apr_pool_t * root_pool)lua_lkl_main103,1837 | ||
|
||
main.c,769 | ||
apr_pool_t * root_pool;root_pool22,460 | ||
static const char *script_name="default.lua";script_name24,485 | ||
static const char *disk_image="disk";disk_image25,531 | ||
static const char *fs_type;fs_type26,569 | ||
static int ro=0;ro27,597 | ||
static dev_t devno;devno28,614 | ||
static apr_file_t *disk_file;disk_file29,634 | ||
static int init_err;init_err30,664 | ||
apr_thread_mutex_t *wait_init;wait_init34,708 | ||
int lkl_init_2(void)lkl_init_236,740 | ||
static const apr_getopt_option_t opt_option[] = {opt_option59,1220 | ||
void show_help(const char *name)show_help71,1695 | ||
static int parse_command_line(int argc, char const *const * argv)parse_command_line85,1997 | ||
int main(int argc, char const *const * argv, char const *const * engv)main125,2607 | ||
int *stupidGdb;stupidGdb193,4347 | ||
|
||
syscall_helpers.c,442 | ||
static apr_thread_mutex_t *syscall_mutex;syscall_mutex4,54 | ||
static apr_pool_t *syscall_pool;syscall_pool5,96 | ||
static apr_thread_mutex_t *wait_syscall_mutex;wait_syscall_mutex6,129 | ||
void syscall_helpers_init(void)syscall_helpers_init8,177 | ||
void syscall_helpers_fini(void)syscall_helpers_fini16,468 | ||
void syscall_done(void *arg)syscall_done23,581 | ||
void syscall_enter(void)syscall_enter28,661 | ||
void syscall_exit(void)syscall_exit33,730 | ||
|
||
syscalls.c,2445 | ||
#define SYSCALL_REQ(SYSCALL_REQ15,242 | ||
long wrapper_sys_sync(void)wrapper_sys_sync28,531 | ||
static struct linux_syscall_request halt_sr = {halt_sr33,584 | ||
long wrapper_sys_halt(void)wrapper_sys_halt38,666 | ||
long wrapper_sys_umount(const char *path, int flags)wrapper_sys_umount44,763 | ||
ssize_t wrapper_sys_write(unsigned int fd, const char *buf, size_t count)wrapper_sys_write49,862 | ||
long wrapper_sys_close(unsigned int fd)wrapper_sys_close54,984 | ||
long wrapper_sys_unlink(const char *pathname)wrapper_sys_unlink59,1054 | ||
long wrapper_sys_open(const char *filename, int flags, int mode)wrapper_sys_open64,1143 | ||
long wrapper_sys_poll(struct pollfd *ufds, unsigned int nfds, long timeout)wrapper_sys_poll69,1268 | ||
ssize_t wrapper_sys_read(unsigned int fd, char *buf, size_t count)wrapper_sys_read74,1396 | ||
off_t wrapper_sys_lseek(unsigned int fd, off_t offset, unsigned int origin)wrapper_sys_lseek79,1510 | ||
long wrapper_sys_rename(const char *oldname, const char *newname)wrapper_sys_rename84,1632 | ||
long wrapper_sys_flock(unsigned int fd, unsigned int cmd)wrapper_sys_flock89,1755 | ||
long wrapper_sys_newfstat(unsigned int fd, struct stat *statbuf)wrapper_sys_newfstat94,1848 | ||
long wrapper_sys_chmod(const char *filename, mode_t mode)wrapper_sys_chmod99,1961 | ||
long wrapper_sys_newlstat(char *filename, struct stat *statbuf)wrapper_sys_newlstat104,2067 | ||
long wrapper_sys_mkdir(const char *pathname, int mode)wrapper_sys_mkdir109,2191 | ||
long wrapper_sys_rmdir(const char *pathname)wrapper_sys_rmdir114,2294 | ||
long wrapper_sys_getdents(unsigned int fd, struct linux_dirent *dirent, unsigned int count)wrapper_sys_getdents119,2381 | ||
long wrapper_sys_newstat(char *filename, struct stat *statbuf)wrapper_sys_newstat124,2527 | ||
long wrapper_sys_utimes(const char *filename, struct timeval *utimes)wrapper_sys_utimes129,2649 | ||
long _wrapper_sys_mount(const char *dev, const char *mnt_point, const char *fs, int flags, void *data)_wrapper_sys_mount134,2775 | ||
long wrapper_sys_chdir(const char *dir)wrapper_sys_chdir140,2962 | ||
long wrapper_sys_mknod(const char *filename, int mode, unsigned dev)wrapper_sys_mknod146,3040 | ||
long wrapper_sys_chroot(const char *dir)wrapper_sys_chroot152,3163 | ||
static void get_fs_names(char *page)get_fs_names160,3281 | ||
static int try_mount(char *fstype, char *devno_str, char *mnt, int flags, void *data)try_mount179,3725 | ||
long wrapper_sys_mount(void *file, int devno, char *fstype, int ro)wrapper_sys_mount209,4269 | ||
|
||
thread_wrapper.c,614 | ||
static volatile apr_uint32_t number_of_threads = -1;number_of_threads4,53 | ||
static apr_thread_mutex_t * all_threads_are_gone_mutex;all_threads_are_gone_mutex5,106 | ||
apr_status_t wrapper_apr_thread_init(apr_pool_t * pool)wrapper_apr_thread_init7,163 | ||
apr_status_t wrapper_apr_thread_create (apr_thread_t **new_thread, apr_threadattr_t *attr, apr_thread_start_t func, void *data, apr_pool_t *cont)wrapper_apr_thread_create23,548 | ||
apr_status_t wrapper_apr_thread_exit (apr_thread_t *thd, apr_status_t retval)wrapper_apr_thread_exit34,894 | ||
void wrapper_apr_thread_join_all(void)wrapper_apr_thread_join_all47,1247 | ||
|
||
utils.c,424 | ||
char* lfd_apr_strerror_thunsafe(apr_status_t rc)lfd_apr_strerror_thunsafe9,160 | ||
void lfd_log(enum err_levels lvl, char * fmt, ...)lfd_log16,330 | ||
void bug(const char* p_text)bug25,504 | ||
apr_size_t lfd_ascii_bin_to_ascii(const char* p_in, char* p_out, apr_size_t in_len)lfd_ascii_bin_to_ascii32,574 | ||
struct ascii_to_bin_ret lfd_ascii_ascii_to_bin(char* p_buf, apr_size_t in_len, int prev_cr)lfd_ascii_ascii_to_bin57,1133 | ||
|
||
drivers/console.c,253 | ||
static void console_write(struct console *con, const char *str, unsigned len)console_write7,125 | ||
static struct console console = {console12,229 | ||
static int __init console_init(void)console_init19,360 | ||
late_initcall(console_init);console_init25,442 | ||
|
||
drivers/disk.c,796 | ||
struct lkl_disk_dev {lkl_disk_dev11,207 | ||
void *file;file12,229 | ||
spinlock_t lock; /* For mutual exclusion */lock13,242 | ||
struct request_queue *queue; /* The device request queue */queue14,309 | ||
struct gendisk *gd; /* The gendisk structure */gd15,380 | ||
static void lkl_disk_request(request_queue_t *q)lkl_disk_request18,452 | ||
static int lkl_disk_open(struct inode *inode, struct file *filp)lkl_disk_open38,916 | ||
static struct block_device_operations lkl_disk_ops = {lkl_disk_ops46,1091 | ||
static int major;major52,1218 | ||
static int which=0;which53,1236 | ||
int lkl_disk_add_disk(void *file, dev_t *devno)lkl_disk_add_disk55,1257 | ||
static int __init lkl_disk_init(void)lkl_disk_init96,2286 | ||
late_initcall(lkl_disk_init);lkl_disk_init107,2479 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
print ("~~~~~~~~~~~~~~ begin lua code. Respect my authoritah!") | ||
filename = "default.lua" | ||
s,a = stat(filename) | ||
print ("stat returned ", s, a) | ||
print ("~~~~~~~~~~~~~~ end lua code.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <apr_file_io.h> | ||
|
||
#include "drivers/disk.h" | ||
|
||
unsigned long lkl_disk_get_sectors(void *file) | ||
{ | ||
apr_finfo_t finfo; | ||
|
||
|
||
if (apr_file_info_get(&finfo, APR_FINFO_SIZE, (apr_file_t*)file) != APR_SUCCESS) | ||
return 0; | ||
|
||
return finfo.size/512; | ||
} | ||
|
||
int lkl_disk_do_rw(void *_file, unsigned long sector, unsigned long nsect, | ||
char *buffer, int dir) | ||
{ | ||
apr_off_t offset=sector*512; | ||
apr_size_t len=nsect*512; | ||
apr_file_t *file=(apr_file_t*)_file; | ||
apr_status_t status; | ||
|
||
if (apr_file_seek(file, APR_SET, &offset) != APR_SUCCESS) | ||
return 0; | ||
|
||
if (dir) | ||
status=apr_file_write_full(file, buffer, len, NULL); | ||
else | ||
status=apr_file_read_full(file, buffer, len, NULL); | ||
|
||
return (status == APR_SUCCESS); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj-y := console.o disk.o |
Oops, something went wrong.