2006-08-11 08:35:27 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Barry Wardell
|
|
|
|
*
|
|
|
|
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
|
|
|
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-08-11 08:35:27 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2007-03-22 12:55:51 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2008-11-23 22:07:48 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "common.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "cpu.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "file.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "system.h"
|
2014-08-08 06:28:11 +00:00
|
|
|
#include "../kernel-internal.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "lcd.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "font.h"
|
2008-11-01 16:14:28 +00:00
|
|
|
#include "storage.h"
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#include "file_internal.h"
|
2008-08-07 11:23:40 +00:00
|
|
|
#include "adc.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "button.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "disk.h"
|
2007-06-04 13:48:21 +00:00
|
|
|
#include "crc32-mi4.h"
|
2012-03-04 14:34:29 +00:00
|
|
|
#include "mi4-loader.h"
|
|
|
|
#include "loader_strerror.h"
|
2007-03-16 14:28:00 +00:00
|
|
|
#include <string.h>
|
2007-11-19 02:07:40 +00:00
|
|
|
#include "power.h"
|
2010-05-27 09:41:46 +00:00
|
|
|
#include "version.h"
|
2008-05-21 03:55:17 +00:00
|
|
|
#if defined(SANSA_E200) || defined(PHILIPS_SA9200)
|
2007-10-14 18:20:23 +00:00
|
|
|
#include "i2c.h"
|
|
|
|
#include "backlight-target.h"
|
|
|
|
#endif
|
2007-03-22 12:55:51 +00:00
|
|
|
#include "usb.h"
|
2011-01-15 08:52:59 +00:00
|
|
|
#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200)
|
2007-11-22 22:17:45 +00:00
|
|
|
#include "usb_drv.h"
|
2007-03-22 12:55:51 +00:00
|
|
|
#endif
|
2009-09-08 13:57:13 +00:00
|
|
|
#if defined(SAMSUNG_YH925)
|
|
|
|
/* this function (in lcd-yh925.c) resets the screen orientation for the OF
|
|
|
|
* for use with dualbooting */
|
|
|
|
void lcd_reset(void);
|
|
|
|
#endif
|
2007-03-22 12:55:51 +00:00
|
|
|
|
2008-05-05 12:05:00 +00:00
|
|
|
/* Show the Rockbox logo - in show_logo.c */
|
2011-09-08 18:31:15 +00:00
|
|
|
extern void show_logo(void);
|
2007-03-22 12:55:51 +00:00
|
|
|
|
|
|
|
/* Button definitions */
|
|
|
|
#if CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
2007-09-06 03:28:58 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_C200_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
2008-01-09 07:24:43 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE100_PAD
|
2008-03-05 00:17:21 +00:00
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_POWER
|
2008-01-09 07:24:43 +00:00
|
|
|
|
2008-05-21 03:55:17 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_VOL_UP
|
2008-06-27 18:40:25 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_MENU
|
|
|
|
|
2009-12-25 04:05:01 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_VOL_UP
|
|
|
|
|
2014-05-22 21:34:52 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SAMSUNG_YH920_PAD)
|
2009-05-25 21:10:45 +00:00
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
2009-07-13 21:09:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
2010-03-23 21:28:25 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_OK
|
|
|
|
|
2007-03-22 12:55:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Maximum allowed firmware image size. 10MB is more than enough */
|
|
|
|
#define MAX_LOADSIZE (10*1024*1024)
|
2007-03-16 14:28:00 +00:00
|
|
|
|
2007-03-22 12:55:51 +00:00
|
|
|
/* A buffer to load the original firmware or Rockbox into */
|
|
|
|
unsigned char *loadbuffer = (unsigned char *)DRAM_START;
|
|
|
|
|
2007-03-20 20:45:25 +00:00
|
|
|
/* Locations and sizes in hidden partition on Sansa */
|
2008-10-31 21:25:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_SD)
|
2007-03-20 20:45:25 +00:00
|
|
|
#define PPMI_SECTOR_OFFSET 1024
|
|
|
|
#define PPMI_SECTORS 1
|
|
|
|
#define MI4_HEADER_SECTORS 1
|
2007-03-20 22:18:35 +00:00
|
|
|
#define NUM_PARTITIONS 2
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define NUM_PARTITIONS 1
|
|
|
|
|
|
|
|
#endif
|
2007-03-20 20:45:25 +00:00
|
|
|
|
2007-03-20 22:56:51 +00:00
|
|
|
#define MI4_HEADER_SIZE 0x200
|
|
|
|
|
2007-03-20 20:45:25 +00:00
|
|
|
/* PPMI header structure */
|
|
|
|
struct ppmi_header_t {
|
|
|
|
unsigned char magic[4];
|
|
|
|
uint32_t length;
|
|
|
|
uint32_t pad[126];
|
|
|
|
};
|
|
|
|
|
2008-10-31 21:25:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_SD)
|
2007-03-16 14:28:00 +00:00
|
|
|
/* Load mi4 firmware from a hidden disk partition */
|
2007-03-22 12:45:19 +00:00
|
|
|
int load_mi4_part(unsigned char* buf, struct partinfo* pinfo,
|
|
|
|
unsigned int buffer_size, bool disable_rebuild)
|
2007-03-16 14:28:00 +00:00
|
|
|
{
|
|
|
|
struct mi4header_t mi4header;
|
|
|
|
struct ppmi_header_t ppmi_header;
|
|
|
|
unsigned long sum;
|
|
|
|
|
|
|
|
/* Read header to find out how long the mi4 file is. */
|
2010-04-03 22:18:16 +00:00
|
|
|
storage_read_sectors(pinfo->start + PPMI_SECTOR_OFFSET,
|
|
|
|
PPMI_SECTORS, &ppmi_header);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
|
|
|
/* The first four characters at 0x80000 (sector 1024) should be PPMI*/
|
|
|
|
if( memcmp(ppmi_header.magic, "PPMI", 4) )
|
|
|
|
return EFILE_NOT_FOUND;
|
|
|
|
|
|
|
|
printf("BL mi4 size: %x", ppmi_header.length);
|
|
|
|
|
|
|
|
/* Read mi4 header of the OF */
|
2010-04-03 22:18:16 +00:00
|
|
|
storage_read_sectors(pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS
|
2007-03-17 19:07:20 +00:00
|
|
|
+ (ppmi_header.length/512), MI4_HEADER_SECTORS, &mi4header);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
|
|
|
/* We don't support encrypted mi4 files yet */
|
2007-03-20 12:35:45 +00:00
|
|
|
if( (mi4header.plaintext) != (mi4header.mi4size-MI4_HEADER_SIZE))
|
2007-03-16 14:28:00 +00:00
|
|
|
return EINVALID_FORMAT;
|
|
|
|
|
|
|
|
/* MI4 file size */
|
2007-03-20 12:35:45 +00:00
|
|
|
printf("OF mi4 size: %x", mi4header.mi4size);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
2007-03-20 12:35:45 +00:00
|
|
|
if ((mi4header.mi4size-MI4_HEADER_SIZE) > buffer_size)
|
2007-03-16 14:28:00 +00:00
|
|
|
return EFILE_TOO_BIG;
|
|
|
|
|
|
|
|
/* CRC32 */
|
|
|
|
printf("CRC32: %x", mi4header.crc32);
|
|
|
|
|
|
|
|
/* Rockbox model id */
|
2007-03-19 11:20:22 +00:00
|
|
|
printf("Model id: %.4s", mi4header.model);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
|
|
|
/* Read binary type (RBOS, RBBL) */
|
2007-03-19 11:20:22 +00:00
|
|
|
printf("Binary type: %.4s", mi4header.type);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
|
|
|
/* Load firmware */
|
2010-04-03 22:18:16 +00:00
|
|
|
storage_read_sectors(pinfo->start + PPMI_SECTOR_OFFSET + PPMI_SECTORS
|
2007-03-17 19:07:20 +00:00
|
|
|
+ (ppmi_header.length/512) + MI4_HEADER_SECTORS,
|
2007-03-20 12:35:45 +00:00
|
|
|
(mi4header.mi4size-MI4_HEADER_SIZE)/512, buf);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
|
|
|
/* Check CRC32 to see if we have a valid file */
|
2007-03-17 19:07:20 +00:00
|
|
|
sum = chksum_crc32 (buf,mi4header.mi4size-MI4_HEADER_SIZE);
|
2007-03-16 14:28:00 +00:00
|
|
|
|
|
|
|
printf("Calculated CRC32: %x", sum);
|
|
|
|
|
|
|
|
if(sum != mi4header.crc32)
|
|
|
|
return EBAD_CHKSUM;
|
|
|
|
|
2007-10-20 17:08:41 +00:00
|
|
|
#ifdef SANSA_E200
|
2007-03-22 12:45:19 +00:00
|
|
|
if (disable_rebuild)
|
|
|
|
{
|
|
|
|
char block[512];
|
2007-10-20 17:08:41 +00:00
|
|
|
|
|
|
|
printf("Disabling database rebuild");
|
|
|
|
|
2010-04-03 22:18:16 +00:00
|
|
|
storage_read_sectors(pinfo->start + 0x3c08, 1, block);
|
2007-10-20 17:08:41 +00:00
|
|
|
block[0xe1] = 0;
|
2010-04-03 22:18:16 +00:00
|
|
|
storage_write_sectors(pinfo->start + 0x3c08, 1, block);
|
2007-03-22 12:45:19 +00:00
|
|
|
}
|
2007-10-20 18:30:41 +00:00
|
|
|
#else
|
|
|
|
(void) disable_rebuild;
|
2007-10-20 17:08:41 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-04 14:34:29 +00:00
|
|
|
return mi4header.mi4size-MI4_HEADER_SIZE;
|
2007-03-16 14:28:00 +00:00
|
|
|
}
|
2011-01-15 08:19:30 +00:00
|
|
|
#endif /* (CONFIG_STORAGE & STORAGE_SD) */
|
|
|
|
|
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
/* Return USB_HANDLED if session took place else return USB_EXTRACTED */
|
|
|
|
static int handle_usb(int connect_timeout)
|
|
|
|
{
|
|
|
|
static struct event_queue q SHAREDBSS_ATTR;
|
|
|
|
struct queue_event ev;
|
|
|
|
int usb = USB_EXTRACTED;
|
|
|
|
long end_tick = 0;
|
|
|
|
|
|
|
|
if (!usb_plugged())
|
|
|
|
return USB_EXTRACTED;
|
|
|
|
|
|
|
|
queue_init(&q, true);
|
|
|
|
usb_init();
|
|
|
|
usb_start_monitoring();
|
|
|
|
|
|
|
|
printf("USB: Connecting");
|
|
|
|
|
|
|
|
if (connect_timeout != TIMEOUT_BLOCK)
|
|
|
|
end_tick = current_tick + connect_timeout;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* Sleep no longer than 1/2s */
|
|
|
|
queue_wait_w_tmo(&q, &ev, HZ/2);
|
|
|
|
|
|
|
|
if (ev.id == SYS_USB_CONNECTED)
|
|
|
|
{
|
2011-01-16 00:21:54 +00:00
|
|
|
/* Switch to verbose mode if not in it so that the status updates
|
|
|
|
* are shown */
|
|
|
|
verbose = true;
|
2011-01-15 08:19:30 +00:00
|
|
|
/* Got the message - wait for disconnect */
|
|
|
|
printf("Bootloader USB mode");
|
|
|
|
|
|
|
|
usb = USB_HANDLED;
|
|
|
|
usb_acknowledge(SYS_USB_CONNECTED_ACK);
|
|
|
|
usb_wait_for_disconnect(&q);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (connect_timeout != TIMEOUT_BLOCK &&
|
|
|
|
TIME_AFTER(current_tick, end_tick))
|
|
|
|
{
|
2011-01-16 00:21:54 +00:00
|
|
|
/* Timed out waiting for the connect - will happen when connected
|
|
|
|
* to a charger instead of a host port and the charging pin is
|
|
|
|
* the same as the USB pin */
|
2011-01-15 08:19:30 +00:00
|
|
|
printf("USB: Timed out");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!usb_plugged())
|
|
|
|
break; /* Cable pulled */
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_close();
|
|
|
|
queue_delete(&q);
|
|
|
|
|
|
|
|
return usb;
|
|
|
|
}
|
2011-01-15 08:52:59 +00:00
|
|
|
#elif (defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
|
2011-01-16 00:35:22 +00:00
|
|
|
|| defined (SANSA_VIEW)) && !defined(USE_ROCKBOX_USB)
|
2011-01-15 08:19:30 +00:00
|
|
|
/* Return USB_INSERTED if cable present */
|
|
|
|
static int handle_usb(int connect_timeout)
|
|
|
|
{
|
|
|
|
int usb_retry = 0;
|
|
|
|
int usb = USB_EXTRACTED;
|
|
|
|
|
|
|
|
usb_init();
|
|
|
|
while (usb_drv_powered() && usb_retry < 5 && usb != USB_INSERTED)
|
|
|
|
{
|
|
|
|
usb_retry++;
|
|
|
|
sleep(HZ/4);
|
|
|
|
usb = usb_detect();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usb != USB_INSERTED)
|
|
|
|
usb = USB_EXTRACTED;
|
|
|
|
|
|
|
|
return usb;
|
|
|
|
(void)connect_timeout;
|
|
|
|
}
|
2011-01-15 08:52:59 +00:00
|
|
|
#else
|
|
|
|
/* Ignore cable state */
|
|
|
|
static int handle_usb(int connect_timeout)
|
|
|
|
{
|
|
|
|
return USB_EXTRACTED;
|
|
|
|
(void)connect_timeout;
|
|
|
|
}
|
2011-01-15 08:19:30 +00:00
|
|
|
#endif /* HAVE_BOOTLOADER_USB_MODE */
|
|
|
|
|
2006-08-28 08:11:32 +00:00
|
|
|
void* main(void)
|
|
|
|
{
|
2012-03-04 14:34:29 +00:00
|
|
|
char filename[MAX_PATH];
|
2006-08-28 08:11:32 +00:00
|
|
|
int i;
|
2007-03-12 22:12:20 +00:00
|
|
|
int btn;
|
2006-08-28 08:11:32 +00:00
|
|
|
int rc;
|
2007-03-16 14:28:00 +00:00
|
|
|
int num_partitions;
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
struct partinfo pinfo;
|
2011-01-15 08:19:30 +00:00
|
|
|
#if !(CONFIG_STORAGE & STORAGE_SD)
|
2007-09-06 03:28:58 +00:00
|
|
|
char buf[256];
|
|
|
|
unsigned short* identify_info;
|
2007-03-22 12:45:19 +00:00
|
|
|
#endif
|
2011-01-15 08:19:30 +00:00
|
|
|
int usb = USB_EXTRACTED;
|
2006-08-28 08:11:32 +00:00
|
|
|
|
|
|
|
system_init();
|
|
|
|
kernel_init();
|
2008-05-05 12:05:00 +00:00
|
|
|
|
2011-01-15 08:19:30 +00:00
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
/* loader must service interrupts */
|
|
|
|
enable_interrupt(IRQ_FIQ_STATUS);
|
|
|
|
#endif
|
|
|
|
|
2006-08-28 08:11:32 +00:00
|
|
|
lcd_init();
|
2008-05-05 12:05:00 +00:00
|
|
|
|
2006-08-28 08:11:32 +00:00
|
|
|
font_init();
|
2008-05-05 12:05:00 +00:00
|
|
|
show_logo();
|
|
|
|
|
2008-08-07 11:23:40 +00:00
|
|
|
adc_init();
|
2011-01-15 08:19:30 +00:00
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
button_init_device();
|
|
|
|
#else
|
2006-12-19 11:33:53 +00:00
|
|
|
button_init();
|
2011-01-15 08:19:30 +00:00
|
|
|
#endif
|
2008-05-21 03:55:17 +00:00
|
|
|
#if defined(SANSA_E200) || defined(PHILIPS_SA9200)
|
2007-10-14 18:20:23 +00:00
|
|
|
i2c_init();
|
2015-01-08 23:22:40 +00:00
|
|
|
backlight_hw_on();
|
2007-10-14 18:20:23 +00:00
|
|
|
#endif
|
2008-01-09 07:24:43 +00:00
|
|
|
|
2007-11-19 02:07:40 +00:00
|
|
|
if (button_hold())
|
|
|
|
{
|
|
|
|
verbose = true;
|
2008-05-05 12:05:00 +00:00
|
|
|
lcd_clear_display();
|
2007-11-19 02:07:40 +00:00
|
|
|
printf("Hold switch on");
|
|
|
|
printf("Shutting down...");
|
|
|
|
sleep(HZ);
|
|
|
|
power_off();
|
|
|
|
}
|
2008-05-21 03:55:17 +00:00
|
|
|
|
2007-03-12 22:12:20 +00:00
|
|
|
btn = button_read_device();
|
2008-03-27 00:31:51 +00:00
|
|
|
|
|
|
|
/* Enable bootloader messages if any button is pressed */
|
2011-01-16 00:21:54 +00:00
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
lcd_clear_display();
|
|
|
|
if (btn)
|
|
|
|
verbose = true;
|
|
|
|
#else
|
2008-05-05 12:05:00 +00:00
|
|
|
if (btn) {
|
|
|
|
lcd_clear_display();
|
2008-03-27 00:31:51 +00:00
|
|
|
verbose = true;
|
2008-05-05 12:05:00 +00:00
|
|
|
}
|
2011-01-16 00:21:54 +00:00
|
|
|
#endif
|
2008-03-27 00:31:51 +00:00
|
|
|
|
2006-08-28 08:11:32 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf("Rockbox boot loader");
|
2014-08-28 14:26:45 +00:00
|
|
|
printf("Version: %s", rbversion);
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf(MODEL_NAME);
|
2006-08-28 08:11:32 +00:00
|
|
|
|
2008-11-01 16:14:28 +00:00
|
|
|
i=storage_init();
|
2008-10-31 21:25:04 +00:00
|
|
|
#if !(CONFIG_STORAGE & STORAGE_SD)
|
2006-08-28 08:11:32 +00:00
|
|
|
if (i==0) {
|
2007-01-28 18:42:11 +00:00
|
|
|
identify_info=ata_get_identify();
|
|
|
|
/* Show model */
|
|
|
|
for (i=0; i < 20; i++) {
|
|
|
|
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
|
|
|
|
}
|
|
|
|
buf[40]=0;
|
|
|
|
for (i=39; i && buf[i]==' '; i--) {
|
|
|
|
buf[i]=0;
|
|
|
|
}
|
|
|
|
printf(buf);
|
2006-08-28 08:11:32 +00:00
|
|
|
} else {
|
2010-06-23 05:08:36 +00:00
|
|
|
error(EATA, i, true);
|
2006-08-28 08:11:32 +00:00
|
|
|
}
|
2007-06-30 02:08:27 +00:00
|
|
|
#endif
|
2006-08-28 08:11:32 +00:00
|
|
|
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
filesystem_init();
|
2007-03-16 14:28:00 +00:00
|
|
|
num_partitions = disk_mount_all();
|
|
|
|
if (num_partitions<=0)
|
2006-08-28 08:11:32 +00:00
|
|
|
{
|
2010-06-23 05:08:36 +00:00
|
|
|
error(EDISK,num_partitions, true);
|
2006-08-28 08:11:32 +00:00
|
|
|
}
|
|
|
|
|
2007-03-16 14:28:00 +00:00
|
|
|
/* Just list the first 2 partitions since we don't have any devices yet
|
|
|
|
that have more than that */
|
2007-03-20 22:18:35 +00:00
|
|
|
for(i=0; i<NUM_PARTITIONS; i++)
|
2007-03-16 14:28:00 +00:00
|
|
|
{
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
disk_partinfo(i, &pinfo);
|
2007-03-16 14:28:00 +00:00
|
|
|
printf("Partition %d: 0x%02x %ld MB",
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
i, pinfo.type, pinfo.size / 2048);
|
2007-03-16 14:28:00 +00:00
|
|
|
}
|
2006-08-28 08:11:32 +00:00
|
|
|
|
2011-01-15 08:19:30 +00:00
|
|
|
/* Now that storage is initialized, check for USB connection */
|
|
|
|
if ((btn & BOOTLOADER_BOOT_OF) == 0)
|
|
|
|
{
|
|
|
|
usb_pin_init();
|
|
|
|
usb = handle_usb(HZ*2);
|
|
|
|
if (usb == USB_INSERTED)
|
|
|
|
btn |= BOOTLOADER_BOOT_OF;
|
|
|
|
}
|
|
|
|
|
2009-03-17 20:05:03 +00:00
|
|
|
/* Try loading Rockbox, if that fails, fall back to the OF */
|
|
|
|
if((btn & BOOTLOADER_BOOT_OF) == 0)
|
|
|
|
{
|
|
|
|
printf("Loading Rockbox...");
|
2012-03-04 14:34:29 +00:00
|
|
|
snprintf(filename,sizeof(filename), BOOTDIR "/%s", BOOTFILE);
|
|
|
|
|
|
|
|
rc = load_mi4(loadbuffer, filename, MAX_LOADSIZE);
|
|
|
|
if (rc <= EFILE_EMPTY)
|
2009-03-17 20:05:03 +00:00
|
|
|
{
|
|
|
|
bool old_verbose = verbose;
|
|
|
|
verbose = true;
|
|
|
|
printf("Can't load " BOOTFILE ": ");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2009-03-17 20:05:03 +00:00
|
|
|
verbose = old_verbose;
|
|
|
|
btn |= BOOTLOADER_BOOT_OF;
|
|
|
|
sleep(5*HZ);
|
|
|
|
}
|
|
|
|
else
|
2011-01-15 08:19:30 +00:00
|
|
|
goto main_exit;
|
2009-03-17 20:05:03 +00:00
|
|
|
}
|
|
|
|
|
2007-03-15 22:32:58 +00:00
|
|
|
if(btn & BOOTLOADER_BOOT_OF)
|
2006-08-28 08:11:32 +00:00
|
|
|
{
|
2007-03-16 14:28:00 +00:00
|
|
|
/* Load original mi4 firmware in to a memory buffer called loadbuffer.
|
|
|
|
The rest of the loading is done in crt0.S.
|
|
|
|
1) First try reading from the hidden partition (on Sansa only).
|
|
|
|
2) Next try a decrypted mi4 file in /System/OF.mi4
|
2009-09-08 13:57:13 +00:00
|
|
|
3) Finally, try a raw firmware binary in /System/OF.bin. It should be
|
2007-03-16 14:28:00 +00:00
|
|
|
a mi4 firmware decrypted and header stripped using mi4code.
|
2007-01-28 18:42:11 +00:00
|
|
|
*/
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf("Loading original firmware...");
|
2007-03-16 14:36:14 +00:00
|
|
|
|
2008-10-31 21:25:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_SD)
|
2007-03-16 14:36:14 +00:00
|
|
|
/* First try a (hidden) firmware partition */
|
|
|
|
printf("Trying firmware partition");
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
disk_partinfo(1, &pinfo);
|
|
|
|
if(pinfo.type == PARTITION_TYPE_OS2_HIDDEN_C_DRIVE)
|
2007-03-16 14:28:00 +00:00
|
|
|
{
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
rc = load_mi4_part(loadbuffer, &pinfo, MAX_LOADSIZE,
|
2011-01-15 08:52:59 +00:00
|
|
|
usb == USB_INSERTED);
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc <= EFILE_EMPTY) {
|
2007-03-16 14:28:00 +00:00
|
|
|
printf("Can't load from partition");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2007-03-16 14:28:00 +00:00
|
|
|
} else {
|
2011-01-15 08:19:30 +00:00
|
|
|
goto main_exit;
|
2007-03-16 14:28:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("No hidden partition found.");
|
|
|
|
}
|
2007-03-16 14:36:14 +00:00
|
|
|
#endif
|
2007-03-16 14:28:00 +00:00
|
|
|
|
2011-01-09 19:31:41 +00:00
|
|
|
#if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) || defined(PHILIPS_SA9200)
|
2009-01-10 03:21:07 +00:00
|
|
|
printf("Trying /System/OF.ebn");
|
|
|
|
rc=load_mi4(loadbuffer, "/System/OF.ebn", MAX_LOADSIZE);
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc <= EFILE_EMPTY) {
|
2009-01-10 03:21:07 +00:00
|
|
|
printf("Can't load /System/OF.ebn");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2009-01-10 03:21:07 +00:00
|
|
|
} else {
|
2011-01-15 08:19:30 +00:00
|
|
|
goto main_exit;
|
2009-01-10 03:21:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-03-16 14:28:00 +00:00
|
|
|
printf("Trying /System/OF.mi4");
|
|
|
|
rc=load_mi4(loadbuffer, "/System/OF.mi4", MAX_LOADSIZE);
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc <= EFILE_EMPTY) {
|
2007-03-16 14:28:00 +00:00
|
|
|
printf("Can't load /System/OF.mi4");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2007-03-16 14:28:00 +00:00
|
|
|
} else {
|
2009-09-08 13:57:13 +00:00
|
|
|
#if defined(SAMSUNG_YH925)
|
|
|
|
lcd_reset();
|
|
|
|
#endif
|
2011-01-15 08:19:30 +00:00
|
|
|
goto main_exit;
|
2007-03-16 14:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("Trying /System/OF.bin");
|
2007-01-28 18:42:11 +00:00
|
|
|
rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE);
|
2012-03-04 14:34:29 +00:00
|
|
|
if (rc <= EFILE_EMPTY) {
|
2007-03-12 22:12:20 +00:00
|
|
|
printf("Can't load /System/OF.bin");
|
2012-03-04 14:34:29 +00:00
|
|
|
printf(loader_strerror(rc));
|
2007-03-16 14:28:00 +00:00
|
|
|
} else {
|
2009-09-08 13:57:13 +00:00
|
|
|
#if defined(SAMSUNG_YH925)
|
|
|
|
lcd_reset();
|
|
|
|
#endif
|
2011-01-15 08:19:30 +00:00
|
|
|
goto main_exit;
|
2007-01-28 18:42:11 +00:00
|
|
|
}
|
2007-03-20 10:36:26 +00:00
|
|
|
|
2010-06-23 05:08:36 +00:00
|
|
|
error(0, 0, true);
|
2006-08-28 08:11:32 +00:00
|
|
|
}
|
2011-01-15 08:19:30 +00:00
|
|
|
|
|
|
|
main_exit:
|
|
|
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
|
|
|
storage_close();
|
|
|
|
system_prepare_fw_start();
|
|
|
|
#endif
|
|
|
|
|
2007-01-28 18:42:11 +00:00
|
|
|
return (void*)loadbuffer;
|
2006-08-11 08:35:27 +00:00
|
|
|
}
|