From: batt Date: Thu, 15 Nov 2007 22:53:45 +0000 (+0000) Subject: Add Page header for BattFS. X-Git-Tag: 1.0.0~243 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=71ef544fea9e991379181432011abb47166fec7b;hp=78b5f5c2bfcb60397ffbaff0ffc5c6d087898459;p=bertos.git Add Page header for BattFS. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@999 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/cpu/arm/drv/sysirq_at91.c b/cpu/arm/drv/sysirq_at91.c index 33e6b0cd..7b12af2d 100644 --- a/cpu/arm/drv/sysirq_at91.c +++ b/cpu/arm/drv/sysirq_at91.c @@ -98,12 +98,14 @@ static void sysirq_dispatcher(void) __attribute__ ((naked)); static void sysirq_dispatcher(void) { IRQ_ENTRY(); - for (unsigned i = 0; i < countof(sysirq_tab); i++) - { - if (sysirq_tab[i].enabled - && sysirq_tab[i].handler) - sysirq_tab[i].handler(); - } + + /* PIT */ + if ((PIT_MR & BV(PITIEN)) + && (PIT_SR & BV(PITS)) + && sysirq_tab[SYSIRQ_PIT].handler) + sysirq_tab[SYSIRQ_PIT].handler(); + + /* TODO: add other system sources here */ IRQ_EXIT(); } @@ -123,8 +125,8 @@ void sysirq_init(void) IRQ_SAVE_DISABLE(flags); /* Disable all system interrupts */ - for (unsigned i = 0; i < countof(sysirq_tab); i++) - sysirq_tab[i].setEnable(false); + PIT_MR &= BV(PITIEN); + /* TODO: add other system sources here */ /* Set the vector. */ AIC_SVR(SYSC_ID) = sysirq_dispatcher; diff --git a/fs/battfs.h b/fs/battfs.h new file mode 100644 index 00000000..0449d4f1 --- /dev/null +++ b/fs/battfs.h @@ -0,0 +1,81 @@ +/** + * \file + * + * + * \version $Id:$ + * + * \author Francesco Sacchi + * + * \brief BattFS: a filesystem for embedded platforms (interface). + */ + +#ifndef FS_BATTFS_H +#define FS_BATTFS_H + +#include // uintXX_t; STATIC_ASSERT + +/** + * BattFS page header. + * \note fields order is chosen to comply with alignment. + */ +typedef struct BattFsPageHeader +{ + uint16_t filled; ///< filled bytes in page. + uint16_t page_off; ///< Page offset inside file. + uint8_t inode; ///< File inode (file identifier). + uint8_t seqnum; ///< bit[1:0]: Page sequence number; bit[7:2] unused for now, must be set to 1. + uint16_t crc; ///< CRC of the page header. +} BattFsPageHeader; + +STATIC_ASSERT(sizeof(BattFsPageHeader) == 8); + +/** + * Reset page sequence number of struct \a m to default value (0xFF). + */ +#define RESET_SEQ(m) ((m).seqnum = 0xFF) + +/** + * Get page sequence number from struct \a m. + */ +#define SEQ(m) ((m).seqnum & 0x03) + +/** + * Set sequence number of struct \a m to \a d. + */ +#define SET_SEQ(m, d) ((m).seqnum = ((m).seqnum & 0xFC) | ((d) & 0x03)) + +/** + * Increment sequence number of struct \a m. + */ +#define INC_SEQ(m) SET_SEQ((m), SEQ(m) + 1) + + +#endif /* FS_BATTFS_H */