Lines Matching defs:buf
61 #define FA_DIRTY 0x80 /* FIL.buf[] needs to be written-back */
654 TCHAR* buf, /* Output buffer */
665 *buf = wc;
669 *buf++ = hs;
670 *buf++ = wc;
678 *buf = (TCHAR)chr;
683 *buf++ = (TCHAR)(0xC0 | (chr >> 6 & 0x1F));
684 *buf++ = (TCHAR)(0x80 | (chr >> 0 & 0x3F));
689 *buf++ = (TCHAR)(0xE0 | (chr >> 12 & 0x0F));
690 *buf++ = (TCHAR)(0x80 | (chr >> 6 & 0x3F));
691 *buf++ = (TCHAR)(0x80 | (chr >> 0 & 0x3F));
700 *buf++ = (TCHAR)(0xF0 | (chr >> 18 & 0x07));
701 *buf++ = (TCHAR)(0x80 | (chr >> 12 & 0x3F));
702 *buf++ = (TCHAR)(0x80 | (chr >> 6 & 0x3F));
703 *buf++ = (TCHAR)(0x80 | (chr >> 0 & 0x3F));
716 *buf++ = (TCHAR)chr;
725 *buf++ = (char)(wc >> 8); /* Store DBC 1st byte */
726 *buf++ = (TCHAR)wc; /* Store DBC 2nd byte */
730 *buf++ = (TCHAR)wc; /* Store the character */
3449 fp->buf = (BYTE*) ff_memalloc(SS(fs)); /* Init sector buffer */
3450 if (fp->buf == NULL) {
3479 if (disk_read(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) res = FR_DISK_ERR;
3606 copy_ret = LOS_CopyFromKernel(rbuff + ((fp->sect - sect) * SS(fs)), SS(fs), fp->buf, SS(fs));
3609 mem_cpy(rbuff + ((fp->sect - sect) * SS(fs)), fp->buf, SS(fs));
3621 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
3625 if (disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */
3640 copy_ret = LOS_CopyFromKernel(rbuff, rcnt, fp->buf + fp->fptr % SS(fs), rcnt);
3643 mem_cpy(rbuff, fp->buf + fp->fptr % SS(fs), rcnt); /* Extract partial sector */
3718 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
3741 copy_ret = LOS_CopyToKernel(fp->buf, SS(fs), wbuff + ((fp->sect - sect) * SS(fs)), SS(fs));
3744 mem_cpy(fp->buf, wbuff + ((fp->sect - sect) * SS(fs)), SS(fs));
3761 disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK) {
3777 copy_ret = LOS_CopyToKernel(fp->buf + fp->fptr % SS(fs), wcnt, wbuff, wcnt);
3780 mem_cpy(fp->buf + fp->fptr % SS(fs), wbuff, wcnt); /* Fit data to the sector */
3814 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) LEAVE_FF(fs, FR_DISK_ERR);
4116 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
4120 if (disk_read(fs->pdrv, fp->buf, dsc, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Load current sector */
4192 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
4196 if (disk_read(fs->pdrv, fp->buf, nsect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR); /* Fill sector cache */
4578 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) {
4893 BYTE buf[SZDIRE], *dir;
4972 mem_cpy(buf, djo.dir, SZDIRE); /* Save directory entry of the object */
4982 mem_cpy(dir + 13, buf + 13, SZDIRE - 13);
4983 dir[DIR_Attr] = buf[DIR_Attr];
5522 if (disk_write(fs->pdrv, fp->buf, fp->sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
5526 if (disk_read(fs->pdrv, fp->buf, sect, 1) != RES_OK) ABORT(fs, FR_DISK_ERR);
5528 dbuf = fp->buf;
5557 BYTE* buf /* Working buffer for a sector */
5574 mem_set(buf, 0, FF_MAX_SS); /* Clear MBR */
5575 pte = buf + MBR_Table; /* Partition table in the MBR */
5603 st_word(buf + BS_55AA, 0xAA55); /* MBR signature */
5604 if (disk_write(drv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Write it to the MBR */
5620 BYTE *buf;
5679 buf = (BYTE*)work; /* Working buffer */
5685 if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */
5686 if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if MBR is valid */
5687 if (buf[MBR_Table + 4] != 0xEE) {
5688 pte = buf + (MBR_Table + (ipart - 1) * SZ_PTE);
5692 pte = &buf[MBR_Table + i * SZ_PTE];
5695 pte = &buf[MBR_Table + extended_pos * SZ_PTE];
5698 if (disk_raw_read(LD2DI(vol), buf, extended_base, 1) != RES_OK) return FR_DISK_ERR;
5700 if (disk_read(LD2PD(vol), buf, extended_base, 1) != RES_OK) return FR_DISK_ERR;
5702 pte = &buf[MBR_Table];
5704 pte = &buf[MBR_Table];
5706 mem_set(buf, 0, len);
5708 if (disk_raw_read(LD2DI(vol), buf, extended_base + extended_offset, 1) != RES_OK) return FR_DISK_ERR;
5710 if (disk_read(LD2PD(vol), buf, extended_base + extended_offset, 1) != RES_OK) return FR_DISK_ERR;
5726 if (disk_read(pdrv, buf, b_vol, 1) != RES_OK) return FR_DISK_ERR; /* Load GPT partition info */
5727 if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if GPT partition is valid */
5734 mem_cpy(multi_buf, buf, ss);
5843 mem_set(buf, 0, ss);
5844 mem_cpy(buf + BS_JmpBoot, "\xEB\xFE\x90" "MSDOS5.0", 11); /* Boot jump code (x86), OEM name */
5845 st_word(buf + BPB_BytsPerSec, ss); /* Sector size [byte] */
5846 buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */
5847 st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */
5848 buf[BPB_NumFATs] = (BYTE)n_fat; /* Number of FATs */
5849 st_word(buf + BPB_RootEntCnt, (WORD)((fsty == FS_FAT32) ? 0 : n_root)); /* Number of root directory entries */
5851 st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */
5853 st_dword(buf + BPB_TotSec32, (DWORD)sz_vol); /* Volume size in 32-bit LBA */
5855 buf[BPB_Media] = 0xF8; /* Media descriptor byte */
5856 st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */
5857 st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */
5858 st_dword(buf + BPB_HiddSec, (DWORD)b_vol); /* Volume offset in the physical drive [sector] */
5860 st_dword(buf + BS_VolID32, GET_FATTIME()); /* VSN */
5861 st_dword(buf + BPB_FATSz32, sz_fat); /* FAT size [sector] */
5862 st_dword(buf + BPB_RootClus32, 2); /* Root directory cluster # (2) */
5863 st_word(buf + BPB_FSInfo32, 1); /* Offset of FSINFO sector (VBR + 1) */
5864 st_word(buf + BPB_BkBootSec32, 6); /* Offset of backup VBR (VBR + 6) */
5865 buf[BS_DrvNum32] = 0x80; /* Drive number (for int13) */
5866 buf[BS_BootSig32] = 0x29; /* Extended boot signature */
5867 mem_cpy(buf + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */
5869 st_dword(buf + BS_VolID, GET_FATTIME()); /* VSN */
5870 st_word(buf + BPB_FATSz16, (WORD)sz_fat); /* FAT size [sector] */
5871 buf[BS_DrvNum] = 0x80; /* Drive number (for int13) */
5872 buf[BS_BootSig] = 0x29; /* Extended boot signature */
5873 mem_cpy(buf + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */
5875 st_word(buf + BS_55AA, 0xAA55); /* Signature (offset is fixed here regardless of sector size) */
5876 if (disk_write(pdrv, buf, b_vol, 1) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; } /* Write it to the VBR sector */
5880 disk_write(pdrv, buf, b_vol + 6, 1); /* Write backup VBR (VBR + 6) */
5881 mem_set(buf, 0, ss);
5882 st_dword(buf + FSI_LeadSig, 0x41615252);
5883 st_dword(buf + FSI_StrucSig, 0x61417272);
5884 st_dword(buf + FSI_Free_Count, n_clst - 1); /* Number of free clusters */
5885 st_dword(buf + FSI_Nxt_Free, 2); /* Last allocated cluster# */
5886 st_word(buf + BS_55AA, 0xAA55);
5887 disk_write(pdrv, buf, b_vol + 7, 1); /* Write backup FSINFO (VBR + 7) */
5888 disk_write(pdrv, buf, b_vol + 1, 1); /* Write original FSINFO (VBR + 1) */
5892 mem_set(buf, 0, sz_buf * ss);
5896 st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */
5897 st_dword(buf + 4, 0xFFFFFFFF); /* Entry 1 */
5898 st_dword(buf + 8, 0x0FFFFFFF); /* Entry 2 (root directory) */
5900 st_dword(buf + 0, (fsty == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */
5905 if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; }
5906 mem_set(buf, 0, ss); /* Rest of FAT all are cleared */
5915 if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; }
5923 mem_set(buf, 0, sz_buf * ss);
5924 if (disk_write(pdrv, buf, sect, 1) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; }
5978 fr = create_partition(pdrv, lba, sys, buf);
6010 BYTE fsopt, fsty, sys, *buf, *pte, pdrv, ipart;
6056 buf = (BYTE *)work; /* Working buffer */
6063 if (disk_read(pdrv, buf, 0, 1) != RES_OK) return FR_DISK_ERR; /* Load MBR */
6064 if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if MBR is valid */
6065 if (buf[MBR_Table + PTE_System] != GPT_PROTECTIVE_MBR) {
6066 pte = buf + (MBR_Table + (ipart - 1) * SZ_PTE);
6070 pte = &buf[MBR_Table + i * SZ_PTE];
6073 pte = &buf[MBR_Table + extended_pos * SZ_PTE];
6075 if (disk_raw_read(partition->disk_id, buf, extended_base, 1) != RES_OK) {
6078 pte = &buf[MBR_Table];
6080 pte = &buf[MBR_Table];
6082 mem_set(buf, 0, len);
6083 if (disk_raw_read(partition->disk_id, buf, extended_base + extended_offset, 1) != RES_OK) {
6092 if (disk_read(pdrv, buf, b_vol, 1) != RES_OK) return FR_DISK_ERR; /* Load GPT partition info */
6093 if (ld_word(buf + BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; /* Check if GPT partition is valid */
6100 mem_cpy(multi_buf, buf, ss);
6214 mem_set(buf, 0, ss);
6215 mem_cpy(buf + BS_JmpBoot, JUMP_CODE "MSDOS5.0", 11); /* Boot jump code (x86), OEM name */
6216 st_word(buf + BPB_BytsPerSec, ss); /* Sector size [byte] */
6217 buf[BPB_SecPerClus] = (BYTE)pau; /* Cluster size [sector] */
6218 st_word(buf + BPB_RsvdSecCnt, (WORD)sz_rsv); /* Size of reserved area */
6219 buf[BPB_NumFATs] = (BYTE)n_fat; /* Number of FATs */
6220 st_word(buf + BPB_RootEntCnt, (WORD)((fsty == FS_FAT32) ? 0 : n_root)); /* Number of root directory entries */
6222 st_word(buf + BPB_TotSec16, (WORD)sz_vol); /* Volume size in 16-bit LBA */
6224 st_dword(buf + BPB_TotSec32, (DWORD)sz_vol); /* Volume size in 32-bit LBA */
6226 buf[BPB_Media] = 0xF8; /* Media descriptor byte */
6227 st_word(buf + BPB_SecPerTrk, 63); /* Number of sectors per track (for int13) */
6228 st_word(buf + BPB_NumHeads, 255); /* Number of heads (for int13) */
6229 st_dword(buf + BPB_HiddSec, (DWORD)b_vol); /* Volume offset in the physical drive [sector] */
6231 st_dword(buf + BS_VolID32, GET_FATTIME()); /* VSN */
6232 st_dword(buf + BPB_FATSz32, sz_fat); /* FAT size [sector] */
6233 st_dword(buf + BPB_RootClus32, 2); /* Root directory cluster # (2) */
6234 st_word(buf + BPB_FSInfo32, 1); /* Offset of FSINFO sector (VBR + 1) */
6235 st_word(buf + BPB_BkBootSec32, 6); /* Offset of backup VBR (VBR + 6) */
6236 buf[BS_DrvNum32] = 0x80; /* Drive number (for int13) */
6237 buf[BS_BootSig32] = 0x29; /* Extended boot signature */
6238 mem_cpy(buf + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */
6240 st_dword(buf + BS_VolID, GET_FATTIME()); /* VSN */
6241 st_word(buf + BPB_FATSz16, (WORD)sz_fat); /* FAT size [sector] */
6242 buf[BS_DrvNum] = 0x80; /* Drive number (for int13) */
6243 buf[BS_BootSig] = 0x29; /* Extended boot signature */
6244 mem_cpy(buf + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */
6246 st_word(buf + BS_55AA, 0xAA55); /* Signature (offset is fixed here regardless of sector size) */
6247 if (disk_write(pdrv, buf, b_vol, 1) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; } /* Write it to the VBR sector */
6251 disk_write(pdrv, buf, b_vol + 6, 1); /* Write backup VBR (VBR + 6) */
6252 mem_set(buf, 0, ss);
6253 st_dword(buf + FSI_LeadSig, 0x41615252);
6254 st_dword(buf + FSI_StrucSig, 0x61417272);
6255 st_dword(buf + FSI_Free_Count, n_clst - 1); /* Number of free clusters */
6256 st_dword(buf + FSI_Nxt_Free, 2); /* Last allocated cluster# */
6257 st_word(buf + BS_55AA, 0xAA55);
6258 disk_write(pdrv, buf, b_vol + 7, 1); /* Write backup FSINFO (VBR + 7) */
6259 disk_write(pdrv, buf, b_vol + 1, 1); /* Write original FSINFO (VBR + 1) */
6264 mem_set(buf, 0, sz_buf * ss);
6268 st_dword(buf + 0, 0xFFFFFFF8); /* Entry 0 */
6269 st_dword(buf + 4, DISK_ERROR); /* Entry 1 */
6270 st_dword(buf + 8, FAT32_END_OF_CLUSTER); /* Entry 2 (root directory) */
6272 st_dword(buf + 0, (fsty == FS_FAT12) ? 0xFFFFF8 : 0xFFFFFFF8); /* Entry 0 and 1 */
6277 if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; }
6278 mem_set(buf, 0, ss); /* Rest of FAT all are cleared */
6288 if (disk_write(pdrv, buf, sect, (UINT)n) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; }
6296 mem_set(buf, 0, sz_buf * ss);
6297 if (disk_write(pdrv, buf, sect, 1) != RES_OK) { fr = FR_DISK_ERR; goto EXIT; }
6349 fr = create_partition(pdrv, lba, sys, buf);
6389 BYTE *buf = (BYTE*)work;
6399 if (!buf) return FR_NOT_ENOUGH_CORE;
6406 res = create_partition(pdrv, ptbl, 0x07, buf); /* Create partitions (system ID is temporary setting and determined by f_mkfs) */
6564 int idx, nchr; /* Write index of buf[] (-1:error), number of encoding units written */
6571 BYTE buf[SZ_PUTC_BUF]; /* Write buffer */
6593 i = pb->idx; /* Write index of pb->buf[] */
6646 st_word(&pb->buf[i], hs);
6650 st_word(&pb->buf[i], wc);
6654 pb->buf[i++] = (BYTE)(hs >> 8);
6655 pb->buf[i++] = (BYTE)hs;
6658 pb->buf[i++] = (BYTE)(wc >> 8);
6659 pb->buf[i++] = (BYTE)wc;
6664 pb->buf[i++] = (BYTE)(0xF0 | hs >> 8);
6665 pb->buf[i++] = (BYTE)(0x80 | (hs >> 2 & 0x3F));
6666 pb->buf[i++] = (BYTE)(0x80 | (hs & 3) << 4 | (wc >> 6 & 0x0F));
6667 pb->buf[i++] = (BYTE)(0x80 | (wc & 0x3F));
6670 pb->buf[i++] = (BYTE)wc;
6674 pb->buf[i++] = (BYTE)(0xC0 | wc >> 6);
6677 pb->buf[i++] = (BYTE)(0xE0 | wc >> 12);
6678 pb->buf[i++] = (BYTE)(0x80 | (wc >> 6 & 0x3F));
6680 pb->buf[i++] = (BYTE)(0x80 | (wc & 0x3F));
6688 pb->buf[i++] = (BYTE)(wc >> 8); nc++;
6690 pb->buf[i++] = (BYTE)wc;
6694 pb->buf[i++] = (BYTE)c;
6697 if (i >= (int)(sizeof pb->buf) - 4) { /* Write buffered characters to the file */
6698 f_write(pb->fp, pb->buf, (UINT)i, &n);
6713 && f_write(pb->fp, pb->buf, (UINT)pb->idx, &nw) == FR_OK