Compare commits

...

6 commits

Author SHA1 Message Date
Keir Fraser
7fff3e451e Update to v2.14 2019-12-27 13:16:12 +00:00
Keir Fraser
888970a9d7 Fix strcmp() build on gcc-9.2.0 2019-12-27 07:54:45 +00:00
Keir Fraser
3e459c9d54 Remove double underscore prefix from __packed and __aligned() definitions.
It is polluting the GCC namespace and breaks the build with GCC v9.
2019-12-27 07:53:51 +00:00
Keir Fraser
8d42b1b8de usb: Fix buffer overflow when parsing USB string descriptors.
This was triggered by a very-long-indeed SanDisk Ultra Fit serial nr.
2019-12-27 07:51:39 +00:00
Keir Fraser
34beef28a9 HxC_Compat: Update to v8-FF
Fixes startup crash on Atari ST: Clears BSS region
2019-12-27 07:50:38 +00:00
Keir Fraser
cd73a4873d img: Fix outp_hden for high-density images.
write_bc_ticks has not been initialised early enough since v2.2a
Refs #290
Refs #301
2019-12-27 07:41:04 +00:00
14 changed files with 55 additions and 50 deletions

View file

@ -1,5 +1,5 @@
export FW_VER := 2.13
export FW_VER := 2.14
PROJ := FlashFloppy
VER := v$(FW_VER)
@ -29,7 +29,7 @@ gotek: all
HXC_FF_URL := https://www.github.com/keirf/HxC_FF_File_Selector
HXC_FF_URL := $(HXC_FF_URL)/releases/download
HXC_FF_VER := v6-FF
HXC_FF_VER := v8-FF
dist:
rm -rf flashfloppy-*

View file

@ -3,6 +3,15 @@
** Keir Fraser <keir.xen@gmail.com>
************************************
** v2.14 - 27 December 2019
- IMG: Fix density-select pin output for HD images
- Fixes 'pin02=dens' and 'interface=ibmpc-hdout'
- Bug has existed since v2.2a
- HxC Compat, v8-FF: Fixes startup crash on Atari ST
- USB: Fix buffer overflow when parsing string descriptors
- Fixes crash with recent SanDisk Ultra Fit drives
- GCC9 build fixes
** v2.13 - 7 June 2019
- HFE: Fix read buffering error
- Update HxC Compat to v6-FF

View file

@ -25,7 +25,7 @@ int get_next_opt(struct opts *opts);
#define OPT_section -2
/* FF.CFG options structure. */
struct __packed ff_cfg {
struct packed ff_cfg {
/* Bump version for every incompatible change to structure layout.
* No need to bump for new fields appended to this structure. */
#define FFCFG_VERSION 2

View file

@ -14,7 +14,7 @@
#define DA_DD_MFM_CYL (DA_FIRST_CYL + 1)
/* Direct-Access Mode: Returned in sector 0 of direct-access track. */
struct __packed da_status_sector {
struct packed da_status_sector {
char sig[8];
char fw_ver[12];
uint32_t lba_base;
@ -32,7 +32,7 @@ struct __packed da_status_sector {
};
/* Direct-Access Mode: Sent to us in sector 0 of direct-access track. */
struct __packed da_cmd_sector {
struct packed da_cmd_sector {
char sig[8];
uint8_t cmd;
uint8_t param[8];

View file

@ -13,6 +13,7 @@
#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <limits.h>
#include "stm32f10x_regs.h"
#include "stm32f10x.h"

View file

@ -10,7 +10,7 @@
*/
/* HXCSDFE.CFG file header. */
struct __packed hxcsdfe_cfg {
struct packed hxcsdfe_cfg {
char signature[16]; /* "HXCFECFGVx.y" */
uint8_t step_sound;
uint8_t ihm_sound;
@ -27,7 +27,7 @@ struct __packed hxcsdfe_cfg {
uint8_t startup_mode;
uint8_t enable_drive_b;
uint8_t index_mode;
struct __packed {
struct packed {
uint8_t cfg_from_cfg;
uint8_t interfacemode;
uint8_t pin02_cfg;
@ -47,7 +47,7 @@ struct __packed hxcsdfe_cfg {
#define HXCSTARTUP_ejected 0x10
/* HXCFECFGV1.x slots start at offset 0x400: */
struct __packed v1_slot {
struct packed v1_slot {
char name[12];
uint8_t attributes;
uint32_t firstCluster;
@ -56,7 +56,7 @@ struct __packed v1_slot {
};
/* HXCFECFGV2.x slots start at sector offset 'slots_position': */
struct __packed v2_slot {
struct packed v2_slot {
char type[3];
uint8_t attributes;
uint32_t firstCluster;

View file

@ -19,8 +19,8 @@ struct exception_frame {
/* Force a compilation error if condition is true */
#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })
#define __aligned(x) __attribute__((aligned(x)))
#define __packed __attribute((packed))
#define aligned(x) __attribute__((aligned(x)))
#define packed __attribute((packed))
#define always_inline __inline__ __attribute__((always_inline))
#define likely(x) __builtin_expect(!!(x),1)

View file

@ -19,9 +19,6 @@ typedef char bool_t;
#define TRUE 1
#define FALSE 0
#define LONG_MAX ((long int)((~0UL)>>1))
#define LONG_MIN ((long int)~LONG_MAX)
#ifndef offsetof
#define offsetof(a,b) __builtin_offsetof(a,b)
#endif

View file

@ -29,7 +29,7 @@ def main(argv):
gap = 16 - height
tgap = gap // 2
bgap = gap - tgap
out_f.write("const uint8_t %s[] __aligned(4) = {\n" % argv[2])
out_f.write("const uint8_t %s[] aligned(4) = {\n" % argv[2])
for line in in_f:
# Look for a new character encoding
match = re.match("^ENCODING ([0-9]+)", line)

View file

@ -62,7 +62,7 @@ static unsigned int oled_prep_buffer(void);
static volatile uint8_t refresh_count;
/* I2C data buffer. Data is DMAed to the I2C peripheral. */
static uint8_t buffer[256] __aligned(4);
static uint8_t buffer[256] aligned(4);
/* Text buffer, rendered into I2C data and placed into buffer[]. */
static char text[2][40];

View file

@ -1465,15 +1465,6 @@ const struct image_handler xdf_image_handler = {
* Generic Handlers
*/
static bool_t raw_open(struct image *im)
{
im->img.rpm = im->img.rpm ?: 300;
im->stk_per_rev = (stk_ms(200) * 300) / im->img.rpm;
volume_cache_init(im->bufs.write_data.p + 1024,
im->img.heap_bottom);
return TRUE;
}
static FSIZE_t raw_extend(struct image *im)
{
unsigned int i, j, sz = im->img.base_off;
@ -1661,6 +1652,20 @@ static void raw_setup_track(
}
}
static bool_t raw_open(struct image *im)
{
im->img.rpm = im->img.rpm ?: 300;
im->stk_per_rev = (stk_ms(200) * 300) / im->img.rpm;
volume_cache_init(im->bufs.write_data.p + 1024,
im->img.heap_bottom);
/* Initialise write_bc_ticks (used by floppy_insert to set outp_hden). */
raw_seek_track(im, 0, 0, 0);
return TRUE;
}
void process_data(struct image *im, void *p, unsigned int len)
{
/* Pointer and size should be 4-byte aligned. */

View file

@ -531,7 +531,7 @@ static USBH_Status USBH_HandleEnum(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
phost,
phost->device_prop.Dev_Desc.iManufacturer,
Local_Buffer ,
0xff) == USBH_OK)
sizeof(Local_Buffer)) == USBH_OK)
{
/* User callback for Manufacturing string */
phost->usr_cb->ManufacturerString(Local_Buffer);
@ -552,7 +552,7 @@ static USBH_Status USBH_HandleEnum(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
phost,
phost->device_prop.Dev_Desc.iProduct,
Local_Buffer,
0xff) == USBH_OK)
sizeof(Local_Buffer)) == USBH_OK)
{
/* User callback for Product string */
phost->usr_cb->ProductString(Local_Buffer);
@ -573,7 +573,7 @@ static USBH_Status USBH_HandleEnum(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
phost,
phost->device_prop.Dev_Desc.iSerialNumber,
Local_Buffer,
0xff) == USBH_OK)
sizeof(Local_Buffer)) == USBH_OK)
{
/* User callback for Serial number string */
phost->usr_cb->SerialNumString(Local_Buffer);

View file

@ -135,7 +135,7 @@ USBH_Status USBH_Get_StringDesc(USB_OTG_CORE_HANDLE *pdev,
USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD,
USB_DESC_STRING | string_index,
Cfg_Rx_Buffer,
length)) == USBH_OK)
512)) == USBH_OK)
{
/* Commands successfully sent and Response Received */
USBH_ParseStringDesc(Cfg_Rx_Buffer, buff, length);
@ -522,30 +522,23 @@ static void USBH_ParseStringDesc (uint8_t* psrc,
uint8_t* pdest,
uint16_t length)
{
uint16_t strlength;
uint16_t idx;
/* Make sure the Descriptor is String Type */
if (psrc[1] == USB_DESC_TYPE_STRING) {
/* The UNICODE string descriptor is not NULL-terminated. The string length is
computed by subtracting two from the value of the first byte of the descriptor.
*/
/* The UNICODE string descriptor is not NUL-terminated. The string
* length is computed from the descriptor length. Divide by two
* to account for UTF-16 encoding. */
length = min_t(uint16_t, psrc[0]/2 - 1, length - 1);
/* Check which is lower size, the Size of string or the length of bytes read
from the device */
if ( psrc[1] == USB_DESC_TYPE_STRING)
{ /* Make sure the Descriptor is String Type */
/* psrc[0] contains Size of Descriptor, subtract 2 to get the length of string */
strlength = ( ( (psrc[0]-2) <= length) ? (psrc[0]-2) :length);
psrc += 2; /* Adjust the offset ignoring the String Len and Descriptor type */
for (idx = 0; idx < strlength; idx+=2 )
{/* Copy Only the string and ignore the UNICODE ID, hence add the src */
*pdest = psrc[idx];
pdest++;
while (length--) {
psrc += 2;
*pdest++ = *psrc;
}
*pdest = 0; /* mark end of string */
}
/* Mark end of string. */
*pdest = '\0';
}
/**

View file

@ -134,7 +134,7 @@ size_t strnlen(const char *s, size_t maxlen)
int strcmp(const char *s1, const char *s2)
{
return strncmp(s1, s2, ~0);
return strncmp(s1, s2, INT_MAX);
}
int strncmp(const char *s1, const char *s2, size_t n)