2 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "exfat_config.h"
20 #include "exfat_global.h"
22 INT32 __wstrchr(UINT16 *str, UINT16 wchar)
25 if (*(str++) == wchar) return(1);
30 INT32 __wstrlen(UINT16 *str)
34 while (*(str++)) length++;
38 #define BITMAP_LOC(v) ((v) >> 3)
39 #define BITMAP_SHIFT(v) ((v) & 0x07)
41 void Bitmap_set_all(UINT8 *bitmap, INT32 mapsize)
43 MEMSET(bitmap, 0xFF, mapsize);
46 void Bitmap_clear_all(UINT8 *bitmap, INT32 mapsize)
48 MEMSET(bitmap, 0x0, mapsize);
51 INT32 Bitmap_test(UINT8 *bitmap, INT32 i)
55 data = bitmap[BITMAP_LOC(i)];
56 if ((data >> BITMAP_SHIFT(i)) & 0x01) return(1);
60 void Bitmap_set(UINT8 *bitmap, INT32 i)
62 bitmap[BITMAP_LOC(i)] |= (0x01 << BITMAP_SHIFT(i));
65 void Bitmap_clear(UINT8 *bitmap, INT32 i)
67 bitmap[BITMAP_LOC(i)] &= ~(0x01 << BITMAP_SHIFT(i));
70 void Bitmap_nbits_set(UINT8 *bitmap, INT32 offset, INT32 nbits)
74 for (i = 0; i < nbits; i++) {
75 Bitmap_set(bitmap, offset+i);
79 void Bitmap_nbits_clear(UINT8 *bitmap, INT32 offset, INT32 nbits)
83 for (i = 0; i < nbits; i++) {
84 Bitmap_clear(bitmap, offset+i);
88 void my_itoa(INT8 *buf, INT32 v)
93 for (i = 0; i < 10; i++) {
102 for (; i >= 0; i--) {
103 *buf = (UINT8) ('0' + mod[i]);
109 INT32 my_log2(UINT32 v)
114 if (v & 0x01) return(-1);