diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/elmfat/dfs_elm.c | 10 | ||||
| -rw-r--r-- | components/drivers/include/drivers/usb_device.h | 1 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/cdc_vcom.c | 19 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/ecm.c | 30 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/hid.c | 22 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/mstorage.c | 30 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/rndis.c | 34 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/class/winusb.c | 25 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/core/core.c | 5 | ||||
| -rw-r--r-- | components/drivers/usb/usbdevice/core/usbdevice.c | 15 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/fcntl.h | 0 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/stat.h | 0 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/sys/unistd.h | 5 | ||||
| -rw-r--r-- | components/libc/compilers/minilibc/stdint.h | 250 |
14 files changed, 350 insertions, 96 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index b244ee5601..4c17911f96 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -214,7 +214,8 @@ int dfs_elm_mkfs(rt_device_t dev_id) int flag; FRESULT result; int index; - + char logic_nbr[2] = {'0',':'}; + work = rt_malloc(_MAX_SS); if(RT_NULL == work) { return -ENOMEM; @@ -264,7 +265,8 @@ int dfs_elm_mkfs(rt_device_t dev_id) * on the disk, you will get a failure. so we need f_mount here, * just fill the FatFS[index] in elm fatfs to make mkfs work. */ - f_mount(fat, "", (BYTE)index); + logic_nbr[0] = '0' + index; + f_mount(fat, logic_nbr, (BYTE)index); } } @@ -273,14 +275,14 @@ int dfs_elm_mkfs(rt_device_t dev_id) /* [IN] Size of the allocation unit */ /* [-] Working buffer */ /* [IN] Size of working buffer */ - result = f_mkfs("", FM_ANY, 0, work, _MAX_SS); + result = f_mkfs(logic_nbr, FM_ANY, 0, work, _MAX_SS); rt_free(work); work = RT_NULL; /* check flag status, we need clear the temp driver stored in disk[] */ if (flag == FSM_STATUS_USE_TEMP_DRIVER) { rt_free(fat); - f_mount(RT_NULL, "",(BYTE)index); + f_mount(RT_NULL, logic_nbr,(BYTE)index); disk[index] = RT_NULL; /* close device */ rt_device_close(dev_id); diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h index 48f407cc3d..caa171079b 100644 --- a/components/drivers/include/drivers/usb_device.h +++ b/components/drivers/include/drivers/usb_device.h @@ -140,6 +140,7 @@ struct udcd struct uendpoint ep0; uep0_stage_t stage; struct ep_id* ep_pool; + rt_uint8_t device_is_hs; }; typedef struct udcd* udcd_t; diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index b8728beac5..c4985f04a2 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -114,15 +114,17 @@ static struct udevice_descriptor dev_desc = USB_DYNAMIC, //bNumConfigurations; }; +//FS and HS needed static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - USB_CLASS_CDC, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + USB_CLASS_CDC, //bDeviceClass + 0x00, //bDeviceSubClass + 0x00, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; @@ -566,7 +568,8 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device) /* create a cdc function */ func = rt_usbd_function_new(device, &dev_desc, &ops); - rt_usbd_device_set_qualifier(device, &dev_qualifier); + //not support HS + //rt_usbd_device_set_qualifier(device, &dev_qualifier); /* allocate memory for cdc vcom data */ data = (struct vcom*)rt_malloc(sizeof(struct vcom)); diff --git a/components/drivers/usb/usbdevice/class/ecm.c b/components/drivers/usb/usbdevice/class/ecm.c index 4a45bc0939..0e38356dda 100644 --- a/components/drivers/usb/usbdevice/class/ecm.c +++ b/components/drivers/usb/usbdevice/class/ecm.c @@ -41,7 +41,7 @@ struct rt_ecm_eth rt_uint8_t dev_addr[MAX_ADDR_LEN]; ALIGN(4) - rt_uint8_t rx_pool[64]; + rt_uint8_t rx_pool[512]; ALIGN(4) rt_size_t rx_size; ALIGN(4) @@ -147,14 +147,14 @@ const static struct ucdc_data_descriptor _data_desc = USB_DESC_TYPE_ENDPOINT, USB_DIR_OUT | USB_DYNAMIC, USB_EP_ATTR_BULK, - USB_CDC_BUFSIZE, + USB_DYNAMIC, 0x00, /* endpoint, bulk in */ USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, USB_EP_ATTR_BULK, - USB_CDC_BUFSIZE, + USB_DYNAMIC, 0x00, }; @@ -170,17 +170,20 @@ const static char* _ustring[] = }; ALIGN(4) +//FS and HS needed static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - USB_CLASS_CDC, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + USB_CLASS_CDC, //bDeviceClass + USB_CDC_SUBCLASS_ETH, //bDeviceSubClass + USB_CDC_PROTOCOL_NONE, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; + static rt_err_t _cdc_send_notifi(ufunction_t func,ucdc_notification_code_t notifi,rt_uint16_t wValue,rt_uint16_t wLength) { static struct ucdc_management_element_notifications _notifi; @@ -472,7 +475,7 @@ static struct ufunction_ops ops = * * @return RT_EOK on successful. */ -static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr) +static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr, rt_uint8_t device_is_hs) { comm->call_mgmt_desc.data_interface = dintf_nr; comm->union_desc.master_interface = cintf_nr; @@ -480,7 +483,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n #ifdef RT_USB_DEVICE_COMPOSITE comm->iad_desc.bFirstInterface = cintf_nr; #endif - + data->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64; + data->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64; return RT_EOK; } @@ -532,7 +536,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device) (rt_off_t)&((ucdc_eth_desc_t)0)->intf_desc); rt_usbd_altsetting_config_descriptor(data_setting, &_data_desc, 0); /* configure the cdc interface descriptor */ - _cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num); + _cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num, device->dcd->device_is_hs); /* create a command endpoint */ comm_desc = (ucdc_eth_desc_t)comm_setting->desc; diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c index 0b44456b8f..b752564974 100644 --- a/components/drivers/usb/usbdevice/class/hid.c +++ b/components/drivers/usb/usbdevice/class/hid.c @@ -227,18 +227,21 @@ static struct udevice_descriptor _dev_desc = USB_DYNAMIC, //bNumConfigurations; }; -static struct usb_qualifier_descriptor _dev_qualifier = +//FS and HS needed +static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(_dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - USB_CLASS_HID, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + USB_CLASS_MASS_STORAGE, //bDeviceClass + 0x06, //bDeviceSubClass + 0x50, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; + /* hid interface descriptor */ const static struct uhid_comm_descriptor _hid_comm_desc = { @@ -631,7 +634,8 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device) /* create a cdc function */ func = rt_usbd_function_new(device, &_dev_desc, &ops); - rt_usbd_device_set_qualifier(device, &_dev_qualifier); + //not support hs + //rt_usbd_device_set_qualifier(device, &_dev_qualifier); /* allocate memory for cdc vcom data */ data = (struct hid_s*)rt_malloc(sizeof(struct hid_s)); diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c index d4caf44166..14284e85a2 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.c +++ b/components/drivers/usb/usbdevice/class/mstorage.c @@ -88,8 +88,8 @@ static struct udevice_descriptor dev_desc = USB_DESC_TYPE_DEVICE, //type; USB_BCD_VERSION, //bcdUSB; USB_CLASS_MASS_STORAGE, //bDeviceClass; - 0x00, //bDeviceSubClass; - 0x00, //bDeviceProtocol; + 0x06, //bDeviceSubClass; + 0x50, //bDeviceProtocol; 0x40, //bMaxPacketSize0; _VENDOR_ID, //idVendor; _PRODUCT_ID, //idProduct; @@ -100,15 +100,17 @@ static struct udevice_descriptor dev_desc = USB_DYNAMIC, //bNumConfigurations; }; +//FS and HS needed static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - USB_CLASS_MASS_STORAGE, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + USB_CLASS_MASS_STORAGE, //bDeviceClass + 0x06, //bDeviceSubClass + 0x50, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; @@ -141,14 +143,14 @@ const static struct umass_descriptor _mass_desc = USB_DESC_TYPE_ENDPOINT, //type; USB_DYNAMIC | USB_DIR_OUT, //bEndpointAddress; USB_EP_ATTR_BULK, //bmAttributes; - 0x40, //wMaxPacketSize; + USB_DYNAMIC, //wMaxPacketSize; 0x00, //bInterval; USB_DESC_LENGTH_ENDPOINT, //bLength; USB_DESC_TYPE_ENDPOINT, //type; USB_DYNAMIC | USB_DIR_IN, //bEndpointAddress; USB_EP_ATTR_BULK, //bmAttributes; - 0x40, //wMaxPacketSize; + USB_DYNAMIC, //wMaxPacketSize; 0x00, //bInterval; }; @@ -1043,11 +1045,13 @@ static struct ufunction_ops ops = _function_disable, RT_NULL, }; -static rt_err_t _mstorage_descriptor_config(umass_desc_t desc, rt_uint8_t cintf_nr) +static rt_err_t _mstorage_descriptor_config(umass_desc_t desc, rt_uint8_t cintf_nr, rt_uint8_t device_is_hs) { #ifdef RT_USB_DEVICE_COMPOSITE desc->iad_desc.bFirstInterface = cintf_nr; #endif + desc->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64; + desc->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64; return RT_EOK; } /** @@ -1090,7 +1094,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device) rt_usbd_altsetting_config_descriptor(setting, &_mass_desc, (rt_off_t)&((umass_desc_t)0)->intf_desc); /* configure the msc interface descriptor */ - _mstorage_descriptor_config(setting->desc, intf->intf_num); + _mstorage_descriptor_config(setting->desc, intf->intf_num, device->dcd->device_is_hs); /* create a bulk out and a bulk in endpoint */ mass_desc = (umass_desc_t)setting->desc; diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c index a7f36dccb6..670c7686b4 100644 --- a/components/drivers/usb/usbdevice/class/rndis.c +++ b/components/drivers/usb/usbdevice/class/rndis.c @@ -58,9 +58,9 @@ struct rt_rndis_eth #endif /* RNDIS_DELAY_LINK_UP */ ALIGN(4) - rt_uint8_t rx_pool[64]; + rt_uint8_t rx_pool[512]; ALIGN(4) - rt_uint8_t tx_pool[64]; + rt_uint8_t tx_pool[512]; rt_uint32_t cmd_pool[2]; ALIGN(4) @@ -175,14 +175,14 @@ const static struct ucdc_data_descriptor _data_desc = USB_DESC_TYPE_ENDPOINT, USB_DIR_OUT | USB_DYNAMIC, USB_EP_ATTR_BULK, - USB_CDC_BUFSIZE, + USB_DYNAMIC, 0x00, /* endpoint, bulk in */ USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, USB_EP_ATTR_BULK, - USB_CDC_BUFSIZE, + USB_DYNAMIC, 0x00, }; @@ -206,16 +206,17 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc = .subCompatibleID = {'5', '1', '6', '2', '0', '0', '1', 0x00}, .reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -ALIGN(4) +//FS and HS needed static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - USB_CLASS_CDC, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + USB_CLASS_CDC, //bDeviceClass + USB_CDC_SUBCLASS_ACM, //bDeviceSubClass + USB_CDC_PROTOCOL_VENDOR, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; @@ -401,7 +402,7 @@ static rt_err_t _rndis_query_response(ufunction_t func,rndis_query_msg_t msg) case OID_GEN_LINK_SPEED: resp = _create_resp(4); if(resp == RT_NULL) break; - _set_resp(resp, (10UL * 1000 * 1000) / 100); + _set_resp(resp, func->device->dcd->device_is_hs ? (480UL * 1000 *1000) : (12UL * 1000 * 1000) / 100); break; case OID_GEN_MEDIA_CONNECT_STATUS: @@ -1008,7 +1009,7 @@ static struct ufunction_ops ops = * * @return RT_EOK on successful. */ -static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr) +static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr, rt_uint8_t device_is_hs) { comm->call_mgmt_desc.data_interface = dintf_nr; comm->union_desc.master_interface = cintf_nr; @@ -1016,7 +1017,8 @@ static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_n #ifdef RT_USB_DEVICE_COMPOSITE comm->iad_desc.bFirstInterface = cintf_nr; #endif - + data->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64; + data->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64; return RT_EOK; } @@ -1237,7 +1239,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device) (rt_off_t)&((ucdc_comm_desc_t)0)->intf_desc); rt_usbd_altsetting_config_descriptor(data_setting, &_data_desc, 0); /* configure the cdc interface descriptor */ - _cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num); + _cdc_descriptor_config(comm_setting->desc, intf_comm->intf_num, data_setting->desc, intf_data->intf_num, device->dcd->device_is_hs); /* create a command endpoint */ comm_desc = (ucdc_comm_desc_t)comm_setting->desc; diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c index 93a3a08e8b..82ac602c85 100644 --- a/components/drivers/usb/usbdevice/class/winusb.c +++ b/components/drivers/usb/usbdevice/class/winusb.c @@ -43,13 +43,14 @@ static struct udevice_descriptor dev_desc = //FS and HS needed static struct usb_qualifier_descriptor dev_qualifier = { - sizeof(dev_qualifier), - USB_DESC_TYPE_DEVICEQUALIFIER, - 0x0200, - 0x00, - 0x00, - 64, - 0x01, + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + 0xFF, //bDeviceClass + 0x00, //bDeviceSubClass + 0x00, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations 0, }; @@ -81,14 +82,14 @@ struct winusb_descriptor _winusb_desc = USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_OUT, USB_EP_ATTR_BULK, - 0x40, + USB_DYNAMIC, 0x00, /*endpoint descriptor*/ USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, USB_EP_ATTR_BULK, - 0x40, + USB_DYNAMIC, 0x00, }; @@ -197,11 +198,13 @@ static struct ufunction_ops ops = RT_NULL, }; -static rt_err_t _winusb_descriptor_config(winusb_desc_t winusb, rt_uint8_t cintf_nr) +static rt_err_t _winusb_descriptor_config(winusb_desc_t winusb, rt_uint8_t cintf_nr, rt_uint8_t device_is_hs) { #ifdef RT_USB_DEVICE_COMPOSITE winusb->iad_desc.bFirstInterface = cintf_nr; #endif + winusb->ep_out_desc.wMaxPacketSize = device_is_hs ? 512 : 64; + winusb->ep_in_desc.wMaxPacketSize = device_is_hs ? 512 : 64; winusb_func_comp_id_desc.bFirstInterfaceNumber = cintf_nr; return RT_EOK; } @@ -293,7 +296,7 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device) rt_usbd_altsetting_config_descriptor(winusb_setting, &_winusb_desc, (rt_off_t)&((winusb_desc_t)0)->intf_desc); /* configure the hid interface descriptor */ - _winusb_descriptor_config(winusb_setting->desc, winusb_intf->intf_num); + _winusb_descriptor_config(winusb_setting->desc, winusb_intf->intf_num, device->dcd->device_is_hs); /* create endpoint */ winusb_desc = (winusb_desc_t)winusb_setting->desc; diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c index 57111b6f4a..c8cd362bef 100644 --- a/components/drivers/usb/usbdevice/core/core.c +++ b/components/drivers/usb/usbdevice/core/core.c @@ -166,7 +166,7 @@ static rt_err_t _get_qualifier_descriptor(struct udevice* device, ureq_t setup) RT_ASSERT(device != RT_NULL); RT_ASSERT(setup != RT_NULL); - if(device->dev_qualifier) + if(device->dev_qualifier && device->dcd->device_is_hs) { /* send device qualifier descriptor to endpoint 0 */ rt_usbd_ep0_write(device, (rt_uint8_t*)device->dev_qualifier, @@ -210,6 +210,9 @@ static rt_err_t _get_descriptor(struct udevice* device, ureq_t setup) case USB_DESC_TYPE_DEVICEQUALIFIER: _get_qualifier_descriptor(device, setup); break; + case USB_DESC_TYPE_OTHERSPEED: + _get_config_descriptor(device, setup); + break; default: rt_kprintf("unsupported descriptor request\n"); rt_usbd_ep0_set_stall(device); diff --git a/components/drivers/usb/usbdevice/core/usbdevice.c b/components/drivers/usb/usbdevice/core/usbdevice.c index 10ffac8ad0..453084990b 100644 --- a/components/drivers/usb/usbdevice/core/usbdevice.c +++ b/components/drivers/usb/usbdevice/core/usbdevice.c @@ -59,6 +59,20 @@ static struct udevice_descriptor compsit_desc = USB_STRING_SERIAL_INDEX, //iSerialNumber; USB_DYNAMIC, //bNumConfigurations; }; + +//FS and HS needed +static struct usb_qualifier_descriptor dev_qualifier = +{ + sizeof(dev_qualifier), //bLength + USB_DESC_TYPE_DEVICEQUALIFIER, //bDescriptorType + 0x0200, //bcdUSB + USB_CLASS_MISC, //bDeviceClass + 0x02, //bDeviceSubClass + 0x01, //bDeviceProtocol + 64, //bMaxPacketSize0 + 0x01, //bNumConfigurations + 0, +}; #endif struct usb_os_comp_id_descriptor usb_comp_id_desc = @@ -169,6 +183,7 @@ rt_err_t rt_usb_device_init(void) #ifdef RT_USB_DEVICE_COMPOSITE rt_usbd_device_set_descriptor(udevice, &compsit_desc); rt_usbd_device_set_string(udevice, ustring); + rt_usbd_device_set_qualifier(device, &dev_qualifier); #else rt_usbd_device_set_descriptor(udevice, func->dev_desc); #endif diff --git a/components/libc/compilers/dlib/fcntl.h b/components/libc/compilers/dlib/fcntl.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/components/libc/compilers/dlib/fcntl.h diff --git a/components/libc/compilers/dlib/sys/stat.h b/components/libc/compilers/dlib/sys/stat.h new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/components/libc/compilers/dlib/sys/stat.h diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h index 06a46746c0..dbe4f3010d 100644 --- a/components/libc/compilers/dlib/sys/unistd.h +++ b/components/libc/compilers/dlib/sys/unistd.h @@ -2,6 +2,11 @@ #define _SYS_UNISTD_H #ifdef RT_USING_DFS + +#define STDIN_FILENO 0 /* standard input file descriptor */ +#define STDOUT_FILENO 1 /* standard output file descriptor */ +#define STDERR_FILENO 2 /* standard error file descriptor */ + #include <dfs_posix.h> #else #define _FREAD 0x0001 /* read enabled */ diff --git a/components/libc/compilers/minilibc/stdint.h b/components/libc/compilers/minilibc/stdint.h index 8733d60a03..c865d43435 100644 --- a/components/libc/compilers/minilibc/stdint.h +++ b/components/libc/compilers/minilibc/stdint.h @@ -1,18 +1,75 @@ +/* + * ISO C Standard: 7.18 Integer types <stdint.h> + */ + #ifndef __STDINT_H__ #define __STDINT_H__ -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; +/* 7.8.1.1 Exact-width integer types */ + +#ifdef __INT8_TYPE__ +typedef __INT8_TYPE__ int8_t; +#endif +#ifdef __INT16_TYPE__ +typedef __INT16_TYPE__ int16_t; +#endif +#ifdef __INT32_TYPE__ +typedef __INT32_TYPE__ int32_t; +#endif +#ifdef __INT64_TYPE__ +typedef __INT64_TYPE__ int64_t; +#endif +#ifdef __UINT8_TYPE__ +typedef __UINT8_TYPE__ uint8_t; +#endif +#ifdef __UINT16_TYPE__ +typedef __UINT16_TYPE__ uint16_t; +#endif +#ifdef __UINT32_TYPE__ +typedef __UINT32_TYPE__ uint32_t; +#endif +#ifdef __UINT64_TYPE__ +typedef __UINT64_TYPE__ uint64_t; +#endif -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; +/* 7.8.1.2 Minimum-width integer types */ -typedef long long int64_t; -typedef unsigned long long uint64_t; -typedef signed long intptr_t; -typedef unsigned long uintptr_t; +typedef __INT_LEAST8_TYPE__ int_least8_t; +typedef __INT_LEAST16_TYPE__ int_least16_t; +typedef __INT_LEAST32_TYPE__ int_least32_t; +typedef __INT_LEAST64_TYPE__ int_least64_t; +typedef __UINT_LEAST8_TYPE__ uint_least8_t; +typedef __UINT_LEAST16_TYPE__ uint_least16_t; +typedef __UINT_LEAST32_TYPE__ uint_least32_t; +typedef __UINT_LEAST64_TYPE__ uint_least64_t; + +/* 7.8.1.3 Fastest minimum-width integer types */ + +typedef __INT_FAST8_TYPE__ int_fast8_t; +typedef __INT_FAST16_TYPE__ int_fast16_t; +typedef __INT_FAST32_TYPE__ int_fast32_t; +typedef __INT_FAST64_TYPE__ int_fast64_t; +typedef __UINT_FAST8_TYPE__ uint_fast8_t; +typedef __UINT_FAST16_TYPE__ uint_fast16_t; +typedef __UINT_FAST32_TYPE__ uint_fast32_t; +typedef __UINT_FAST64_TYPE__ uint_fast64_t; + +/* 7.8.1.4 Integer types capable of holding object pointers */ + +#ifdef __INTPTR_TYPE__ +typedef __INTPTR_TYPE__ intptr_t; +#endif +#ifdef __UINTPTR_TYPE__ +typedef __UINTPTR_TYPE__ uintptr_t; +#endif + +/* 7.8.1.5 Greatest-width integer types */ + +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; + +#if (!defined __cplusplus || __cplusplus >= 201103L \ + || defined __STDC_LIMIT_MACROS) /* * 7.18.2 Limits of specified-width integer types. @@ -22,17 +79,170 @@ typedef unsigned long uintptr_t; */ /* 7.18.2.1 Limits of exact-width integer types */ -#define INT8_MIN (-0x7f - 1) -#define INT16_MIN (-0x7fff - 1) -#define INT32_MIN (-0x7fffffff - 1) -#define INT8_MAX 0x7f -#define INT16_MAX 0x7fff -#define INT32_MAX 0x7fffffff +#ifdef __INT8_MAX__ +# undef INT8_MAX +# define INT8_MAX __INT8_MAX__ +# undef INT8_MIN +# define INT8_MIN (-INT8_MAX - 1) +#endif +#ifdef __UINT8_MAX__ +# undef UINT8_MAX +# define UINT8_MAX __UINT8_MAX__ +#endif +#ifdef __INT16_MAX__ +# undef INT16_MAX +# define INT16_MAX __INT16_MAX__ +# undef INT16_MIN +# define INT16_MIN (-INT16_MAX - 1) +#endif +#ifdef __UINT16_MAX__ +# undef UINT16_MAX +# define UINT16_MAX __UINT16_MAX__ +#endif +#ifdef __INT32_MAX__ +# undef INT32_MAX +# define INT32_MAX __INT32_MAX__ +# undef INT32_MIN +# define INT32_MIN (-INT32_MAX - 1) +#endif +#ifdef __UINT32_MAX__ +# undef UINT32_MAX +# define UINT32_MAX __UINT32_MAX__ +#endif +#ifdef __INT64_MAX__ +# undef INT64_MAX +# define INT64_MAX __INT64_MAX__ +# undef INT64_MIN +# define INT64_MIN (-INT64_MAX - 1) +#endif +#ifdef __UINT64_MAX__ +# undef UINT64_MAX +# define UINT64_MAX __UINT64_MAX__ +#endif + +#undef INT_LEAST8_MAX +#define INT_LEAST8_MAX __INT_LEAST8_MAX__ +#undef INT_LEAST8_MIN +#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1) +#undef UINT_LEAST8_MAX +#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__ +#undef INT_LEAST16_MAX +#define INT_LEAST16_MAX __INT_LEAST16_MAX__ +#undef INT_LEAST16_MIN +#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1) +#undef UINT_LEAST16_MAX +#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__ +#undef INT_LEAST32_MAX +#define INT_LEAST32_MAX __INT_LEAST32_MAX__ +#undef INT_LEAST32_MIN +#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1) +#undef UINT_LEAST32_MAX +#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__ +#undef INT_LEAST64_MAX +#define INT_LEAST64_MAX __INT_LEAST64_MAX__ +#undef INT_LEAST64_MIN +#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1) +#undef UINT_LEAST64_MAX +#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__ + +#undef INT_FAST8_MAX +#define INT_FAST8_MAX __INT_FAST8_MAX__ +#undef INT_FAST8_MIN +#define INT_FAST8_MIN (-INT_FAST8_MAX - 1) +#undef UINT_FAST8_MAX +#define UINT_FAST8_MAX __UINT_FAST8_MAX__ +#undef INT_FAST16_MAX +#define INT_FAST16_MAX __INT_FAST16_MAX__ +#undef INT_FAST16_MIN +#define INT_FAST16_MIN (-INT_FAST16_MAX - 1) +#undef UINT_FAST16_MAX +#define UINT_FAST16_MAX __UINT_FAST16_MAX__ +#undef INT_FAST32_MAX +#define INT_FAST32_MAX __INT_FAST32_MAX__ +#undef INT_FAST32_MIN +#define INT_FAST32_MIN (-INT_FAST32_MAX - 1) +#undef UINT_FAST32_MAX +#define UINT_FAST32_MAX __UINT_FAST32_MAX__ +#undef INT_FAST64_MAX +#define INT_FAST64_MAX __INT_FAST64_MAX__ +#undef INT_FAST64_MIN +#define INT_FAST64_MIN (-INT_FAST64_MAX - 1) +#undef UINT_FAST64_MAX +#define UINT_FAST64_MAX __UINT_FAST64_MAX__ + +#ifdef __INTPTR_MAX__ +# undef INTPTR_MAX +# define INTPTR_MAX __INTPTR_MAX__ +# undef INTPTR_MIN +# define INTPTR_MIN (-INTPTR_MAX - 1) +#endif +#ifdef __UINTPTR_MAX__ +# undef UINTPTR_MAX +# define UINTPTR_MAX __UINTPTR_MAX__ +#endif -#define UINT8_MAX 0xff -#define UINT16_MAX 0xffff -#define UINT32_MAX 0xffffffffU +#undef INTMAX_MAX +#define INTMAX_MAX __INTMAX_MAX__ +#undef INTMAX_MIN +#define INTMAX_MIN (-INTMAX_MAX - 1) +#undef UINTMAX_MAX +#define UINTMAX_MAX __UINTMAX_MAX__ + +/* 7.18.3 Limits of other integer types */ + +#undef PTRDIFF_MAX +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#undef PTRDIFF_MIN +#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) + +#undef SIG_ATOMIC_MAX +#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__ +#undef SIG_ATOMIC_MIN +#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__ + +#undef SIZE_MAX +#define SIZE_MAX __SIZE_MAX__ + +#undef WCHAR_MAX +#define WCHAR_MAX __WCHAR_MAX__ +#undef WCHAR_MIN +#define WCHAR_MIN __WCHAR_MIN__ + +#undef WINT_MAX +#define WINT_MAX __WINT_MAX__ +#undef WINT_MIN +#define WINT_MIN __WINT_MIN__ + +#endif /* (!defined __cplusplus || __cplusplus >= 201103L + || defined __STDC_LIMIT_MACROS) */ + +#if (!defined __cplusplus || __cplusplus >= 201103L \ + || defined __STDC_CONSTANT_MACROS) + +#undef INT8_C +#define INT8_C(c) __INT8_C(c) +#undef INT16_C +#define INT16_C(c) __INT16_C(c) +#undef INT32_C +#define INT32_C(c) __INT32_C(c) +#undef INT64_C +#define INT64_C(c) __INT64_C(c) +#undef UINT8_C +#define UINT8_C(c) __UINT8_C(c) +#undef UINT16_C +#define UINT16_C(c) __UINT16_C(c) +#undef UINT32_C +#define UINT32_C(c) __UINT32_C(c) +#undef UINT64_C +#define UINT64_C(c) __UINT64_C(c) +#undef INTMAX_C +#define INTMAX_C(c) __INTMAX_C(c) +#undef UINTMAX_C +#define UINTMAX_C(c) __UINTMAX_C(c) + +#endif /* (!defined __cplusplus || __cplusplus >= 201103L + || defined __STDC_CONSTANT_MACROS) */ #ifndef __INT_MAX__ #define __INT_MAX__ 2147483647 @@ -45,6 +255,4 @@ typedef unsigned long uintptr_t; #define LONG_MIN (-LONG_MAX - 1) #define ULONG_MAX (~0UL) -#define SIZE_MAX ULONG_MAX - #endif |
