Compare commits

...

4 Commits

Author SHA1 Message Date
Sebastian Huber
0e83de9c9f Merge branch 'build-provide-ldflags-6.2' into '6'
build: Provide LDFLAGS for pkg-config

See merge request rtems/rtos/rtems!424
2025-11-15 01:59:03 +00:00
Kinsey Moore
23accdc0bb cpukit/flashdev: Return error for missing callbacks
When a callback does not exist, the Flashdev API should return error
where possible instead of success. When the API returns success for
missing callbacks, the Flashdev API client code may end up using
uninitialized variables as if they were filled by the API.

Closes #5392
2025-11-10 12:36:33 -06:00
Kinsey Moore
2c8973005d bsps/shared/xqspi_flash.c: Add support for sector information
Updates #5392
2025-11-10 12:35:56 -06:00
Sebastian Huber
3e90c37861 build: Provide LDFLAGS for pkg-config
Some pkg-config variants perform transformations on the --libs options.
This may lead to completely broken linker options:

https://github.com/pkgconf/pkgconf/issues/371

Provide the LDFLAGS as a variable.  Do not add the ABI_FLAGS to LDFLAGS
since they are already contained in the CFLAGS.  The linker command line
should include the compiler flags so that link-time optimization works
properly.

Update #5165.
2025-07-02 14:25:39 -04:00
3 changed files with 40 additions and 15 deletions

View File

@@ -99,6 +99,28 @@ static int xqspi_page_count(
return 0;
}
static int xqspi_sector_count(
rtems_flashdev *flash,
int *sector_count
)
{
*sector_count = QspiPsu_NOR_Get_Device_Size(flash->driver) /
QspiPsu_NOR_Get_Sector_Size(flash->driver);
return 0;
}
static int xqspi_sector_info_by_off(
rtems_flashdev *flash,
off_t search_offset,
off_t *sector_offset,
size_t *sector_size
)
{
*sector_size = QspiPsu_NOR_Get_Sector_Size(flash->driver);
*sector_offset = search_offset - (search_offset%((off_t)(*sector_size)));
return 0;
}
static int xqspi_write_block_size(
rtems_flashdev *flash,
size_t *write_block_size
@@ -177,6 +199,8 @@ rtems_flashdev* xqspi_flash_init(XQspiPsu *xQspiDev)
flash->page_info_by_index = &xqspi_page_info_by_index;
flash->page_count = &xqspi_page_count;
flash->write_block_size = &xqspi_write_block_size;
flash->sector_count = &xqspi_sector_count;
flash->sector_info_by_offset = &xqspi_sector_info_by_off;
flash->region_table = ftable;
return flash;

View File

@@ -104,7 +104,7 @@ static uint32_t rtems_flashdev_ioctl_jedec_id(
rtems_flashdev *flash
);
static uint32_t rtems_flashdev_ioctl_flash_type(
static int rtems_flashdev_ioctl_flash_type(
rtems_flashdev *flash,
void *arg
);
@@ -734,7 +734,7 @@ static int rtems_flashdev_ioctl_erase(
int status;
if ( flash->erase == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
}
erase_args_1 = (rtems_flashdev_region *) arg;
@@ -890,14 +890,14 @@ static uint32_t rtems_flashdev_ioctl_jedec_id( rtems_flashdev *flash )
}
}
static uint32_t rtems_flashdev_ioctl_flash_type(
static int rtems_flashdev_ioctl_flash_type(
rtems_flashdev *flash,
void *arg
)
{
rtems_flashdev_flash_type *type = (rtems_flashdev_flash_type*)arg;
if ( flash->flash_type == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
return ( *flash->flash_type )( flash, type );
}
@@ -914,7 +914,7 @@ static int rtems_flashdev_ioctl_pageinfo_offset(
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->page_info_by_offset == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
page_info = (rtems_flashdev_ioctl_page_info *) arg;
return ( *flash->page_info_by_offset )( flash,
@@ -933,7 +933,7 @@ static int rtems_flashdev_ioctl_pageinfo_index( rtems_flashdev *flash,
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->page_info_by_index == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
page_info = (rtems_flashdev_ioctl_page_info *) arg;
return ( *flash->page_info_by_index )( flash,
@@ -949,7 +949,7 @@ static int rtems_flashdev_ioctl_page_count( rtems_flashdev *flash, void *arg )
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->page_count == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
return ( *flash->page_count )( flash, ( (int *) arg ) );
}
@@ -964,7 +964,7 @@ static int rtems_flashdev_ioctl_write_block_size(
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->write_block_size == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
return ( *flash->write_block_size )( flash, ( (size_t *) arg ) );
}
@@ -981,7 +981,7 @@ static int rtems_flashdev_ioctl_sectorinfo_offset(
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->sector_info_by_offset == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
sector_info = (rtems_flashdev_ioctl_sector_info *) arg;
return ( *flash->sector_info_by_offset )( flash,
@@ -997,7 +997,7 @@ static int rtems_flashdev_ioctl_sector_count( rtems_flashdev *flash, void *arg )
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->sector_count == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
return ( *flash->sector_count )( flash, ( (int *) arg ) );
}
@@ -1048,7 +1048,7 @@ static int rtems_flashdev_ioctl_oob_bytes_per_page(
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->oob_bytes_per_page == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
return ( *flash->oob_bytes_per_page )( flash, ( (size_t *) arg ) );
}
@@ -1061,7 +1061,7 @@ static int rtems_flashdev_ioctl_oob_read( rtems_flashdev *flash, void *arg )
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->oob_read == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
rw_info = (rtems_flashdev_ioctl_oob_rw_info *) arg;
return ( *flash->oob_read )(
@@ -1160,7 +1160,7 @@ static int rtems_flashdev_ioctl_oob_write( rtems_flashdev *flash, void *arg )
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->oob_write == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
rw_info = (rtems_flashdev_ioctl_oob_rw_info *) arg;
return ( *flash->oob_write )(
@@ -1199,7 +1199,7 @@ static int rtems_flashdev_ioctl_sector_mark_bad(
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->sector_mark_bad == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
return ( *flash->sector_mark_bad)( flash, *(uintptr_t *) arg );
}
@@ -1235,7 +1235,7 @@ static int rtems_flashdev_ioctl_sectorhealth(
rtems_set_errno_and_return_minus_one( EINVAL );
}
if ( flash->sector_health == NULL ) {
return 0;
rtems_set_errno_and_return_minus_one( ENOSYS );
} else {
sector_health = arg;
return ( *flash->sector_health)( flash, sector_health->location, &sector_health->sector_bad );

View File

@@ -13,6 +13,7 @@ content: |
includedir=$${libdir}/include
ABI_FLAGS=${ABI_FLAGS}
LDFLAGS=-B$${libdir} ${PKGCONFIG_LDFLAGS}
RTEMS_ARCH=${ARCH}
RTEMS_BSP=${BSP_NAME}
RTEMS_BSP_BASE=${BSP_BASE}