Operating System
fsutilities.h
Go to the documentation of this file.
1 #ifndef __FS_UTILITIES_H_
2 #define __FS_UTILITIES_H_
3 #include <stdint.h>
4 #define lgsector2sector(X) (((X-1)%18)+1)
5 #define lgsector2head(X) (((X-1)/18)%2)
6 #define lgsector2track(X) ((X-1)/36)
7 void loadSector(uint16_t track, uint16_t head, uint16_t sector, uint16_t addr, uint16_t num);
8 static inline void loadLogicSector(uint16_t lgsector, uint16_t addr, uint16_t num) {
9  uint16_t sectorN = lgsector2sector(lgsector);
10  uint16_t headN = lgsector2head(lgsector);
11  uint16_t trackN = lgsector2track(lgsector);
12  loadSector(trackN, headN, sectorN, addr, num);
13 }
14 
15 #define filesize2sectors(X) ((X+511)/512)
16 
20 static inline int16_t __fs_strcmp(const char* s1, const char* s2) {
21  const char* lhs = s1;
22  const char* rhs = s2;
23  while (*lhs && *rhs) {
24  if (*lhs != * rhs) {
25  return *lhs - *rhs;
26  }
27  lhs++;
28  rhs++;
29  }
30  return *lhs - *rhs;
31 }
32 
33 
34 #endif
void loadSector(uint16_t track, uint16_t head, uint16_t sector, uint16_t addr, uint16_t num)
static void loadLogicSector(uint16_t lgsector, uint16_t addr, uint16_t num)
Definition: fsutilities.h:8
static int16_t __fs_strcmp(const char *s1, const char *s2)
Definition: fsutilities.h:20
#define lgsector2sector(X)
logic sector to sector
Definition: fsutilities.h:4
#define lgsector2track(X)
logic sector 2 track
Definition: fsutilities.h:6
#define lgsector2head(X)
logic sector to head
Definition: fsutilities.h:5