Skip to content

Commit ab43881

Browse files
committed
Internal optimizations
1 parent d950d23 commit ab43881

8 files changed

Lines changed: 123 additions & 51 deletions

File tree

doxyfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "Stratify OS"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 3.7.0
41+
PROJECT_NUMBER = 4.0.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a
@@ -1078,7 +1078,7 @@ IGNORE_PREFIX =
10781078
# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
10791079
# The default value is: YES.
10801080

1081-
GENERATE_HTML = NO
1081+
GENERATE_HTML = YES
10821082

10831083
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
10841084
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1622,7 +1622,7 @@ EXTRA_SEARCH_MAPPINGS =
16221622
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
16231623
# The default value is: YES.
16241624

1625-
GENERATE_LATEX = NO
1625+
GENERATE_LATEX = YES
16261626

16271627
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
16281628
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1793,7 +1793,7 @@ LATEX_TIMESTAMP = NO
17931793
# readers/editors.
17941794
# The default value is: NO.
17951795

1796-
GENERATE_RTF = NO
1796+
GENERATE_RTF = YES
17971797

17981798
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
17991799
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
@@ -1929,7 +1929,7 @@ XML_PROGRAMLISTING = YES
19291929
# that can be used to generate PDF.
19301930
# The default value is: NO.
19311931

1932-
GENERATE_DOCBOOK = NO
1932+
GENERATE_DOCBOOK = YES
19331933

19341934
# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
19351935
# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
@@ -1946,7 +1946,7 @@ DOCBOOK_OUTPUT = docbook
19461946
# The default value is: NO.
19471947
# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
19481948

1949-
DOCBOOK_PROGRAMLISTING = NO
1949+
DOCBOOK_PROGRAMLISTING = YES
19501950

19511951
#---------------------------------------------------------------------------
19521952
# Configuration options for the AutoGen Definitions output

include/device/drive_sdio.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99

1010
typedef struct {
1111
u32 flags;
12+
void *async_buffer;
13+
devfs_async_t *async;
14+
int bytes_read;
15+
int async_nbyte;
16+
mcu_event_handler_t async_handler;
1217
} drive_sdio_state_t;
1318

1419
typedef struct {
1520
devfs_device_t device;
21+
void * dma_read_buffer;
22+
u16 dma_read_buffer_size;
1623
} drive_sdio_config_t;
1724

1825
int drive_sdio_open(const devfs_handle_t *handle) MCU_ROOT_EXEC_CODE;
@@ -22,13 +29,4 @@ int drive_sdio_read(const devfs_handle_t *handle, devfs_async_t *rop) MCU_ROOT_E
2229
int drive_sdio_write(const devfs_handle_t *handle, devfs_async_t *wop) MCU_ROOT_EXEC_CODE;
2330
int drive_sdio_close(const devfs_handle_t *handle);
2431

25-
int drive_sdio_dma_open(const devfs_handle_t *handle) MCU_ROOT_EXEC_CODE;
26-
int drive_sdio_dma_ioctl(const devfs_handle_t *handle, int request, void *ctl)
27-
MCU_ROOT_EXEC_CODE;
28-
int drive_sdio_dma_read(const devfs_handle_t *handle, devfs_async_t *rop)
29-
MCU_ROOT_EXEC_CODE;
30-
int drive_sdio_dma_write(const devfs_handle_t *handle, devfs_async_t *wop)
31-
MCU_ROOT_EXEC_CODE;
32-
int drive_sdio_dma_close(const devfs_handle_t *handle) MCU_ROOT_EXEC_CODE;
33-
3432
#endif /* DEVICE_SD_SPI_H_ */

include/sos/dev/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ typedef enum {
110110
CORE_PERIPH_DFSDM /*! DFSDM Pins */,
111111
CORE_PERIPH_FMP_I2C /*! Fast Mode Plus I2C */,
112112
CORE_PERIPH_DCMI /*! Digital Camera interface */,
113+
CORE_PERIPH_OCTOSPI /*! Digital Camera interface */,
113114
CORE_PERIPH_TOTAL
114115
} core_periph_t;
115116

include/sos/dev/netif.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,46 +17,49 @@
1717
#ifndef SOS_DEV_NETIF_H_
1818
#define SOS_DEV_NETIF_H_
1919

20-
#include <sdk/types.h>
2120
#include "sos/link/types.h"
21+
#include <sdk/types.h>
2222

2323
#define NETIF_VERSION (0x030100)
2424
#define NETIF_IOC_CHAR 'N'
2525

2626
#define NETIF_MAX_MAC_ADDRESS_SIZE 16
2727

2828
enum {
29-
NETIF_FLAG_INIT /*! When setting attributes, initializes the interface */ = (1<<0),
30-
NETIF_FLAG_DEINIT /*! When setting attributes, de-initialies the interface */ = (1<<1),
31-
NETIF_FLAG_IS_LINK_UP /*! When settings attributes, ioctl() return 1 if link is up */ = (1<<2),
32-
NETIF_FLAG_SET_LINK_UP /*! When setting attributes, sets the link as up */ = (1<<3),
33-
NETIF_FLAG_SET_LINK_DOWN /*! When setting attributes, sets the link as down */ = (1<<4),
34-
NETIF_FLAG_SET_MAC_ADDRESS /*! Sets the MAC address populated by I_NETIF_GETINFO */ = (1<<5),
35-
NETIF_FLAG_IS_BROADCAST = (1<<6),
36-
NETIF_FLAG_IS_ETHERNET = (1<<7),
37-
NETIF_FLAG_IS_ETHERNET_ARP = (1<<8),
38-
NETIF_FLAG_IS_IGMP = (1<<9),
39-
NETIF_FLAG_IS_MLD6 = (1<<10),
29+
NETIF_FLAG_INIT /*! When setting attributes, initializes the interface */ = (1 << 0),
30+
NETIF_FLAG_DEINIT /*! When setting attributes, de-initialies the interface */ =
31+
(1 << 1),
32+
NETIF_FLAG_IS_LINK_UP /*! When settings attributes, ioctl() return 1 if link is up */ =
33+
(1 << 2),
34+
NETIF_FLAG_SET_LINK_UP /*! When setting attributes, sets the link as up */ = (1 << 3),
35+
NETIF_FLAG_SET_LINK_DOWN /*! When setting attributes, sets the link as down */ =
36+
(1 << 4),
37+
NETIF_FLAG_SET_MAC_ADDRESS /*! Sets the MAC address populated by I_NETIF_GETINFO */ =
38+
(1 << 5),
39+
NETIF_FLAG_IS_BROADCAST = (1 << 6),
40+
NETIF_FLAG_IS_ETHERNET = (1 << 7),
41+
NETIF_FLAG_IS_ETHERNET_ARP = (1 << 8),
42+
NETIF_FLAG_IS_IGMP = (1 << 9),
43+
NETIF_FLAG_IS_MLD6 = (1 << 10),
4044
};
4145

4246
typedef struct MCU_PACK {
43-
u32 o_flags;
44-
u32 o_events;
45-
u8 mac_address[NETIF_MAX_MAC_ADDRESS_SIZE];
46-
u8 mac_address_length;
47-
u8 resd;
48-
u16 mtu;
47+
u32 o_flags;
48+
u32 o_events;
49+
u8 mac_address[NETIF_MAX_MAC_ADDRESS_SIZE];
50+
u8 mac_address_length;
51+
u8 resd;
52+
u16 mtu;
4953
} netif_info_t;
5054

5155
/*! \brief Network Interface attributes
5256
*/
5357
typedef struct MCU_PACK {
54-
u32 o_flags;
55-
u16 mtu;
56-
u8 mac_address[NETIF_MAX_MAC_ADDRESS_SIZE];
58+
u32 o_flags;
59+
u16 mtu;
60+
u8 mac_address[NETIF_MAX_MAC_ADDRESS_SIZE];
5761
} netif_attr_t;
5862

59-
6063
#define I_NETIF_GETVERSION _IOCTL(NETIF_IOC_CHAR, I_MCU_GETVERSION)
6164

6265
/*! \brief See below for details.

include/sos/dev/pwm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ typedef struct MCU_PACK {
9090
*/
9191
#define I_PWM_SETCHANNEL _IOCTLW(PWM_IOC_IDENT_CHAR, I_MCU_TOTAL + 0, mcu_channel_t)
9292
#define I_PWM_GETCHANNEL _IOCTLRW(PWM_IOC_IDENT_CHAR, I_MCU_TOTAL + 1, mcu_channel_t)
93-
#define I_PWM_SET _IOCTL(TMR_IOC_IDENT_CHAR, I_MCU_TOTAL + 2)
94-
#define I_PWM_GET _IOCTL(TMR_IOC_IDENT_CHAR, I_MCU_TOTAL + 3)
93+
#define I_PWM_SET _IOCTL(PWM_IOC_IDENT_CHAR, I_MCU_TOTAL + 2)
94+
#define I_PWM_GET _IOCTL(PWM_IOC_IDENT_CHAR, I_MCU_TOTAL + 3)
9595
#define I_PWM_ENABLE _IOCTL(PWM_IOC_IDENT_CHAR, I_MCU_TOTAL + 4)
9696
#define I_PWM_DISABLE _IOCTL(PWM_IOC_IDENT_CHAR, I_MCU_TOTAL + 5)
9797

src/boot/boot_main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ void boot_invoke_bootloader(void *args) {
2323
*bootloader_software_request_address =
2424
sos_config.boot.software_bootloader_request_value;
2525

26+
sos_config.cache.clean_data();
2627
cortexm_reset(0);
2728
}
2829

2930
void sos_handle_event(int event, void *args) {
30-
if (sos_config.event_handler != NULL) {
31-
sos_config.event_handler(event, args);
32-
}
31+
sos_config.event_handler(event, args);
3332
}
3433

3534
extern u32 _etext;

src/device/drive_sdio.c

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,90 @@
1212
#include "cortexm/task.h"
1313

1414
int drive_sdio_open(const devfs_handle_t *handle) {
15-
const drive_sdio_config_t *config = handle->config;
15+
DEVFS_DRIVER_DECLARE_CONFIG(drive_sdio);
1616
return config->device.driver.open(&config->device.handle);
1717
}
1818

19+
static int handle_misaligned_read_complete(void *context, const mcu_event_t *event) {
20+
MCU_UNUSED_ARGUMENT(event);
21+
const devfs_handle_t *handle = context;
22+
DEVFS_DRIVER_DECLARE_CONFIG_STATE(drive_sdio);
23+
24+
// copy the data to the original buffer
25+
memcpy(
26+
(u8 *)state->async_buffer + state->bytes_read, config->dma_read_buffer,
27+
state->async->nbyte);
28+
29+
state->bytes_read += state->async->nbyte;
30+
31+
int result = 0;
32+
33+
if (state->bytes_read < state->async_nbyte) {
34+
// read another block
35+
result = config->device.driver.read(&config->device.handle, state->async);
36+
} else {
37+
// finalize the transaction
38+
result = state->async_nbyte;
39+
}
40+
41+
if (result != 0) {
42+
// restore the async object
43+
state->async->buf = state->async_buffer;
44+
state->async->nbyte = state->async_nbyte;
45+
state->async->handler = state->async_handler;
46+
47+
// mark as not busy
48+
state->async_handler.callback = 0;
49+
state->async->result = result;
50+
51+
if (result < 0) {
52+
devfs_execute_event_handler(
53+
&state->async->handler, MCU_EVENT_FLAG_ERROR | MCU_EVENT_FLAG_CANCELED, 0);
54+
} else {
55+
devfs_execute_event_handler(&state->async->handler, MCU_EVENT_FLAG_DATA_READY, 0);
56+
}
57+
58+
return 0;
59+
}
60+
}
61+
1962
int drive_sdio_read(const devfs_handle_t *handle, devfs_async_t *async) {
20-
const drive_sdio_config_t *config = handle->config;
63+
DEVFS_DRIVER_DECLARE_CONFIG_STATE(drive_sdio);
64+
if (config->dma_read_buffer) {
65+
if (state->async_handler.callback != 0) {
66+
return SYSFS_SET_RETURN(EBUSY);
67+
}
68+
69+
if ((u32)async->buf % 32) {
70+
// can't have misaligned reads -- need to use the dedicated buffer
71+
// save the originals
72+
state->async_buffer = async->buf;
73+
state->async_handler = async->handler;
74+
state->async_nbyte = async->nbyte;
75+
state->bytes_read = 0;
76+
state->async = async;
77+
78+
// re-route the async object to use the aligned DMA buffer
79+
async->buf = config->dma_read_buffer;
80+
async->handler.callback = handle_misaligned_read_complete;
81+
async->handler.context = (void *)handle;
82+
83+
// adjust the size accordingly
84+
if (async->nbyte > config->dma_read_buffer_size) {
85+
async->nbyte = config->dma_read_buffer_size;
86+
}
87+
}
88+
}
2189
return config->device.driver.read(&config->device.handle, async);
2290
}
2391

2492
int drive_sdio_write(const devfs_handle_t *handle, devfs_async_t *async) {
25-
const drive_sdio_config_t *config = handle->config;
93+
DEVFS_DRIVER_DECLARE_CONFIG(drive_sdio);
2694
return config->device.driver.write(&config->device.handle, async);
2795
}
2896

2997
int drive_sdio_ioctl(const devfs_handle_t *handle, int request, void *ctl) {
30-
const drive_sdio_config_t *config = handle->config;
98+
DEVFS_DRIVER_DECLARE_CONFIG(drive_sdio);
3199
drive_info_t *info = ctl;
32100
drive_attr_t *attr = ctl;
33101
u32 o_flags;
@@ -103,7 +171,7 @@ int drive_sdio_ioctl(const devfs_handle_t *handle, int request, void *ctl) {
103171
}
104172

105173
int drive_sdio_close(const devfs_handle_t *handle) {
106-
const drive_sdio_config_t *config = handle->config;
174+
DEVFS_DRIVER_DECLARE_CONFIG(drive_sdio);
107175
return config->device.driver.close(&config->device.handle);
108176
}
109177

src/sys/sysfs/assetfs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ typedef struct {
2424
u32 checksum;
2525
} assetfs_handle_t;
2626

27-
int assetfs_init(const void *cfg) {
27+
int assetfs_init(const void *config) {
28+
MCU_UNUSED_ARGUMENT(config);
2829
// nothing to initialize
2930
return 0;
3031
}
@@ -33,8 +34,8 @@ static int get_directory_entry(const void *cfg, int loc, const assetfs_dirent_t
3334
static const assetfs_dirent_t *find_file(const void *cfg, const char *path, int *ino);
3435
static void assign_stat(int ino, const assetfs_dirent_t *entry, struct stat *st);
3536

36-
int assetfs_startup(const void *cfg) {
37-
// check for any applications that are embedded and start them?
37+
int assetfs_startup(const void *config) {
38+
MCU_UNUSED_ARGUMENT(config);
3839
return 0;
3940
}
4041

@@ -153,6 +154,7 @@ void assign_stat(int ino, const assetfs_dirent_t *entry, struct stat *st) {
153154
}
154155

155156
int assetfs_opendir(const void *cfg, void **handle, const char *path) {
157+
MCU_UNUSED_ARGUMENT(cfg);
156158
if (strncmp(path, "", PATH_MAX) == 0) {
157159
*handle = VALID_DIR_HANDLE;
158160
} else {
@@ -179,6 +181,7 @@ int assetfs_readdir_r(const void *cfg, void *handle, int loc, struct dirent *ent
179181
}
180182

181183
int assetfs_closedir(const void *cfg, void **handle) {
184+
MCU_UNUSED_ARGUMENT(cfg);
182185
if (*handle != VALID_DIR_HANDLE) {
183186
return SYSFS_SET_RETURN(EINVAL);
184187
}
@@ -203,7 +206,7 @@ const assetfs_dirent_t *find_file(const void *cfg, const char *path, int *ino) {
203206

204207
int get_directory_entry(const void *cfg, int loc, const assetfs_dirent_t **entry) {
205208
const assetfs_config_t *config = cfg;
206-
const u32 count = config->count;
209+
const int count = config->count;
207210
if (loc < 0) {
208211
return SYSFS_SET_RETURN(EINVAL);
209212
}

0 commit comments

Comments
 (0)