summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ypr0/fs-ypr0.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-12-24 11:56:46 +0000
committerThomas Martitz <kugel@rockbox.org>2011-12-24 11:56:46 +0000
commit249bba03f1051f4984538f66b9e7d36674c61e5c (patch)
treeb9a0d78e05269ed2043521ab0dfdad83aeaf2aff /firmware/target/hosted/ypr0/fs-ypr0.c
parent567e0ad93ef3048f2266932b10dcdb309b1a77c9 (diff)
downloadrockbox-249bba03f1051f4984538f66b9e7d36674c61e5c.tar.gz
rockbox-249bba03f1051f4984538f66b9e7d36674c61e5c.zip
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system, but is the only application. It therefore can implement lots of stuff that native targets also implement, while leveraging the underlying linux kernel. The port is quite advanced. User interface, audio playback, plugins work mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page). Included in utils/ypr0tools are scripts and programs required to generate a patched firmware. The patched firmware has the rootfs modified to load Rockbox. It includes a early/safe USB mode. This port needs a new toolchain, one that includes glibc headers and libraries. rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may also work. Most of the initial effort is done by Lorenzo Miori and others (on ABI), including reverse engineering and patching of the original firmware, initial drivers, and more. Big thanks to you. Flyspray: FS#12348 Author: Lorenzo Miori, myself Merry christmas to ypr0 owners! :) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/ypr0/fs-ypr0.c')
-rw-r--r--firmware/target/hosted/ypr0/fs-ypr0.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/firmware/target/hosted/ypr0/fs-ypr0.c b/firmware/target/hosted/ypr0/fs-ypr0.c
new file mode 100644
index 0000000000..7f49a5f91a
--- /dev/null
+++ b/firmware/target/hosted/ypr0/fs-ypr0.c
@@ -0,0 +1,141 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdlib.h>
23#include <sys/stat.h> /* stat() */
24#include <stdio.h> /* snprintf */
25#include <string.h> /* size_t */
26#include <dirent.h>
27#include <time.h> /* localtime() */
28#include "system-target.h"
29#include "dir-target.h"
30#include "file.h"
31#include "dir.h"
32#include "rbpaths.h"
33
34
35long filesize(int fd)
36{
37 struct stat buf;
38
39 if (!fstat(fd, &buf))
40 return buf.st_size;
41 else
42 return -1;
43}
44
45/* do we really need this in the app? */
46void fat_size(unsigned long* size, unsigned long* free)
47{
48 *size = *free = 0;
49}
50
51#undef opendir
52#undef closedir
53#undef mkdir
54#undef readdir
55
56/* need to wrap around DIR* because we need to save the parent's
57 * directory path in order to determine dirinfo */
58struct __dir {
59 DIR *dir;
60 char *path;
61};
62
63DIR* _opendir(const char *name)
64{
65 char *buf = malloc(sizeof(struct __dir) + strlen(name)+1);
66 if (!buf)
67 return NULL;
68
69 struct __dir *this = (struct __dir*)buf;
70
71 this->path = buf+sizeof(struct __dir);
72 /* definitely fits due to strlen() */
73 strcpy(this->path, name);
74
75 this->dir = opendir(name);
76
77 if (!this->dir)
78 {
79 free(buf);
80 return NULL;
81 }
82 return (DIR*)this;
83}
84
85int _mkdir(const char *name)
86{
87 return mkdir(name, 0777);
88}
89
90int _closedir(DIR *dir)
91{
92 struct __dir *this = (struct __dir*)dir;
93 int ret = closedir(this->dir);
94 free(this);
95 return ret;
96}
97
98struct dirent* _readdir(DIR* dir)
99{
100 struct __dir *d = (struct __dir*)dir;
101 return readdir(d->dir);
102}
103
104struct dirinfo dir_get_info(DIR* _parent, struct dirent *dir)
105{
106 struct __dir *parent = (struct __dir*)_parent;
107 struct stat s;
108 struct tm *tm = NULL;
109 struct dirinfo ret;
110 char path[MAX_PATH];
111
112 snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name);
113 memset(&ret, 0, sizeof(ret));
114
115 if (!stat(path, &s))
116 {
117 if (S_ISDIR(s.st_mode))
118 {
119 ret.attribute = ATTR_DIRECTORY;
120 }
121 ret.size = s.st_size;
122 tm = localtime(&(s.st_mtime));
123 }
124
125 if (!lstat(path, &s) && S_ISLNK(s.st_mode))
126 {
127 ret.attribute |= ATTR_LINK;
128 }
129
130 if (tm)
131 {
132 ret.wrtdate = ((tm->tm_year - 80) << 9) |
133 ((tm->tm_mon + 1) << 5) |
134 tm->tm_mday;
135 ret.wrttime = (tm->tm_hour << 11) |
136 (tm->tm_min << 5) |
137 (tm->tm_sec >> 1);
138 }
139
140 return ret;
141}