forked from Imagelibrary/rtems
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7093cb5e5d | ||
|
|
5812a26eeb | ||
|
|
dc746b50ca | ||
|
|
a346408e4e | ||
|
|
a2a9751823 | ||
|
|
1a304307a2 | ||
|
|
d438427cbe | ||
|
|
004a63efef | ||
|
|
c139a70597 | ||
|
|
1a21831b3c | ||
|
|
8ca15e26ba | ||
|
|
a3199d91f3 | ||
|
|
a76c31e13d | ||
|
|
e1c3dc0909 | ||
|
|
2ed53cb982 | ||
|
|
89fd08eae6 | ||
|
|
492c95eee6 | ||
|
|
7d097c5c69 | ||
|
|
5cc276e7c1 |
@@ -39,7 +39,7 @@ typedef struct {
|
||||
uint32_t size;
|
||||
uint16_t i2c_address_mask;
|
||||
uint16_t i2c_address_shift;
|
||||
rtems_interval program_timeout;
|
||||
rtems_interval program_timeout_in_ticks;
|
||||
} eeprom;
|
||||
|
||||
static uint16_t eeprom_i2c_addr(eeprom *dev, uint32_t off)
|
||||
@@ -48,6 +48,23 @@ static uint16_t eeprom_i2c_addr(eeprom *dev, uint32_t off)
|
||||
| ((off >> dev->i2c_address_shift) & dev->i2c_address_mask);
|
||||
}
|
||||
|
||||
static void eeprom_set_addr(
|
||||
const eeprom *dev,
|
||||
uint32_t off,
|
||||
uint8_t addr[EEPROM_MAX_ADDRESS_BYTES]
|
||||
)
|
||||
{
|
||||
int shift = 24 - (4 - dev->address_bytes) * 8;
|
||||
|
||||
addr[0] = (uint8_t) (off >> shift);
|
||||
shift -= 8;
|
||||
addr[1] = (uint8_t) (off >> shift);
|
||||
shift -= 8;
|
||||
addr[2] = (uint8_t) (off >> shift);
|
||||
shift -= 8;
|
||||
addr[3] = (uint8_t) (off >> shift);
|
||||
}
|
||||
|
||||
static ssize_t eeprom_read(
|
||||
i2c_dev *base,
|
||||
void *buf,
|
||||
@@ -80,12 +97,7 @@ static ssize_t eeprom_read(
|
||||
*/
|
||||
uint16_t cur = (uint16_t) (todo < 255 ? todo : 255);
|
||||
|
||||
uint8_t addr[EEPROM_MAX_ADDRESS_BYTES] = {
|
||||
(uint8_t) off,
|
||||
(uint8_t) (off >> 8),
|
||||
(uint8_t) (off >> 16),
|
||||
(uint8_t) (off >> 24)
|
||||
};
|
||||
uint8_t addr[EEPROM_MAX_ADDRESS_BYTES];
|
||||
i2c_msg msgs[2] = {
|
||||
{
|
||||
.addr = i2c_addr,
|
||||
@@ -101,6 +113,7 @@ static ssize_t eeprom_read(
|
||||
};
|
||||
int err;
|
||||
|
||||
eeprom_set_addr(dev, off, addr);
|
||||
err = i2c_bus_transfer(dev->base.bus, &msgs[0], RTEMS_ARRAY_SIZE(msgs));
|
||||
if (err != 0) {
|
||||
return err;
|
||||
@@ -141,12 +154,7 @@ static ssize_t eeprom_write(
|
||||
uint16_t i2c_addr = eeprom_i2c_addr(dev, off);
|
||||
uint16_t rem = dev->page_size - (off & (dev->page_size - 1));
|
||||
uint16_t cur = (uint16_t) (todo < rem ? todo : rem);
|
||||
uint8_t addr[EEPROM_MAX_ADDRESS_BYTES] = {
|
||||
(uint8_t) off,
|
||||
(uint8_t) (off >> 8),
|
||||
(uint8_t) (off >> 16),
|
||||
(uint8_t) (off >> 24)
|
||||
};
|
||||
uint8_t addr[EEPROM_MAX_ADDRESS_BYTES];
|
||||
i2c_msg msgs[2] = {
|
||||
{
|
||||
.addr = i2c_addr,
|
||||
@@ -164,17 +172,24 @@ static ssize_t eeprom_write(
|
||||
int err;
|
||||
ssize_t m;
|
||||
rtems_interval timeout;
|
||||
bool before;
|
||||
|
||||
eeprom_set_addr(dev, off, addr);
|
||||
err = i2c_bus_transfer(dev->base.bus, &msgs[0], RTEMS_ARRAY_SIZE(msgs));
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
timeout = rtems_clock_tick_later(dev->program_timeout);
|
||||
timeout = rtems_clock_tick_later(dev->program_timeout_in_ticks);
|
||||
|
||||
do {
|
||||
before = rtems_clock_tick_before(timeout);
|
||||
|
||||
m = eeprom_read(&dev->base, &in[0], cur, off);
|
||||
} while (m != cur && rtems_clock_tick_before(timeout));
|
||||
if (m == cur) {
|
||||
break;
|
||||
}
|
||||
} while (before);
|
||||
|
||||
if (m != cur) {
|
||||
return -ETIMEDOUT;
|
||||
@@ -217,6 +232,7 @@ int i2c_dev_register_eeprom(
|
||||
)
|
||||
{
|
||||
uint32_t extra_address;
|
||||
uint32_t ms_per_tick;
|
||||
eeprom *dev;
|
||||
|
||||
if (address_bytes > EEPROM_MAX_ADDRESS_BYTES) {
|
||||
@@ -252,7 +268,9 @@ int i2c_dev_register_eeprom(
|
||||
dev->address_bytes = address_bytes;
|
||||
dev->page_size = page_size_in_bytes;
|
||||
dev->size = size_in_bytes;
|
||||
dev->program_timeout = RTEMS_MILLISECONDS_TO_TICKS(program_timeout_in_ms);
|
||||
ms_per_tick = rtems_configuration_get_milliseconds_per_tick();
|
||||
dev->program_timeout_in_ticks = (program_timeout_in_ms + ms_per_tick - 1)
|
||||
/ ms_per_tick + 1;
|
||||
|
||||
if (extra_address != 0) {
|
||||
dev->i2c_address_mask = extra_address - 1;
|
||||
|
||||
@@ -38,7 +38,8 @@ convert_ascii_to_voidp (const char* arg)
|
||||
int
|
||||
shell_dlopen (int argc, char* argv[])
|
||||
{
|
||||
int arg;
|
||||
int arg;
|
||||
char *err;
|
||||
for (arg = 1; arg < argc; arg++)
|
||||
{
|
||||
void* handle = dlopen (argv[arg], RTLD_NOW | RTLD_GLOBAL);
|
||||
@@ -53,7 +54,10 @@ shell_dlopen (int argc, char* argv[])
|
||||
printf ("handle: %p %s\n", handle, message);
|
||||
}
|
||||
else
|
||||
printf ("error: %s\n", dlerror ());
|
||||
{
|
||||
err = dlerror ();
|
||||
printf ("error: %s\n", err ? err : "");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <dlfcn.h>
|
||||
#include <rtems/rtl/rtl.h>
|
||||
#include "rtl-error.h"
|
||||
|
||||
static rtems_rtl_obj_t*
|
||||
dl_get_obj_from_handle (void* handle)
|
||||
@@ -125,11 +126,14 @@ dlsym (void* handle, const char *symbol)
|
||||
return symval;
|
||||
}
|
||||
|
||||
const char*
|
||||
char*
|
||||
dlerror (void)
|
||||
{
|
||||
static char msg[64];
|
||||
rtems_rtl_get_error (msg, sizeof (msg));
|
||||
rtems_rtl_clear_error ();
|
||||
if (msg[0] == '\0')
|
||||
return NULL;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ int dladdr(void * __restrict, Dl_info * __restrict);
|
||||
int dlctl(void *, int, void *);
|
||||
#endif
|
||||
int dlinfo(void *, int, void *);
|
||||
const char *dlerror(void);
|
||||
char *dlerror(void);
|
||||
__END_DECLS
|
||||
|
||||
/* Values for dlopen `mode'. */
|
||||
|
||||
@@ -52,3 +52,15 @@ rtems_rtl_get_error (char* message, size_t max_message)
|
||||
|
||||
return EIO;
|
||||
}
|
||||
|
||||
void
|
||||
rtems_rtl_clear_error (void)
|
||||
{
|
||||
rtems_rtl_data_t* rtl = rtems_rtl_lock ();
|
||||
if (rtl != NULL)
|
||||
{
|
||||
rtl->last_errno = 0;
|
||||
rtl->last_error[0] = '\0';
|
||||
rtems_rtl_unlock ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ extern "C" {
|
||||
*/
|
||||
void rtems_rtl_set_error (int error, const char* format, ...) RTEMS_RTL_PRINTF_ATTR;
|
||||
|
||||
/**
|
||||
* Clears the error.
|
||||
*/
|
||||
void rtems_rtl_clear_error (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -168,11 +168,9 @@ fat_file_update(fat_fs_info_t *fs_info, fat_file_fd_t *fat_fd)
|
||||
{
|
||||
int ret_rc = RC_OK;
|
||||
|
||||
/*
|
||||
* if fat-file descriptor is not marked as "removed", synchronize
|
||||
* size, first cluster number, write time and date fields of the file
|
||||
*/
|
||||
if (!FAT_FILE_IS_REMOVED(fat_fd) && FAT_FILE_HAS_META_DATA_CHANGED(fat_fd))
|
||||
if (!FAT_FILE_IS_REMOVED(fat_fd) &&
|
||||
FAT_FILE_HAS_META_DATA_CHANGED(fat_fd) &&
|
||||
!FAT_FD_OF_ROOT_DIR(fat_fd))
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
|
||||
fat_file_fd_t *tmp_fat_fd = NULL;
|
||||
struct dirent tmp_dirent;
|
||||
size_t tmp_lfn_len = 0;
|
||||
size_t lfn_len = 0;
|
||||
uint16_t *lfn_buf = converter->buffer.data;
|
||||
char *sfn_buf = converter->buffer.data;
|
||||
const size_t buf_size = converter->buffer.size;
|
||||
@@ -85,7 +85,6 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
uint32_t lfn_start = FAT_FILE_SHORT_NAME;
|
||||
uint8_t lfn_checksum = 0;
|
||||
int lfn_entries = 0;
|
||||
size_t string_size = sizeof(tmp_dirent.d_name);
|
||||
bool is_first_entry;
|
||||
|
||||
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
|
||||
@@ -185,7 +184,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
*/
|
||||
lfn_entries = (*MSDOS_DIR_ENTRY_TYPE(entry) &
|
||||
MSDOS_LAST_LONG_ENTRY_MASK);
|
||||
tmp_lfn_len = 0;
|
||||
lfn_len = 0;
|
||||
lfn_checksum = *MSDOS_DIR_LFN_CHECKSUM(entry);
|
||||
memset (tmp_dirent.d_name, 0, sizeof(tmp_dirent.d_name));
|
||||
}
|
||||
@@ -220,7 +219,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
|
||||
lfn_entries--;
|
||||
offset_lfn = lfn_entries * MSDOS_LFN_LEN_PER_ENTRY;
|
||||
tmp_lfn_len += msdos_get_utf16_string_from_long_entry (
|
||||
lfn_len += msdos_get_utf16_string_from_long_entry (
|
||||
entry,
|
||||
&lfn_buf[offset_lfn],
|
||||
buf_size - offset_lfn,
|
||||
@@ -281,27 +280,30 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
*/
|
||||
if (lfn_start != FAT_FILE_SHORT_NAME)
|
||||
{
|
||||
if (lfn_entries ||
|
||||
lfn_checksum != msdos_lfn_checksum(entry))
|
||||
lfn_start = FAT_FILE_SHORT_NAME;
|
||||
if (lfn_entries == 0 &&
|
||||
lfn_checksum == msdos_lfn_checksum(entry)) {
|
||||
size_t len = sizeof(tmp_dirent.d_name) - 1;
|
||||
|
||||
eno = (*convert_handler->utf16_to_utf8) (
|
||||
converter,
|
||||
lfn_buf,
|
||||
tmp_lfn_len,
|
||||
(uint8_t*)(&tmp_dirent.d_name[0]),
|
||||
&string_size);
|
||||
if (eno == 0) {
|
||||
tmp_dirent.d_namlen = string_size;
|
||||
tmp_dirent.d_name[tmp_dirent.d_namlen] = '\0';
|
||||
}
|
||||
else {
|
||||
eno = (*convert_handler->utf16_to_utf8) (
|
||||
converter,
|
||||
lfn_buf,
|
||||
lfn_len,
|
||||
(uint8_t *) &tmp_dirent.d_name[0],
|
||||
&len);
|
||||
if (eno == 0) {
|
||||
tmp_dirent.d_namlen = len;
|
||||
tmp_dirent.d_name[len] = '\0';
|
||||
} else {
|
||||
lfn_start = FAT_FILE_SHORT_NAME;
|
||||
}
|
||||
} else {
|
||||
lfn_start = FAT_FILE_SHORT_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
if (lfn_start == FAT_FILE_SHORT_NAME)
|
||||
{
|
||||
if (lfn_start == FAT_FILE_SHORT_NAME) {
|
||||
size_t len = sizeof(tmp_dirent.d_name) - 1;
|
||||
|
||||
/*
|
||||
* convert dir entry from fixed 8+3 format (without dot)
|
||||
* to 0..8 + 1dot + 0..3 format
|
||||
@@ -312,13 +314,12 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
converter,
|
||||
sfn_buf,
|
||||
tmp_dirent.d_namlen,
|
||||
(uint8_t*)(&tmp_dirent.d_name[0]),
|
||||
&string_size);
|
||||
(uint8_t *) &tmp_dirent.d_name[0],
|
||||
&len);
|
||||
if ( 0 == eno ) {
|
||||
tmp_dirent.d_namlen = string_size;
|
||||
tmp_dirent.d_name[tmp_dirent.d_namlen] = '\0';
|
||||
}
|
||||
else {
|
||||
tmp_dirent.d_namlen = len;
|
||||
tmp_dirent.d_name[len] = '\0';
|
||||
} else {
|
||||
cmpltd = -1;
|
||||
errno = eno;
|
||||
}
|
||||
|
||||
@@ -1241,10 +1241,10 @@ msdos_compare_entry_against_filename (
|
||||
const uint8_t *entry,
|
||||
const size_t entry_size,
|
||||
const uint8_t *filename,
|
||||
const size_t filename_size_remaining,
|
||||
const size_t name_len_remaining,
|
||||
bool *is_matching)
|
||||
{
|
||||
ssize_t size_remaining = filename_size_remaining;
|
||||
ssize_t size_remaining = name_len_remaining;
|
||||
int eno = 0;
|
||||
uint8_t entry_normalized[MSDOS_LFN_ENTRY_SIZE_UTF8];
|
||||
size_t bytes_in_entry_normalized = sizeof ( entry_normalized );
|
||||
@@ -1270,7 +1270,7 @@ msdos_compare_entry_against_filename (
|
||||
*is_matching = true;
|
||||
} else {
|
||||
*is_matching = false;
|
||||
size_remaining = filename_size_remaining;
|
||||
size_remaining = name_len_remaining;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1287,6 +1287,18 @@ msdos_compare_entry_against_filename (
|
||||
return size_remaining;
|
||||
}
|
||||
|
||||
static void
|
||||
msdos_prepare_for_next_entry(
|
||||
fat_pos_t *lfn_start,
|
||||
bool *entry_matched,
|
||||
ssize_t *name_len_remaining,
|
||||
size_t name_len_for_compare)
|
||||
{
|
||||
lfn_start->cln = FAT_FILE_SHORT_NAME;
|
||||
*entry_matched = false;
|
||||
*name_len_remaining = name_len_for_compare;
|
||||
}
|
||||
|
||||
static int
|
||||
msdos_find_file_in_directory (
|
||||
const uint8_t *filename_converted,
|
||||
@@ -1308,14 +1320,14 @@ msdos_find_file_in_directory (
|
||||
uint32_t dir_entry;
|
||||
fat_pos_t lfn_start;
|
||||
uint8_t lfn_checksum = 0;
|
||||
bool entry_matched = false;
|
||||
bool entry_matched;
|
||||
bool empty_space_found = false;
|
||||
uint32_t entries_per_block = bts2rd / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE;
|
||||
int lfn_entry = 0;
|
||||
uint8_t entry_utf8_normalized[MSDOS_LFN_ENTRY_SIZE_UTF8];
|
||||
size_t bytes_in_entry;
|
||||
bool filename_matched = false;
|
||||
ssize_t filename_size_remaining = name_len_for_compare;
|
||||
ssize_t name_len_remaining;
|
||||
rtems_dosfs_convert_control *converter = fs_info->converter;
|
||||
uint32_t dir_offset = 0;
|
||||
|
||||
@@ -1325,7 +1337,9 @@ msdos_find_file_in_directory (
|
||||
* create the entry if the name is not found.
|
||||
*/
|
||||
|
||||
lfn_start.cln = lfn_start.ofs = FAT_FILE_SHORT_NAME;
|
||||
msdos_prepare_for_next_entry(&lfn_start, &entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
|
||||
while ( (bytes_read = fat_file_read (&fs_info->fat, fat_fd, (dir_offset * bts2rd),
|
||||
bts2rd, fs_info->cl_buf)) != FAT_EOF
|
||||
@@ -1419,6 +1433,9 @@ msdos_find_file_in_directory (
|
||||
printf ("MSFS:[4.1] esc:%li esf:%i\n",
|
||||
*empty_entry_count, empty_space_found);
|
||||
#endif
|
||||
msdos_prepare_for_next_entry(&lfn_start, &entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1492,7 +1509,10 @@ msdos_find_file_in_directory (
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[4.4] no match\n");
|
||||
#endif
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
msdos_prepare_for_next_entry(&lfn_start,
|
||||
&entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
continue;
|
||||
}
|
||||
#if MSDOS_FIND_PRINT
|
||||
@@ -1507,22 +1527,25 @@ msdos_find_file_in_directory (
|
||||
&entry_utf8_normalized[0],
|
||||
sizeof (entry_utf8_normalized));
|
||||
if (bytes_in_entry > 0) {
|
||||
filename_size_remaining = msdos_compare_entry_against_filename (
|
||||
name_len_remaining = msdos_compare_entry_against_filename (
|
||||
converter,
|
||||
&entry_utf8_normalized[0],
|
||||
bytes_in_entry,
|
||||
&filename_converted[0],
|
||||
filename_size_remaining,
|
||||
name_len_remaining,
|
||||
&entry_matched);
|
||||
|
||||
if (filename_size_remaining < 0
|
||||
|| (! entry_matched)) {
|
||||
filename_size_remaining = name_len_for_compare;
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
if (name_len_remaining < 0 || !entry_matched) {
|
||||
msdos_prepare_for_next_entry(&lfn_start,
|
||||
&entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
}
|
||||
} else {
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
entry_matched = false;
|
||||
msdos_prepare_for_next_entry(&lfn_start,
|
||||
&entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1541,9 +1564,13 @@ msdos_find_file_in_directory (
|
||||
if (entry_matched)
|
||||
{
|
||||
if (lfn_entry ||
|
||||
lfn_checksum != msdos_lfn_checksum(entry))
|
||||
entry_matched = false;
|
||||
else if (filename_size_remaining == 0) {
|
||||
name_len_remaining > 0 ||
|
||||
lfn_checksum != msdos_lfn_checksum(entry)) {
|
||||
msdos_prepare_for_next_entry(&lfn_start,
|
||||
&entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
} else if (name_len_remaining == 0) {
|
||||
filename_matched = true;
|
||||
rc = msdos_on_entry_found (
|
||||
fs_info,
|
||||
@@ -1562,7 +1589,8 @@ msdos_find_file_in_directory (
|
||||
printf ("MSFS:[9.2] checksum, entry_matched:%i, lfn_entry:%i, lfn_checksum:%02x/%02x\n",
|
||||
entry_matched, lfn_entry, lfn_checksum, msdos_lfn_checksum(entry));
|
||||
#endif
|
||||
} else {
|
||||
} else if ((*MSDOS_DIR_ATTR(entry) & MSDOS_ATTR_VOLUME_ID)
|
||||
== 0) {
|
||||
bytes_in_entry = MSDOS_SHORT_NAME_LEN + 1;
|
||||
bytes_in_entry = msdos_short_entry_to_utf8_name (
|
||||
converter,
|
||||
@@ -1570,14 +1598,14 @@ msdos_find_file_in_directory (
|
||||
&entry_utf8_normalized[0],
|
||||
bytes_in_entry);
|
||||
if (bytes_in_entry > 0) {
|
||||
filename_size_remaining = msdos_compare_entry_against_filename (
|
||||
name_len_remaining = msdos_compare_entry_against_filename (
|
||||
converter,
|
||||
&entry_utf8_normalized[0],
|
||||
bytes_in_entry,
|
||||
&filename_converted[0],
|
||||
name_len_for_compare,
|
||||
&entry_matched);
|
||||
if (entry_matched && filename_size_remaining == 0) {
|
||||
if (entry_matched && name_len_remaining == 0) {
|
||||
filename_matched = true;
|
||||
rc = msdos_on_entry_found (
|
||||
fs_info,
|
||||
@@ -1591,15 +1619,17 @@ msdos_find_file_in_directory (
|
||||
&lfn_start
|
||||
);
|
||||
}
|
||||
if (rc == RC_OK && (! filename_matched)) {
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
entry_matched = false;
|
||||
filename_size_remaining = name_len_for_compare;
|
||||
if (rc == RC_OK && !filename_matched) {
|
||||
msdos_prepare_for_next_entry(&lfn_start,
|
||||
&entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
}
|
||||
} else {
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
entry_matched = false;
|
||||
filename_size_remaining = name_len_for_compare;
|
||||
msdos_prepare_for_next_entry(&lfn_start,
|
||||
&entry_matched,
|
||||
&name_len_remaining,
|
||||
name_len_for_compare);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,24 +11,9 @@
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
struct rtems_shell_topic_tt;
|
||||
typedef struct rtems_shell_topic_tt rtems_shell_topic_t;
|
||||
|
||||
struct rtems_shell_topic_tt {
|
||||
const char *topic;
|
||||
rtems_shell_topic_t *next;
|
||||
};
|
||||
|
||||
|
||||
extern rtems_shell_cmd_t * rtems_shell_first_cmd;
|
||||
extern rtems_shell_topic_t * rtems_shell_first_topic;
|
||||
|
||||
rtems_shell_topic_t * rtems_shell_lookup_topic(const char *topic);
|
||||
|
||||
bool rtems_shell_can_see_cmd(const rtems_shell_cmd_t *shell_cmd);
|
||||
|
||||
int rtems_shell_execute_cmd(const char *cmd, int argc, char *argv[]);
|
||||
|
||||
extern void rtems_shell_register_monitor_commands(void);
|
||||
|
||||
extern void rtems_shell_print_heap_info(
|
||||
|
||||
@@ -147,6 +147,12 @@ static void rtems_shell_init_once(void)
|
||||
"running on %m\n");
|
||||
|
||||
rtems_shell_init_commands();
|
||||
rtems_shell_register_monitor_commands();
|
||||
}
|
||||
|
||||
void rtems_shell_init_environment(void)
|
||||
{
|
||||
assert(pthread_once(&rtems_shell_once, rtems_shell_init_once) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -721,10 +727,7 @@ bool rtems_shell_main_loop(
|
||||
FILE *stdinToClose = NULL;
|
||||
FILE *stdoutToClose = NULL;
|
||||
|
||||
eno = pthread_once(&rtems_shell_once, rtems_shell_init_once);
|
||||
assert(eno == 0);
|
||||
|
||||
rtems_shell_register_monitor_commands();
|
||||
rtems_shell_init_environment();
|
||||
|
||||
shell_env = rtems_shell_init_env(shell_env_arg);
|
||||
if (shell_env == NULL) {
|
||||
|
||||
@@ -94,6 +94,14 @@ typedef struct {
|
||||
const char *alias;
|
||||
} rtems_shell_alias_t;
|
||||
|
||||
struct rtems_shell_topic_tt;
|
||||
typedef struct rtems_shell_topic_tt rtems_shell_topic_t;
|
||||
|
||||
struct rtems_shell_topic_tt {
|
||||
const char *topic;
|
||||
rtems_shell_topic_t *next;
|
||||
};
|
||||
|
||||
/*
|
||||
* The return value has RTEMS_SHELL_KEYS_EXTENDED set if the key
|
||||
* is extended, ie a special key.
|
||||
@@ -125,6 +133,26 @@ extern int rtems_shell_make_args(
|
||||
int max_args
|
||||
);
|
||||
|
||||
extern rtems_shell_topic_t * rtems_shell_lookup_topic(
|
||||
const char *topic
|
||||
);
|
||||
|
||||
extern bool rtems_shell_can_see_cmd(
|
||||
const rtems_shell_cmd_t *shell_cmd
|
||||
);
|
||||
|
||||
extern int rtems_shell_execute_cmd(
|
||||
const char *cmd, int argc, char *argv[]
|
||||
);
|
||||
|
||||
/*
|
||||
* Call to set up the shell environment if you need to execute commands before
|
||||
* running a shell.
|
||||
*/
|
||||
extern void rtems_shell_init_environment(
|
||||
void
|
||||
);
|
||||
|
||||
extern int rtems_shell_cat_file(
|
||||
FILE *out,
|
||||
const char *name
|
||||
|
||||
@@ -58,7 +58,7 @@ int aio_cancel(int fildes, struct aiocb *aiocbp)
|
||||
rtems_chain_extract (&r_chain->next_fd);
|
||||
rtems_aio_remove_fd (r_chain);
|
||||
pthread_mutex_destroy (&r_chain->mutex);
|
||||
pthread_cond_destroy (&r_chain->mutex);
|
||||
pthread_cond_destroy (&r_chain->cond);
|
||||
free (r_chain);
|
||||
|
||||
pthread_mutex_unlock (&aio_request_queue.mutex);
|
||||
|
||||
@@ -2480,7 +2480,8 @@ const rtems_libio_helper rtems_fs_init_helper =
|
||||
#define CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) \
|
||||
(_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \
|
||||
+ _Configure_From_workspace( \
|
||||
_key_value_pairs * sizeof(POSIX_Keys_Key_value_pair)))
|
||||
_Configure_Max_Objects(_key_value_pairs) \
|
||||
* sizeof(POSIX_Keys_Key_value_pair)))
|
||||
|
||||
/*
|
||||
* The rest of the POSIX threads API features are only available when
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -44,9 +44,14 @@
|
||||
#define FRAME_SIZE (FRAME_OFFSET_LR + 4)
|
||||
#endif
|
||||
|
||||
.syntax unified
|
||||
.section .text
|
||||
|
||||
#ifdef __thumb2__
|
||||
FUNCTION_THUMB_ENTRY(_CPU_Context_validate)
|
||||
#else
|
||||
FUNCTION_ENTRY(_CPU_Context_validate)
|
||||
#endif
|
||||
|
||||
/* Save */
|
||||
|
||||
@@ -99,12 +104,7 @@ FUNCTION_THUMB_ENTRY(_CPU_Context_validate)
|
||||
#ifdef ARM_MULTILIB_VFP
|
||||
/* R3 contains the FPSCR */
|
||||
vmrs r3, FPSCR
|
||||
movs r4, #0x001f
|
||||
#ifdef ARM_MULTILIB_ARCH_V7M
|
||||
movt r4, #0xf000
|
||||
#else
|
||||
movt r4, #0xf800
|
||||
#endif
|
||||
ldr r4, =0xf000001f
|
||||
bic r3, r3, r4
|
||||
and r4, r4, r0
|
||||
orr r3, r3, r4
|
||||
@@ -175,11 +175,34 @@ check:
|
||||
bne restore
|
||||
.endm
|
||||
|
||||
cmp r2, sp
|
||||
/* A compare involving the stack pointer is deprecated */
|
||||
mov r1, sp
|
||||
cmp r2, r1
|
||||
bne restore
|
||||
|
||||
mov r1, r0
|
||||
|
||||
#ifdef __thumb2__
|
||||
cmp r1, r1
|
||||
itttt eq
|
||||
addeq r1, #1
|
||||
addeq r1, #2
|
||||
addeq r1, #4
|
||||
addeq r1, #8
|
||||
subs r1, #15
|
||||
cmp r1, r0
|
||||
bne restore
|
||||
cmp r1, r1
|
||||
iteee eq
|
||||
addeq r1, #1
|
||||
addne r1, #2
|
||||
addne r1, #4
|
||||
addne r1, #8
|
||||
subs r1, #1
|
||||
cmp r1, r0
|
||||
bne restore
|
||||
#endif
|
||||
|
||||
#ifndef ARM_MULTILIB_VFP
|
||||
check_register r3
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -29,8 +29,7 @@ FUNCTION_THUMB_ENTRY(_CPU_Context_volatile_clobber)
|
||||
|
||||
#ifdef ARM_MULTILIB_VFP
|
||||
vmrs r1, FPSCR
|
||||
movs r2, #0x001f
|
||||
movt r2, #0xf800
|
||||
ldr r2, =0xf000001f
|
||||
bic r1, r1, r2
|
||||
and r2, r2, r0
|
||||
orr r1, r1, r2
|
||||
|
||||
@@ -46,6 +46,7 @@ const char rtems_test_name[] = "FSDOSFSNAME 1";
|
||||
#define RAMDISK_PATH "/dev/rda"
|
||||
#define BLOCK_NUM 47
|
||||
#define BLOCK_SIZE 512
|
||||
#define VOLUME_LABEL "MyDisk"
|
||||
|
||||
#define NUMBER_OF_DIRECTORIES 8
|
||||
#define NUMBER_OF_FILES 13
|
||||
@@ -78,7 +79,7 @@ static rtems_resource_snapshot before_mount;
|
||||
|
||||
static const msdos_format_request_param_t rqdata = {
|
||||
.OEMName = "RTEMS",
|
||||
.VolLabel = "RTEMSDisk",
|
||||
.VolLabel = VOLUME_LABEL,
|
||||
.sectors_per_cluster = 2,
|
||||
.fat_num = 0,
|
||||
.files_per_root_dir = 0,
|
||||
@@ -1096,6 +1097,30 @@ static void test_end_of_string_matches( void )
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
static void test_end_of_string_matches_2( void )
|
||||
{
|
||||
int rc;
|
||||
int fd;
|
||||
|
||||
fd = open( MOUNT_DIR "/ets.beam", O_RDWR | O_CREAT,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
|
||||
rtems_test_assert( fd >= 0 );
|
||||
rc = close( fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
fd = open( MOUNT_DIR "/sets.beam", O_RDWR | O_CREAT,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
|
||||
rtems_test_assert( fd >= 0 );
|
||||
rc = close( fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
rc = unlink( MOUNT_DIR "/sets.beam" );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
rc = unlink( MOUNT_DIR "/ets.beam" );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
static void test_full_8_3_name( void )
|
||||
{
|
||||
int rc;
|
||||
@@ -1107,10 +1132,53 @@ static void test_full_8_3_name( void )
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
static void test_dir_with_same_name_as_volume_label( void )
|
||||
{
|
||||
int rc;
|
||||
DIR *dirp;
|
||||
|
||||
rc = mkdir( MOUNT_DIR "/" VOLUME_LABEL, S_IRWXU | S_IRWXG | S_IRWXO );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
dirp = opendir( MOUNT_DIR "/" VOLUME_LABEL );
|
||||
rtems_test_assert( NULL != dirp );
|
||||
|
||||
rc = closedir( dirp );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
rc = unlink( MOUNT_DIR "/" VOLUME_LABEL );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
static void test_file_with_same_name_as_volume_label( void )
|
||||
{
|
||||
int rc;
|
||||
int fd;
|
||||
|
||||
fd = open( MOUNT_DIR "/" VOLUME_LABEL, O_RDWR | O_CREAT,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
|
||||
rtems_test_assert( fd >= 0 );
|
||||
|
||||
rc = close( fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
fd = open( MOUNT_DIR "/" VOLUME_LABEL, O_RDWR );
|
||||
rtems_test_assert( fd >= 0 );
|
||||
|
||||
rc = close( fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
rc = unlink( MOUNT_DIR "/" VOLUME_LABEL );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
static void test_special_cases( void )
|
||||
{
|
||||
test_end_of_string_matches();
|
||||
test_end_of_string_matches_2();
|
||||
test_full_8_3_name();
|
||||
test_file_with_same_name_as_volume_label();
|
||||
test_dir_with_same_name_as_volume_label();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -12,14 +12,12 @@ AM_INIT_AUTOMAKE([no-define foreign 1.12.2])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
RTEMS_ENABLE_CXX
|
||||
|
||||
RTEMS_ENV_RTEMSBSP
|
||||
RTEMS_CHECK_RTEMS_TEST_NO_PAUSE
|
||||
|
||||
RTEMS_PROJECT_ROOT
|
||||
|
||||
RTEMS_PROG_CC_FOR_TARGET
|
||||
|
||||
RTEMS_PROG_CXX_FOR_TARGET
|
||||
|
||||
RTEMS_CANONICALIZE_TOOLS
|
||||
@@ -29,6 +27,8 @@ RTEMS_CHECK_CXX(RTEMS_BSP)
|
||||
RTEMS_CHECK_CPUOPTS([RTEMS_NETWORKING])
|
||||
RTEMS_CHECK_CPUOPTS([RTEMS_POSIX_API])
|
||||
|
||||
AC_PROG_CXX
|
||||
|
||||
AC_PROG_LN_S
|
||||
AC_PATH_PROG([PAX],[pax],no)
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
LINK_OBJS = $(dl01_OBJECTS)
|
||||
LINK_LIBS = $(dl01_LDLIBS)
|
||||
|
||||
init.$(OBJEXT): dl-tar.h
|
||||
|
||||
dl-o1.o: dl-o1.c
|
||||
|
||||
dl.tar: dl-o1.o
|
||||
@@ -29,14 +31,9 @@ dl-tar.h: dl.tar
|
||||
$(BIN2C) -H $< $@
|
||||
CLEANFILES += dl-tar.h
|
||||
|
||||
dl01.pre$(EXEEXT): $(dl01_OBJECTS) $(dl01_DEPENDENCIES)
|
||||
@rm -f dl01.pre$(EXEEXT)
|
||||
$(make-exe)
|
||||
rm -f dl01.pre.ralf
|
||||
|
||||
dl01.pre: dl01.pre$(EXEEXT)
|
||||
mv $< $@
|
||||
CLEANFILES += dl01.pre
|
||||
dl01.pre: $(dl01_OBJECTS) $(dl01_DEPENDENCIES)
|
||||
@rm -f dl01.pre
|
||||
$(LINK_APP)
|
||||
|
||||
dl-sym.o: dl01.pre
|
||||
rtems-syms -e -c "$(CFLAGS)" -o $@ $<
|
||||
|
||||
@@ -27,13 +27,46 @@ int dl_load_test(void)
|
||||
int call_ret;
|
||||
int unresolved;
|
||||
char* message = "loaded";
|
||||
char* err;
|
||||
|
||||
err = dlerror ();
|
||||
if (err != NULL)
|
||||
{
|
||||
printf ("dlerror failed: did not return NULL for no error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("load: /abcd.o (no found)\n");
|
||||
handle = dlopen ("/abcd.o", RTLD_NOW | RTLD_GLOBAL);
|
||||
if (handle)
|
||||
{
|
||||
printf ("dlopen failed: found unknown object file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
err = dlerror ();
|
||||
if (!err)
|
||||
{
|
||||
printf ("dlerror failed: no error message\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("dlerror: %s\n", err);
|
||||
|
||||
err = dlerror ();
|
||||
if (err != NULL)
|
||||
{
|
||||
printf ("dlerror failed: did not return NULL so error no cleared\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("load: /dl-o1.o\n");
|
||||
|
||||
handle = dlopen ("/dl-o1.o", RTLD_NOW | RTLD_GLOBAL);
|
||||
if (!handle)
|
||||
{
|
||||
printf("dlopen failed: %s\n", dlerror());
|
||||
err = dlerror ();
|
||||
printf ("dlopen failed: %s\n", err ? err : "");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -67,7 +100,8 @@ int dl_load_test(void)
|
||||
|
||||
if (dlclose (handle) < 0)
|
||||
{
|
||||
printf("dlclose failed: %s\n", dlerror());
|
||||
err = dlerror ();
|
||||
printf ("dlclose failed: %s\n", err ? err : "");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
LINK_OBJS = $(dl02_OBJECTS)
|
||||
LINK_LIBS = $(dl02_LDLIBS)
|
||||
|
||||
init.$(OBJEXT): dl-tar.h
|
||||
|
||||
dl-o1.o: dl-o1.c
|
||||
|
||||
dl-o2.o: dl-o2.c
|
||||
@@ -31,14 +33,9 @@ dl-tar.h: dl.tar
|
||||
$(BIN2C) -H $< $@
|
||||
CLEANFILES += dl-tar.h
|
||||
|
||||
dl02.pre$(EXEEXT): $(dl02_OBJECTS) $(dl02_DEPENDENCIES)
|
||||
@rm -f dl02.pre$(EXEEXT)
|
||||
$(make-exe)
|
||||
rm -f dl02.pre.ralf
|
||||
|
||||
dl02.pre: dl02.pre$(EXEEXT)
|
||||
mv $< $@
|
||||
CLEANFILES += dl02.pre
|
||||
dl02.pre: $(dl02_OBJECTS) $(dl02_DEPENDENCIES)
|
||||
@rm -f dl02.pre
|
||||
$(LINK_APP)
|
||||
|
||||
dl-sym.o: dl02.pre
|
||||
rtems-syms -e -c "$(CFLAGS)" -o $@ $<
|
||||
|
||||
@@ -21,13 +21,15 @@ static void* dl_load_obj(const char* name)
|
||||
void* handle;
|
||||
int unresolved;
|
||||
char* message = "loaded";
|
||||
char* err;
|
||||
|
||||
printf("load: %s\n", name);
|
||||
|
||||
handle = dlopen (name, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (!handle)
|
||||
{
|
||||
printf("dlopen failed: %s\n", dlerror());
|
||||
err = dlerror ();
|
||||
printf ("dlopen failed: %s\n", err ? err : "");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -48,6 +50,7 @@ int dl_load_test(void)
|
||||
call_t call;
|
||||
int call_ret;
|
||||
int ret;
|
||||
char* err;
|
||||
|
||||
o1 = dl_load_obj("/dl-o1.o");
|
||||
if (!o1)
|
||||
@@ -83,7 +86,8 @@ int dl_load_test(void)
|
||||
|
||||
if (dlclose (o1) < 0)
|
||||
{
|
||||
printf("dlclose o1 failed: %s\n", dlerror());
|
||||
err = dlerror ();
|
||||
printf ("dlclose o1 failed: %s\n", err ? err : "");
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
@@ -91,7 +95,8 @@ int dl_load_test(void)
|
||||
|
||||
if (dlclose (o2) < 0)
|
||||
{
|
||||
printf("dlclose o1 failed: %s\n", dlerror());
|
||||
err = dlerror ();
|
||||
printf ("dlclose o2 failed: %s\n", err ? err : "");
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
LINK_OBJS = $(dl04_OBJECTS)
|
||||
LINK_LIBS = $(dl04_LDLIBS)
|
||||
|
||||
init.$(OBJEXT): dl-tar.h
|
||||
|
||||
dl-o4.o: dl-o4.cpp
|
||||
|
||||
dl.tar: dl-o4.o
|
||||
@@ -30,14 +32,9 @@ dl-tar.h: dl.tar
|
||||
$(BIN2C) -H $< $@
|
||||
CLEANFILES += dl-tar.h
|
||||
|
||||
dl04.pre$(EXEEXT): $(dl04_OBJECTS) $(dl04_DEPENDENCIES)
|
||||
@rm -f dl04.pre$(EXEEXT)
|
||||
$(make-exe)
|
||||
rm -f dl04.pre.ralf
|
||||
|
||||
dl04.pre: dl04.pre$(EXEEXT)
|
||||
mv $< $@
|
||||
CLEANFILES += dl04.pre
|
||||
dl04.pre: $(dl04_OBJECTS) $(dl04_DEPENDENCIES)
|
||||
@rm -f dl04.pre
|
||||
$(LINK_APP)
|
||||
|
||||
dl-sym.o: dl04.pre
|
||||
rtems-syms -e -c "$(CFLAGS)" -o $@ $<
|
||||
|
||||
@@ -14,6 +14,8 @@ AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
LINK_OBJS = $(dl05_OBJECTS)
|
||||
LINK_LIBS = $(dl05_LDLIBS)
|
||||
|
||||
init.$(OBJEXT): dl-tar.h
|
||||
|
||||
dl-o5.o: dl-o5.cpp
|
||||
|
||||
dl.tar: dl-o5.o
|
||||
@@ -29,15 +31,10 @@ dl-tar.h: dl.tar
|
||||
$(BIN2C) -H $< $@
|
||||
CLEANFILES += dl-tar.h
|
||||
|
||||
dl05.pre$(EXEEXT): $(dl05_OBJECTS) $(dl05_DEPENDENCIES)
|
||||
@rm -f dl05.pre$(EXEEXT)
|
||||
dl05.pre: $(dl05_OBJECTS) $(dl05_DEPENDENCIES)
|
||||
@rm -f dl05.pre
|
||||
$(LINK.cc) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
|
||||
-o $(basename $@)$(EXEEXT) $(LINK_OBJS) $(LINK_LIBS)
|
||||
rm -f dl05.pre.ralf
|
||||
|
||||
dl05.pre: dl05.pre$(EXEEXT)
|
||||
mv $< $@
|
||||
CLEANFILES += dl05.pre
|
||||
-o $@ $(LINK_OBJS) $(LINK_LIBS)
|
||||
|
||||
dl-sym.o: dl05.pre
|
||||
rtems-syms -e -c "$(CFLAGS)" -o $@ $<
|
||||
|
||||
Reference in New Issue
Block a user