Ignore:
Timestamp:
Apr 29, 2017, 4:33:37 PM (7 years ago)
Author:
coas-nagasima
Message:

ファイルを追加、更新。

Location:
EcnlProtoTool/trunk/ntshell/fatfs
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/fatfs/ccsbcs.c

    r278 r279  
    266266
    267267
    268 #if !_TBLDEF || !_USE_LFN
     268#if _CODE_PAGE != 65001 && (!_TBLDEF || !_USE_LFN)
    269269#error This file is not needed at current configuration. Remove from the project.
    270270#endif
     
    272272
    273273
    274 
     274#if _CODE_PAGE != 65001
    275275WCHAR ff_convert (      /* Converted character, Returns zero on error */
    276276        WCHAR   chr,    /* Character code to be converted */
     
    298298        return c;
    299299}
    300 
     300#endif
    301301
    302302
  • EcnlProtoTool/trunk/ntshell/fatfs/diskio.c

    r278 r279  
    1515#define MAX_DRIVES      1       /* Max number of physical drives to be used */
    1616
    17 unsigned char RamDisk[SZ_RAMDISK * 1024];
     17#define RamDisk _binary____webserver_httpd_fs_bin_start
     18extern unsigned char RamDisk[];
    1819
    1920typedef struct {
  • EcnlProtoTool/trunk/ntshell/fatfs/ff.c

    r278 r279  
    314314#endif
    315315#define _DF1S   0
     316
     317#elif _CODE_PAGE == 65001 /* UTF-8 */
     318#if _LFN_UNICODE
     319#error Cannot use LFN_UNICODE feature without valid code page.
     320#endif
     321#define _DF1S   0
     322
     323void Utf16_to_Utf8(unsigned char *ret_code, int *ret_size, UINT chr)
     324{
     325        ret_code[0] = ret_code[1] = ret_code[2] = ret_code[3] = 0;
     326
     327        if (chr <= 0x7f) {  // ASCII互換
     328                ret_code[0] = chr;
     329                *ret_size = 1;
     330                return;
     331        }
     332
     333        if (chr <= 0x7ff) {
     334                ret_code[1] = (0x80 | (chr & 0x3f));
     335                ret_code[0] = (0xc0 | (chr >> 6));
     336                *ret_size = 2;
     337                return;
     338        }
     339
     340        if (chr <= 0xffff) {
     341                ret_code[2] = (0x80 | (chr & 0x3f));
     342                ret_code[1] = (0x80 | ((chr >> 6) & 0x3f));
     343                ret_code[0] = (0xe0 | ((chr >> 12) & 0x0f));
     344                *ret_size = 3;
     345                return;
     346        }
     347
     348        if (chr <= 0x1fffff) {
     349                ret_code[3] = (0x80 | (chr & 0x3f));
     350                ret_code[2] = (0x80 | ((chr >> 6) & 0x3f));
     351                ret_code[1] = (0x80 | ((chr >> 12) & 0x3f));
     352                ret_code[0] = (0xf0 | ((chr >> 18) & 0x07));
     353                *ret_size = 4;
     354                return;
     355        }
     356
     357        if (chr <= 0x3ffffff) {
     358                ret_code[4] = (0x80 | (chr & 0x3f));
     359                ret_code[3] = (0x80 | ((chr >> 6) & 0x3f));
     360                ret_code[2] = (0x80 | ((chr >> 12) & 0x3f));
     361                ret_code[1] = (0x80 | ((chr >> 18) & 0x3f));
     362                ret_code[0] = (0xf8 | ((chr >> 24) & 0x03));
     363                *ret_size = 5;
     364                return;
     365        }
     366
     367        ret_code[5] = (0x80 | (chr & 0x3f));
     368        ret_code[4] = (0x80 | ((chr >> 6) & 0x3f));
     369        ret_code[3] = (0x80 | ((chr >> 12) & 0x3f));
     370        ret_code[2] = (0x80 | ((chr >> 18) & 0x3f));
     371        ret_code[1] = (0x80 | ((chr >> 24) & 0x3f));
     372        ret_code[0] = (0xfc | ((chr >> 30) & 0x01));
     373        *ret_size = 6;
     374        return;
     375}
     376
     377//2バイトのUTF-16コードが得られる
     378WCHAR Utf8_to_Utf16(const char *src, int *code_size)
     379{
     380        int i;
     381        unsigned int uc = 0;
     382        unsigned char len = 0;
     383
     384        len = 0;
     385        if ((src[0] & 0x80) == 0) { uc = src[0] & 0x7F; len = 0; }
     386        else if ((src[0] & 0xE0) == 0xC0) { uc = src[0] & 0x1F; len = 1; }
     387        else if ((src[0] & 0xF0) == 0xE0) { uc = src[0] & 0x0F; len = 2; }
     388        else if ((src[0] & 0xF8) == 0xF0) { uc = src[0] & 0x07; len = 3; }
     389        else if ((src[0] & 0xFC) == 0xF8) { uc = src[0] & 0x03; len = 4; }
     390        else if ((src[0] & 0xFE) == 0xFC) { uc = src[0] & 0x01; len = 5; }
     391
     392        i = 1;
     393        while ((i <= len) && ((src[i] & 0xC0) == 0x80)) {
     394                uc = (uc << 6) | (src[i] & 0x3F);
     395                i++;
     396        }
     397
     398        //消費文字数設定
     399        *code_size = i;
     400
     401        //現状、2バイト限定
     402        return uc;
     403}
    316404
    317405#else
     
    17121800        WCHAR w, *lfn;
    17131801#endif
     1802#if _CODE_PAGE == 65001
     1803        unsigned char utf8_code[6];
     1804        int code_size;
     1805#endif
    17141806
    17151807        p = fno->fname;
     
    17481840                        while ((w = *lfn++) != 0) {             /* Get an LFN character */
    17491841#if !_LFN_UNICODE
     1842#if _CODE_PAGE == 65001
     1843                                Utf16_to_Utf8(utf8_code, &code_size, w);
     1844                                for (int j = 0; j < code_size - 1; j++) {
     1845                                        p[i++] = utf8_code[j];
     1846                                }
     1847                                w = utf8_code[code_size - 1];
     1848#else
    17501849                                w = ff_convert(w, 0);           /* Unicode -> OEM */
    17511850                                if (!w) { i = 0; break; }       /* No LFN if it could not be converted */
     
    17531852                                        p[i++] = (TCHAR)(w >> 8);
    17541853#endif
     1854#endif
    17551855                                if (i >= fno->lfsize - 1) { i = 0; break; }     /* No LFN if buffer overflow */
    17561856                                p[i++] = (TCHAR)w;
     
    17781878
    17791879#if !_LFN_UNICODE
     1880#if _CODE_PAGE == 65001
     1881        int code_size;
     1882        chr = Utf8_to_Utf16(*ptr, &code_size);
     1883        (*ptr) += code_size;
     1884#else
    17801885        chr = (BYTE)*(*ptr)++;                                  /* Get a byte */
    17811886        if (IsLower(chr)) chr -= 0x20;                  /* To upper ASCII char */
    17821887        if (IsDBCS1(chr) && IsDBCS2(**ptr))             /* Get DBC 2nd byte if needed */
    17831888                chr = chr << 8 | (BYTE)*(*ptr)++;
     1889#endif
    17841890#ifdef _EXCVT
    17851891        if (chr >= 0x80) chr = ExCvt[chr - 0x80];       /* To upper SBCS extended char */
     
    18511957        UINT i, ni, si, di;
    18521958        const TCHAR *p;
    1853 
     1959#if _CODE_PAGE == 65001
     1960        char utf8_code[6];
     1961        int code_size;
     1962#endif
    18541963        /* Create LFN in Unicode */
    18551964        for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */
     
    18621971                        return FR_INVALID_NAME;
    18631972#if !_LFN_UNICODE
     1973#if _CODE_PAGE == 65001
     1974                w = Utf8_to_Utf16(&p[si - 1], &code_size);
     1975                si += code_size - 1;
     1976#else
    18641977                w &= 0xFF;
    18651978                if (IsDBCS1(w)) {                               /* Check if it is a DBC 1st byte (always false on SBCS cfg) */
     
    18711984                w = ff_convert(w, 1);                   /* Convert ANSI/OEM to Unicode */
    18721985                if (!w) return FR_INVALID_NAME; /* Reject invalid code */
     1986#endif
    18731987#endif
    18741988                if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */
     
    19252039                        if (w) w = ExCvt[w - 0x80];     /* Convert extended character to upper (SBCS) */
    19262040#else
     2041#if _CODE_PAGE == 65001
     2042                        Utf16_to_Utf8(utf8_code, &code_size, ff_wtoupper(w));
     2043#else
    19272044                        w = ff_convert(ff_wtoupper(w), 0);      /* Upper converted Unicode -> OEM code */
    19282045#endif
     2046#endif
    19292047                        cf |= NS_LFN;                           /* Force create LFN entry */
    19302048                }
    1931 
     2049#if _CODE_PAGE == 65001
     2050                else
     2051                        code_size = 1;
     2052#endif
     2053
     2054#if _CODE_PAGE == 65001
     2055                if (code_size > 1) {            /* Is this DBC? (always false at SBCS cfg) */
     2056                        if (i >= ni - 1) {
     2057                                cf |= NS_LOSS | NS_LFN; i = ni; continue;
     2058                        }
     2059                        for (int j = 0; j < code_size; j++) {
     2060                                dp->fn[i++] = (BYTE)utf8_code[j];
     2061                        }
     2062                }
     2063                else {                                          /* SBC */
     2064                        if (!w || chk_chr("+,;=[]", w)) {       /* Replace illegal characters for SFN */
     2065                                w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */
     2066                        }
     2067                        else {
     2068                                if (IsUpper(w)) {               /* ASCII large capital */
     2069                                        b |= 2;
     2070                                }
     2071                                else {
     2072                                        if (IsLower(w)) {       /* ASCII small capital */
     2073                                                b |= 1; w -= 0x20;
     2074                                        }
     2075                                }
     2076                        }
     2077                        dp->fn[i++] = (BYTE)w;
     2078                }
     2079#else
    19322080                if (_DF1S && w >= 0x100) {              /* Is this DBC? (always false at SBCS cfg) */
    19332081                        if (i >= ni - 1) {
     
    19492097                }
    19502098                dp->fn[i++] = (BYTE)w;
     2099#endif
    19512100        }
    19522101
     
    31783327}
    31793328
    3180 
     3329FRESULT f_seek(FIL* fp, DWORD ofs, BYTE mode)
     3330{
     3331  switch (mode) {
     3332  case F_SEEK_SET:
     3333    return f_lseek((fp), ofs);
     3334  case F_SEEK_CUR:
     3335    return f_lseek((fp), (fp)->fptr + ofs);
     3336  case F_SEEK_END:
     3337    return f_lseek((fp), (fp)->fsize - ofs);
     3338  default:
     3339    return FR_INVALID_PARAMETER;
     3340  }
     3341}
    31813342
    31823343#if _FS_MINIMIZE <= 1
     
    37193880        DWORD dw;
    37203881        DEFINE_NAMEBUF;
     3882        TCHAR *temp_new_path = 0;
    37213883
    37223884
     
    37423904                                else
    37433905                                        res = FR_INVALID_DRIVE;
    3744                                 if (res == FR_OK) res = FR_EXIST;               /* The new object name is already existing */
     3906                                if (res == FR_OK) {
     3907                                        res = FR_EXIST;         /* The new object name is already existing */
     3908                                        dir = djn.dir;
     3909                                        if (dir[DIR_Attr] & AM_DIR) {   /* The new object is a directory */
     3910                                                temp_new_path = (TCHAR *)ff_memalloc((_MAX_LFN + 1) * sizeof(WCHAR));
     3911                                                snprintf(temp_new_path, _MAX_LFN, "%s/%s", path_new, basename((char *)path_old));
     3912                                                res = follow_path(&djn, temp_new_path);
     3913                                        }
     3914                                }
    37453915                                if (res == FR_NO_FILE) {                                /* It is a valid path and no name collision */
    37463916                                        res = dir_register(&djn);                       /* Register the new entry */
     
    37773947        }
    37783948
     3949        if (temp_new_path != 0) ff_memfree(temp_new_path);
     3950
    37793951        LEAVE_FF(djo.fs, res);
    37803952}
     
    39124084        WCHAR w;
    39134085        DWORD tm;
    3914 
     4086#if _CODE_PAGE == 65001
     4087        int code_size;
     4088        char utf8_code[6];
     4089#endif
    39154090
    39164091        /* Get logical drive number */
     
    39254100                i = j = 0;
    39264101                do {
     4102#if _CODE_PAGE == 65001
     4103                        w = ff_wtoupper(Utf8_to_Utf16(&label[i], &code_size));
     4104                        i += code_size;
     4105                        Utf16_to_Utf8(utf8_code, &code_size, w);
     4106                        if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= sizeof(vn) - code_size) /* Reject invalid characters for volume label */
     4107                                LEAVE_FF(dj.fs, FR_INVALID_NAME);
     4108                        for (int k = 0; k < code_size; k++)
     4109                                vn[j++] = utf8_code[k];
     4110#else
    39274111#if _USE_LFN && _LFN_UNICODE
    39284112                        w = ff_convert(ff_wtoupper(label[i++]), 0);
     
    39464130                        if (w >= 0x100) vn[j++] = (BYTE)(w >> 8);
    39474131                        vn[j++] = (BYTE)w;
     4132#endif
    39484133                } while (i < sl);
    39494134                while (j < 11) vn[j++] = ' ';   /* Fill remaining name field */
  • EcnlProtoTool/trunk/ntshell/fatfs/ff.h

    r278 r279  
    143143/* Directory object structure (DIR) */
    144144
    145 typedef struct {
     145typedef struct __dirstream {
    146146        FATFS*  fs;                             /* Pointer to the owner file system object (**do not change order**) */
    147147        WORD    id;                             /* Owner file system mount ID (**do not change order**) */
     
    162162        const TCHAR*    pat;    /* Pointer to the name matching pattern */
    163163#endif
     164        struct dirent *dirent;
    164165} DIR;
    165166
     
    252253#define f_rewind(fp) f_lseek((fp), 0)
    253254#define f_rewinddir(dp) f_readdir((dp), 0)
    254 #define f_flush(fp)
     255#define f_flush(fp) (FR_OK)
    255256
    256257#define F_SEEK_SET 1
    257258#define F_SEEK_CUR 2
    258259#define F_SEEK_END 3
    259 static FRESULT f_seek(FIL* fp, DWORD ofs, BYTE mode)
    260 {
    261   switch (mode) {
    262   case F_SEEK_SET:
    263     return f_lseek((fp), ofs);
    264   case F_SEEK_CUR:
    265     return f_lseek((fp), (fp)->fptr + ofs);
    266   case F_SEEK_END:
    267     return f_lseek((fp), (fp)->fsize - ofs);
    268   default:
    269     return FR_INVALID_PARAMETER;
    270   }
    271 }
     260FRESULT f_seek(FIL* fp, DWORD ofs, BYTE mode);
    272261
    273262#ifndef EOF
  • EcnlProtoTool/trunk/ntshell/fatfs/ffarch.c

    r278 r279  
    5656#include <kernel.h>
    5757#include <stdlib.h>
    58 #include <errno.h>
    59 #include <sys/types.h>
    6058#include <string.h>
    6159#include "t_stdlib.h"
     60#include "syssvc/serial.h"
    6261#include "syssvc/syslog.h"
    6362#include "kernel_cfg.h"
     
    6564#include "sdfs.h"
    6665#include "ff.h"
     66#include "tlsf.h"
     67#include "ntstdio.h"
     68
     69#define SIO_PORTID 1
     70extern ntstdio_t ntstdio;
     71
     72static tlsf_t sys_tlsf;
     73static pool_t sys_pool;
     74
     75uint32_t  __HeapBase;
     76uint32_t  __HeapLimit;
     77FATFS RomDisk;
    6778
    6879gpio_t ins;
     
    7081#define WP() false
    7182
    72 extern FATFS RomDisk;
    73 extern unsigned char RamDisk[SZ_RAMDISK * 1024];
    74 
     83typedef struct SD {
     84        DSTATUS dst;
     85        BYTE type;
     86        FATFS FatFs;
     87} SD;
     88SD Sd;
     89
     90void sys_init(void);
    7591bool_t romdisk_init();
     92bool_t SD_begin();
    7693
    7794int mruby_arduino_init()
    7895{
    7996        int result = -1;
     97
     98        sys_init();
    8099
    81100        /* SD_CD */
     
    85104        sdfs_init(&sdfs, P8_5, P8_6, P8_3, P8_4, "sd");
    86105
    87         SD_begin();
    88 
    89         FIL fd;
    90         UINT rlen = 0;
    91         memset(&fd, 0, sizeof(fd));
    92         if (f_open(&fd, "1:/httpd-fs.bin", FA_OPEN_EXISTING | FA_READ) == FR_OK) {
    93                 f_read(&fd, RamDisk, SZ_RAMDISK * 1024, &rlen);
    94                 f_close(&fd);
    95                 if (romdisk_init())
    96                         result = 0;
    97         }
    98 
     106        result = SD_begin() ? 0 : -1;
    99107        if (result == 0) {
    100                 syslog(LOG_NOTICE, "ramdisk ok!");
     108                ntstdio_printf(&ntstdio, "SD card (1:) OK!\n");
    101109        }
    102110        else {
    103                 syslog(LOG_NOTICE, "ramdisk ng!");
    104         }
    105 
    106         arduino_init();
     111                ntstdio_printf(&ntstdio, "SD card (1:) NG!\n");
     112        }
     113        sta_cyc(SDFS_CYC);
     114
     115        if (romdisk_init())
     116                result = 0;
     117
     118        if (result == 0) {
     119                ntstdio_printf(&ntstdio, "ROM disk (0:) OK!\n");
     120        }
     121        else {
     122                ntstdio_printf(&ntstdio, "ROM disk (0:) NG!\n");
     123        }
     124
     125        /* uploadディレクトリを作成しておく */
     126        f_mkdir("1:/upload");
     127
     128        serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    107129
    108130        return result;
     131}
     132
     133void sys_init(void)
     134{
     135        sys_tlsf = tlsf_create(&__HeapBase);
     136        if (sys_tlsf == NULL)
     137                return;
     138
     139        sys_pool = tlsf_add_pool(sys_tlsf, ((uint8_t *)&__HeapBase) + tlsf_size(), ((size_t)&__HeapLimit - (size_t)&__HeapBase) - tlsf_size());
     140}
     141
     142void sys_fini(void)
     143{
     144        tlsf_destroy(sys_tlsf);
     145}
     146
     147void *sys_malloc(size_t size)
     148{
     149        return tlsf_malloc(sys_tlsf, size);
     150}
     151
     152void *sys_calloc(size_t size, size_t count)
     153{
     154        void *result = tlsf_malloc(sys_tlsf, count * size);
     155        memset(result, 0, count * size);
     156        return result;
     157}
     158
     159void *sys_realloc(void *ptr, size_t size)
     160{
     161        return tlsf_realloc(sys_tlsf, ptr, size);
     162}
     163
     164void sys_free(void *ptr)
     165{
     166        tlsf_free(sys_tlsf, ptr);
    109167}
    110168
     
    122180
    123181        if ((res = f_mount(&RomDisk, "0:", 1)) != FR_OK) {
     182                return false;
     183        }
     184
     185        return true;
     186}
     187
     188bool_t SD_begin()
     189{
     190        DSTATUS dst;
     191        FRESULT res;
     192        BYTE pdrv = 1, type;
     193
     194        if (Sd.FatFs.fs_type != 0)
     195                return true;
     196
     197        if ((dst = disk_initialize(pdrv)) != RES_OK) {
     198                return false;
     199        }
     200
     201        if ((dst = disk_ioctl(pdrv, MMC_GET_TYPE, &type)) != RES_OK) {
     202                Sd.dst = dst;
     203                Sd.type = 0;
     204        }
     205        else {
     206                Sd.dst = RES_OK;
     207                Sd.type = type;
     208        }
     209
     210        if ((res = f_mount(&Sd.FatFs, "1:", 1)) != FR_OK) {
    124211                return false;
    125212        }
     
    207294}
    208295
    209 static int lock[TNUM_TSKID];
    210 static int stack_pos[TNUM_TSKID];
    211 
    212 void __malloc_lock(struct _reent *a)
    213 {
    214         ID tskid;
     296int ff_cre_syncobj(BYTE vol, _SYNC_t* sobj)
     297{
     298        return 1;
     299}
     300
     301int ff_req_grant(_SYNC_t sobj)
     302{
    215303        ER ret;
    216         int count, sp;
    217 
    218         ret = get_tid(&tskid);
    219         if (ret != E_OK) {
    220                 /*syslog(LOG_DEBUG, "get_tid %s", itron_strerror(ret));*/
    221                 Asm("bkpt #0");
    222         }
    223 
    224         Asm("mov %0, sp" : "=r"(sp) :);
    225         if ((stack_pos[tskid - 1] == 0) || (stack_pos[tskid - 1] < sp))
    226                 stack_pos[tskid - 1] = sp;
    227 
    228         count = ++lock[tskid - 1];
    229         if (count != 1)
    230                 return;
    231 
    232         ret = wai_sem(SEM_MALLOC);
    233         if (ret != E_OK) {
    234                 /*syslog(LOG_DEBUG, "wai_sem %s", itron_strerror(ret));*/
    235                 Asm("bkpt #0");
    236         }
    237 }
    238 
    239 void __malloc_unlock(struct _reent *a)
    240 {
    241         ID tskid;
    242         ER ret;
    243         int count;
    244 
    245         ret = get_tid(&tskid);
    246         if (ret != E_OK) {
    247                 /*syslog(LOG_DEBUG, "get_tid %s", itron_strerror(ret));*/
    248                 Asm("bkpt #0");
    249         }
    250 
    251         count = --lock[tskid - 1];
    252         if(count != 0)
    253                 return;
    254 
    255         ret = sig_sem(SEM_MALLOC);
    256         if (ret != E_OK) {
    257                 /*syslog(LOG_DEBUG, "sig_sem %s", itron_strerror(ret));*/
    258                 Asm("bkpt #0");
    259         }
    260 }
    261 
    262 // Provide implementation of _sbrk (low-level dynamic memory allocation
    263 // routine) for GCC_ARM which compares new heap pointer with MSP instead of
    264 // SP.  This make it compatible with RTX RTOS thread stacks.
    265 
    266 // Linker defined symbol used by _sbrk to indicate where heap should start.
    267 int __end__;
    268 uint32_t  __HeapLimit;
    269 
    270 // Turn off the errno macro and use actual global variable instead.
    271 #undef errno
    272 int errno;
    273 
    274 static unsigned char* heap = (unsigned char*)&__end__;
    275 
    276 // Dynamic memory allocation related syscall.
    277 caddr_t _sbrk(int incr) {
    278         unsigned char*        prev_heap = heap;
    279         unsigned char*        new_heap = heap + incr;
    280 
    281         if (new_heap >= (unsigned char*)&__HeapLimit) {     /* __HeapLimit is end of heap section */
    282                 errno = ENOMEM;
    283                 return (caddr_t)-1;
    284         }
    285 
    286         heap = new_heap;
    287         return (caddr_t) prev_heap;
    288 }
    289 
    290 void reset_heap()
    291 {
    292         // .data
    293         extern uint8_t __malloc_av_[0x408];
    294         extern uint8_t __malloc_sbrk_base[0x4];
    295         extern uint8_t __malloc_trim_threshold[0x4];
    296         // .bss
    297         extern uint8_t __malloc_top_pad[0x4];
    298         extern uint8_t __malloc_current_mallinfo[0x28];
    299         extern uint8_t __malloc_max_sbrked_mem[0x4];
    300         extern uint8_t __malloc_max_total_mem[0x4];
    301         //
    302         extern void *__etext;
    303         extern void *__data_start__;
    304 
    305         int offset = (int)&__etext - (int)&__data_start__;
    306 
    307         __malloc_lock(_REENT);
    308 
    309         memcpy(__malloc_av_, &__malloc_av_[offset], sizeof(__malloc_av_));
    310         memcpy(__malloc_sbrk_base, &__malloc_sbrk_base[offset], sizeof(__malloc_sbrk_base));
    311         memcpy(__malloc_trim_threshold, &__malloc_trim_threshold[offset], sizeof(__malloc_trim_threshold));
    312 
    313         memset(__malloc_top_pad, 0, sizeof(__malloc_top_pad));
    314         memset(__malloc_current_mallinfo, 0, sizeof(__malloc_current_mallinfo));
    315         memset(__malloc_max_sbrked_mem, 0, sizeof(__malloc_max_sbrked_mem));
    316         memset(__malloc_max_total_mem, 0, sizeof(__malloc_max_total_mem));
    317 
    318         heap = (unsigned char*)&__end__;
    319 
    320         __malloc_unlock(_REENT);
    321 }
    322 
    323 void exit(int return_code) {
    324         Asm("bkpt #0");
    325         reset_heap();
    326         ext_tsk();
    327         for(;;);
    328 }
     304        ret = wai_sem(SEM_FILESYSTEM);
     305        return ret == E_OK;
     306}
     307
     308void ff_rel_grant(_SYNC_t sobj)
     309{
     310        sig_sem(SEM_FILESYSTEM);
     311}
     312
     313int ff_del_syncobj(_SYNC_t sobj)
     314{
     315        return 1;
     316}
     317
     318void* ff_memalloc (UINT msize)
     319{
     320        return sys_malloc(msize);
     321}
     322
     323void ff_memfree (void* mblock)
     324{
     325        sys_free(mblock);
     326}
  • EcnlProtoTool/trunk/ntshell/fatfs/ffarch.cfg

    r278 r279  
    5151 */
    5252
    53 #include "mruby_arduino.h"
     53#include "ffarch.h"
    5454
    55 CRE_CYC(SDFS_CYC, { TA_NULL, { TNFY_HANDLER, 0, sdfs_cychdr }, 1000, 0 });
     55CRE_CYC(SDFS_CYC, { TA_NULL, { TNFY_HANDLER, 0, sdfs_cychdr }, 1000000, 0 });
    5656
    5757CRE_SEM(SEM_MALLOC, { TA_TPRI, 1, 1 });
  • EcnlProtoTool/trunk/ntshell/fatfs/ffarch.h

    r278 r279  
    5454
    5555int mruby_arduino_init();
    56 void reset_heap();
    5756void sdfs_cychdr(intptr_t exinf);
    5857
  • EcnlProtoTool/trunk/ntshell/fatfs/ffconf.h

    r278 r279  
    6262/---------------------------------------------------------------------------*/
    6363
    64 #define _CODE_PAGE 437
     64#define _CODE_PAGE 65001
    6565/* This option specifies the OEM code page to be used on the target system.
    6666/  Incorrect setting of the code page can cause a file open failure.
     
    9191
    9292
    93 #define _USE_LFN        1
     93#define _USE_LFN        3
    9494#define _MAX_LFN        255
    9595/* The _USE_LFN option switches the LFN feature.
     
    227227
    228228
    229 #define _FS_REENTRANT   0
     229#define _FS_REENTRANT   1
    230230#define _FS_TIMEOUT             1000
    231 #define _SYNC_t                 HANDLE
     231#define _SYNC_t                 unsigned int
    232232/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
    233233/  module itself. Note that regardless of this option, file access to different
Note: See TracChangeset for help on using the changeset viewer.