[include][dbg]update: no longer use RT_DEBUG_LOG in rtdebug.h (#7750)

This commit is contained in:
Shicheng Chu 2023-06-29 23:24:25 +08:00 committed by GitHub
parent 148ae53cf8
commit e2c031643c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 524 additions and 477 deletions

View File

@ -16,6 +16,15 @@
*/
#include <rtthread.h>
#define DBG_TAG "kernel.device"
#ifdef RT_DEBUG_DEVICE
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_DEVICE) */
#include <rtdbg.h>
#ifdef RT_USING_POSIX_DEVIO
#include <rtdevice.h> /* for wqueue_init */
#endif /* RT_USING_POSIX_DEVIO */
@ -178,8 +187,8 @@ rt_err_t rt_device_init(rt_device_t dev)
result = device_init(dev);
if (result != RT_EOK)
{
RT_DEBUG_LOG(RT_DEBUG_DEVICE, ("To initialize device:%s failed. The error code is %d\n",
dev->parent.name, result));
LOG_E("To initialize device:%s failed. The error code is %d",
dev->parent.name, result);
}
else
{
@ -216,8 +225,8 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
result = device_init(dev);
if (result != RT_EOK)
{
RT_DEBUG_LOG(RT_DEBUG_DEVICE, ("To initialize device:%s failed. The error code is %d\n",
dev->parent.name, result));
LOG_E("To initialize device:%s failed. The error code is %d",
dev->parent.name, result);
return result;
}

View File

@ -20,6 +20,10 @@
#ifdef RT_USB_DEVICE_CDC
#define DBG_TAG "usbdevice_cdc"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#define VCOM_INTF_STR_INDEX 5
#ifdef RT_VCOM_TX_TIMEOUT
#define VCOM_TX_TIMEOUT RT_VCOM_TX_TIMEOUT
@ -287,7 +291,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
data = (struct vcom*)func->user_data;
request_size = data->ep_in->request.size;
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_in_handler %d\n", request_size));
LOG_D("_ep_in_handler %d", request_size);
if ((request_size != 0) && ((request_size % EP_MAXPACKET(data->ep_in)) == 0))
{
/* don't have data right now. Send a zero-length-packet to
@ -325,7 +329,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size));
LOG_D("_ep_out_handler %d", size);
data = (struct vcom*)func->user_data;
/* ensure serial is active */
@ -362,7 +366,7 @@ static rt_err_t _ep_cmd_handler(ufunction_t func, rt_size_t size)
{
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_cmd_handler\n"));
LOG_D("_ep_cmd_handler");
return RT_EOK;
}
@ -383,7 +387,7 @@ static rt_err_t _cdc_get_line_coding(udevice_t device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_get_line_coding\n"));
LOG_D("_cdc_get_line_coding");
data.dwDTERate = 115200;
data.bCharFormat = 0;
@ -398,7 +402,7 @@ static rt_err_t _cdc_get_line_coding(udevice_t device, ureq_t setup)
static rt_err_t _cdc_set_line_coding_callback(udevice_t device, rt_size_t size)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_set_line_coding_callback\n"));
LOG_D("_cdc_set_line_coding_callback");
dcd_ep0_send_status(device->dcd);
@ -418,7 +422,7 @@ static rt_err_t _cdc_set_line_coding(udevice_t device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_set_line_coding\n"));
LOG_D("_cdc_set_line_coding");
rt_usbd_ep0_read(device, (void*)&line_coding, sizeof(struct ucdc_line_coding),
_cdc_set_line_coding_callback);
@ -464,7 +468,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
break;
case CDC_SET_CONTROL_LINE_STATE:
data->connected = (setup->wValue & 0x01) > 0?RT_TRUE:RT_FALSE;
RT_DEBUG_LOG(RT_DEBUG_USB, ("vcom state:%d \n", data->connected));
LOG_D("vcom state:%d ", data->connected);
dcd_ep0_send_status(func->device->dcd);
break;
case CDC_SEND_BREAK:
@ -490,7 +494,7 @@ static rt_err_t _function_enable(ufunction_t func)
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc function enable\n"));
LOG_D("cdc function enable");
_vcom_reset_state(func);
@ -524,7 +528,7 @@ static rt_err_t _function_disable(ufunction_t func)
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc function disable\n"));
LOG_D("cdc function disable");
_vcom_reset_state(func);
@ -765,7 +769,7 @@ static rt_ssize_t _vcom_tx(struct rt_serial_device *serial, rt_uint8_t *buf, rt_
RT_ASSERT(serial != RT_NULL);
RT_ASSERT(buf != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("%s\n",__func__));
LOG_D("%s",__func__);
if (data->connected)
{
@ -917,7 +921,7 @@ static void vcom_tx_thread_entry(void* parameter)
if (rt_completion_wait(&data->wait, VCOM_TX_TIMEOUT) != RT_EOK)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("vcom tx timeout\n"));
LOG_D("vcom tx timeout");
}
if(data->serial.parent.open_flag &
#ifdef RT_USING_SERIAL_V1

View File

@ -17,6 +17,11 @@
#include "hid.h"
#ifdef RT_USB_DEVICE_HID
#define DBG_TAG "usbdevice.hid"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#define HID_INTF_STR_INDEX 7
struct hid_s
{
@ -431,7 +436,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
static rt_err_t _hid_set_report_callback(udevice_t device, rt_size_t size)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("_hid_set_report_callback\n"));
LOG_D("_hid_set_report_callback");
if(size != 0)
{
@ -525,7 +530,7 @@ static rt_err_t _function_enable(ufunction_t func)
RT_ASSERT(func->device != RT_NULL);
data = (struct hid_s *) func->user_data;
RT_DEBUG_LOG(RT_DEBUG_USB, ("hid function enable\n"));
LOG_D("hid function enable");
//
// _vcom_reset_state(func);
//
@ -557,7 +562,7 @@ static rt_err_t _function_disable(ufunction_t func)
RT_ASSERT(func->device != RT_NULL);
data = (struct hid_s *) func->user_data;
RT_DEBUG_LOG(RT_DEBUG_USB, ("hid function disable\n"));
LOG_D("hid function disable");
if(data->ep_out->buffer != RT_NULL)
{

View File

@ -21,6 +21,10 @@
#ifdef RT_USB_DEVICE_MSTORAGE
#define MSTRORAGE_INTF_STR_INDEX 11
#define DBG_TAG "usbdevice.mstorage"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
enum STAT
{
STAT_CBW,
@ -202,7 +206,7 @@ static void _send_status(ufunction_t func)
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_send_status\n"));
LOG_D("_send_status");
data = (struct mstorage*)func->user_data;
data->ep_in->request.buffer = (rt_uint8_t*)&data->csw_response;
@ -219,7 +223,7 @@ static rt_ssize_t _test_unit_ready(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_test_unit_ready\n"));
LOG_D("_test_unit_ready");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@ -234,7 +238,7 @@ static rt_ssize_t _allow_removal(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_allow_removal\n"));
LOG_D("_allow_removal");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@ -260,7 +264,7 @@ static rt_ssize_t _inquiry_cmd(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_inquiry_cmd\n"));
LOG_D("_inquiry_cmd");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@ -299,7 +303,7 @@ static rt_ssize_t _request_sense(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_sense\n"));
LOG_D("_request_sense");
data = (struct mstorage*)func->user_data;
buf = (struct request_sense_data *)data->ep_in->buffer;
@ -342,7 +346,7 @@ static rt_ssize_t _mode_sense_6(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_mode_sense_6\n"));
LOG_D("_mode_sense_6");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@ -379,7 +383,7 @@ static rt_ssize_t _read_capacities(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacities\n"));
LOG_D("_read_capacities");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@ -425,7 +429,7 @@ static rt_ssize_t _read_capacity(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacity\n"));
LOG_D("_read_capacity");
data = (struct mstorage*)func->user_data;
buf = data->ep_in->buffer;
@ -515,8 +519,8 @@ static rt_ssize_t _write_10(ufunction_t func, ustorage_cbw_t cbw)
data->csw_response.data_reside = cbw->xfer_len;
data->size = data->count * data->geometry.bytes_per_sector;
RT_DEBUG_LOG(RT_DEBUG_USB, ("_write_10 count 0x%x block 0x%x 0x%x\n",
data->count, data->block, data->geometry.sector_count));
LOG_D("_write_10 count 0x%x block 0x%x 0x%x",
data->count, data->block, data->geometry.sector_count);
data->csw_response.data_reside = data->cb_data_size;
@ -543,7 +547,7 @@ static rt_ssize_t _verify_10(ufunction_t func, ustorage_cbw_t cbw)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_verify_10\n"));
LOG_D("_verify_10");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@ -559,7 +563,7 @@ static rt_ssize_t _start_stop(ufunction_t func,
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_start_stop\n"));
LOG_D("_start_stop");
data = (struct mstorage*)func->user_data;
data->csw_response.status = 0;
@ -574,7 +578,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_in_handler\n"));
LOG_D("_ep_in_handler");
data = (struct mstorage*)func->user_data;
@ -588,7 +592,7 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
}
else
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("return to cbw status\n"));
LOG_D("return to cbw status");
data->ep_out->request.buffer = data->ep_out->buffer;
data->ep_out->request.size = SIZEOF_CBW;
data->ep_out->request.req_type = UIO_REQUEST_READ_FULL;
@ -606,8 +610,8 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size)
data->csw_response.data_reside -= data->ep_in->request.size;
if(data->csw_response.data_reside != 0)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("data_reside %d, request %d\n",
data->csw_response.data_reside, data->ep_in->request.size));
LOG_D("data_reside %d, request %d",
data->csw_response.data_reside, data->ep_in->request.size);
if(data->processing->dir == DIR_OUT)
{
rt_usbd_ep_set_stall(func->device, data->ep_out);
@ -657,13 +661,13 @@ static void cbw_dump(struct ustorage_cbw* cbw)
{
RT_ASSERT(cbw != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("signature 0x%x\n", cbw->signature));
RT_DEBUG_LOG(RT_DEBUG_USB, ("tag 0x%x\n", cbw->tag));
RT_DEBUG_LOG(RT_DEBUG_USB, ("xfer_len 0x%x\n", cbw->xfer_len));
RT_DEBUG_LOG(RT_DEBUG_USB, ("dflags 0x%x\n", cbw->dflags));
RT_DEBUG_LOG(RT_DEBUG_USB, ("lun 0x%x\n", cbw->lun));
RT_DEBUG_LOG(RT_DEBUG_USB, ("cb_len 0x%x\n", cbw->cb_len));
RT_DEBUG_LOG(RT_DEBUG_USB, ("cb[0] 0x%x\n", cbw->cb[0]));
LOG_D("signature 0x%x", cbw->signature);
LOG_D("tag 0x%x", cbw->tag);
LOG_D("xfer_len 0x%x", cbw->xfer_len);
LOG_D("dflags 0x%x", cbw->dflags);
LOG_D("lun 0x%x", cbw->lun);
LOG_D("cb_len 0x%x", cbw->cb_len);
LOG_D("cb[0] 0x%x", cbw->cb[0]);
}
#endif
@ -827,7 +831,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
RT_ASSERT(func != RT_NULL);
RT_ASSERT(func->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size));
LOG_D("_ep_out_handler %d", size);
data = (struct mstorage*)func->user_data;
cbw = (struct ustorage_cbw*)data->ep_out->buffer;
@ -844,7 +848,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
data->csw_response.data_reside = cbw->xfer_len;
data->csw_response.status = 0;
RT_DEBUG_LOG(RT_DEBUG_USB, ("ep_out reside %d\n", data->csw_response.data_reside));
LOG_D("ep_out reside %d", data->csw_response.data_reside);
cmd = _find_cbw_command(cbw->cb[0]);
if(cmd == RT_NULL)
@ -869,8 +873,8 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
}
else if(data->status == STAT_RECEIVE)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("\nwrite size %d block 0x%x oount 0x%x\n",
size, data->block, data->size));
LOG_D("write size %d block 0x%x oount 0x%x",
size, data->block, data->size);
data->size -= size;
data->csw_response.data_reside -= size;
@ -928,13 +932,13 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
RT_ASSERT(func->device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("mstorage_interface_handler\n"));
LOG_D("mstorage_interface_handler");
switch(setup->bRequest)
{
case USBREQ_GET_MAX_LUN:
RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_GET_MAX_LUN\n"));
LOG_D("USBREQ_GET_MAX_LUN");
if(setup->wValue || setup->wLength != 1)
{
@ -947,7 +951,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
break;
case USBREQ_MASS_STORAGE_RESET:
RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_MASS_STORAGE_RESET\n"));
LOG_D("USBREQ_MASS_STORAGE_RESET");
if(setup->wValue || setup->wLength != 0)
{
@ -977,7 +981,7 @@ static rt_err_t _function_enable(ufunction_t func)
{
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function enabled\n"));
LOG_D("Mass storage function enabled");
data = (struct mstorage*)func->user_data;
data->disk = rt_device_find(RT_USB_MSTORAGE_DISK_NAME);
@ -1039,7 +1043,7 @@ static rt_err_t _function_disable(ufunction_t func)
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function disabled\n"));
LOG_D("Mass storage function disabled");
data = (struct mstorage*)func->user_data;
if(data->ep_in->buffer != RT_NULL)

View File

@ -17,6 +17,10 @@
#include "drivers/usb_common.h"
#include "drivers/usb_device.h"
#define DBG_TAG "usbdevice.core"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static rt_list_t device_list;
static rt_ssize_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_size_t size);
@ -40,7 +44,7 @@ static rt_err_t _get_device_descriptor(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_device_descriptor\n"));
LOG_D("_get_device_descriptor");
/* device descriptor wLength should less than USB_DESC_LENGTH_DEVICE*/
size = (setup->wLength > USB_DESC_LENGTH_DEVICE) ?
@ -69,7 +73,7 @@ static rt_err_t _get_config_descriptor(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_config_descriptor\n"));
LOG_D("_get_config_descriptor");
cfg_desc = &device->curr_cfg->cfg_desc;
size = (setup->wLength > cfg_desc->wTotalLength) ?
@ -99,7 +103,7 @@ static rt_err_t _get_string_descriptor(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_string_descriptor\n"));
LOG_D("_get_string_descriptor");
str_desc.type = USB_DESC_TYPE_STRING;
index = setup->wValue & 0xFF;
@ -152,7 +156,7 @@ static rt_err_t _get_string_descriptor(struct udevice* device, ureq_t setup)
static rt_err_t _get_qualifier_descriptor(struct udevice* device, ureq_t setup)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_qualifier_descriptor\n"));
LOG_D("_get_qualifier_descriptor");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -249,7 +253,7 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_interface\n"));
LOG_D("_get_interface");
if (device->state != USB_STATE_CONFIGURED)
{
@ -292,7 +296,7 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_set_interface\n"));
LOG_D("_set_interface");
if (device->state != USB_STATE_CONFIGURED)
{
@ -341,7 +345,7 @@ static rt_err_t _get_config(struct udevice* device, ureq_t setup)
RT_ASSERT(setup != RT_NULL);
RT_ASSERT(device->curr_cfg != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_config\n"));
LOG_D("_get_config");
if (device->state == USB_STATE_CONFIGURED)
{
@ -378,7 +382,7 @@ static rt_err_t _set_config(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_set_config\n"));
LOG_D("_set_config");
if (setup->wValue > device->dev_desc.bNumConfigurations)
{
@ -388,7 +392,7 @@ static rt_err_t _set_config(struct udevice* device, ureq_t setup)
if (setup->wValue == 0)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("address state\n"));
LOG_D("address state");
device->state = USB_STATE_ADDRESS;
goto _exit;
@ -448,7 +452,7 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup)
/* issue status stage */
dcd_ep0_send_status(device->dcd);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_set_address\n"));
LOG_D("_set_address");
device->state = USB_STATE_ADDRESS;
@ -474,7 +478,7 @@ static rt_err_t _request_interface(struct udevice* device, ureq_t setup)
RT_ASSERT(device != RT_NULL);
RT_ASSERT(setup != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_interface\n"));
LOG_D("_request_interface");
intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, &func);
if (intf != RT_NULL)
@ -593,7 +597,7 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
{
req = (uio_request_t)rt_list_entry(node, struct uio_request, list);
rt_usbd_io_request(device, ep, req);
RT_DEBUG_LOG(RT_DEBUG_USB, ("fired a request\n"));
LOG_D("fired a request");
}
rt_list_init(&ep->request_list);
@ -739,14 +743,14 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup)
}
static rt_err_t _dump_setup_packet(ureq_t setup)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("[\n"));
RT_DEBUG_LOG(RT_DEBUG_USB, (" setup_request : 0x%x\n",
setup->request_type));
RT_DEBUG_LOG(RT_DEBUG_USB, (" value : 0x%x\n", setup->wValue));
RT_DEBUG_LOG(RT_DEBUG_USB, (" length : 0x%x\n", setup->wLength));
RT_DEBUG_LOG(RT_DEBUG_USB, (" index : 0x%x\n", setup->wIndex));
RT_DEBUG_LOG(RT_DEBUG_USB, (" request : 0x%x\n", setup->bRequest));
RT_DEBUG_LOG(RT_DEBUG_USB, ("]\n"));
LOG_D("[");
LOG_D(" setup_request : 0x%x",
setup->request_type);
LOG_D(" value : 0x%x", setup->wValue);
LOG_D(" length : 0x%x", setup->wLength);
LOG_D(" index : 0x%x", setup->wIndex);
LOG_D(" request : 0x%x", setup->bRequest);
LOG_D("]");
return RT_EOK;
}
@ -1010,7 +1014,7 @@ udevice_t rt_usbd_device_new(void)
{
udevice_t udevice;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_device_new\n"));
LOG_D("rt_usbd_device_new");
/* allocate memory for the object */
udevice = (udevice_t)rt_malloc(sizeof(struct udevice));
@ -1146,7 +1150,7 @@ uconfig_t rt_usbd_config_new(void)
{
uconfig_t cfg;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_config_new\n"));
LOG_D("rt_usbd_config_new");
/* allocate memory for the object */
cfg = (uconfig_t)rt_malloc(sizeof(struct uconfig));
@ -1182,7 +1186,7 @@ uintf_t rt_usbd_interface_new(udevice_t device, uintf_handler_t handler)
{
uintf_t intf;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_interface_new\n"));
LOG_D("rt_usbd_interface_new");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -1217,7 +1221,7 @@ ualtsetting_t rt_usbd_altsetting_new(rt_size_t desc_size)
{
ualtsetting_t setting;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_altsetting_new\n"));
LOG_D("rt_usbd_altsetting_new");
/* parameter check */
RT_ASSERT(desc_size > 0);
@ -1281,7 +1285,7 @@ ufunction_t rt_usbd_function_new(udevice_t device, udev_desc_t dev_desc,
{
ufunction_t func;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_function_new\n"));
LOG_D("rt_usbd_function_new");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -1317,7 +1321,7 @@ uep_t rt_usbd_endpoint_new(uep_desc_t ep_desc, udep_handler_t handler)
{
uep_t ep;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_endpoint_new\n"));
LOG_D("rt_usbd_endpoint_new");
/* parameter check */
RT_ASSERT(ep_desc != RT_NULL);
@ -1377,7 +1381,7 @@ uconfig_t rt_usbd_find_config(udevice_t device, rt_uint8_t value)
struct rt_list_node* node;
uconfig_t cfg = RT_NULL;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_find_config\n"));
LOG_D("rt_usbd_find_config");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -1411,7 +1415,7 @@ uintf_t rt_usbd_find_interface(udevice_t device, rt_uint8_t value, ufunction_t *
ufunction_t func;
uintf_t intf;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_find_interface\n"));
LOG_D("rt_usbd_find_interface");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -1451,7 +1455,7 @@ ualtsetting_t rt_usbd_find_altsetting(uintf_t intf, rt_uint8_t value)
struct rt_list_node *i;
ualtsetting_t setting;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_find_altsetting\n"));
LOG_D("rt_usbd_find_altsetting");
/* parameter check */
RT_ASSERT(intf != RT_NULL);
@ -1534,7 +1538,7 @@ rt_err_t rt_usbd_device_add_config(udevice_t device, uconfig_t cfg)
ualtsetting_t altsetting;
uep_t ep;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_device_add_config\n"));
LOG_D("rt_usbd_device_add_config");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -1592,7 +1596,7 @@ rt_err_t rt_usbd_device_add_config(udevice_t device, uconfig_t cfg)
*/
rt_err_t rt_usbd_config_add_function(uconfig_t cfg, ufunction_t func)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_config_add_function\n"));
LOG_D("rt_usbd_config_add_function");
/* parameter check */
RT_ASSERT(cfg != RT_NULL);
@ -1615,7 +1619,7 @@ rt_err_t rt_usbd_config_add_function(uconfig_t cfg, ufunction_t func)
rt_err_t rt_usbd_function_add_interface(ufunction_t func, uintf_t intf)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_function_add_interface\n"));
LOG_D("rt_usbd_function_add_interface");
/* parameter check */
RT_ASSERT(func != RT_NULL);
@ -1637,7 +1641,7 @@ rt_err_t rt_usbd_function_add_interface(ufunction_t func, uintf_t intf)
*/
rt_err_t rt_usbd_interface_add_altsetting(uintf_t intf, ualtsetting_t setting)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_interface_add_altsetting\n"));
LOG_D("rt_usbd_interface_add_altsetting");
/* parameter check */
RT_ASSERT(intf != RT_NULL);
@ -1661,7 +1665,7 @@ rt_err_t rt_usbd_interface_add_altsetting(uintf_t intf, ualtsetting_t setting)
*/
rt_err_t rt_usbd_altsetting_add_endpoint(ualtsetting_t setting, uep_t ep)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_altsetting_add_endpoint\n"));
LOG_D("rt_usbd_altsetting_add_endpoint");
/* parameter check */
RT_ASSERT(setting != RT_NULL);
@ -1694,7 +1698,7 @@ rt_err_t rt_usbd_set_altsetting(uintf_t intf, rt_uint8_t value)
{
ualtsetting_t setting;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_set_altsetting\n"));
LOG_D("rt_usbd_set_altsetting");
/* parameter check */
RT_ASSERT(intf != RT_NULL);
@ -1720,7 +1724,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
{
uconfig_t cfg;
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbd_set_config\n"));
LOG_D("rt_usbd_set_config");
/* parameter check */
RT_ASSERT(device != RT_NULL);
@ -1774,7 +1778,7 @@ rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req)
else
{
rt_list_insert_before(&ep->request_list, &req->list);
RT_DEBUG_LOG(RT_DEBUG_USB, ("suspend a request\n"));
LOG_D("suspend a request");
}
return size;
@ -1794,11 +1798,11 @@ rt_err_t rt_usbd_set_feature(udevice_t device, rt_uint16_t value, rt_uint16_t in
if (value == USB_FEATURE_DEV_REMOTE_WAKEUP)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("set feature remote wakeup\n"));
LOG_D("set feature remote wakeup");
}
else if (value == USB_FEATURE_ENDPOINT_HALT)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("set feature stall\n"));
LOG_D("set feature stall");
dcd_ep_set_stall(device->dcd, (rt_uint32_t)(index & 0xFF));
}
@ -1819,11 +1823,11 @@ rt_err_t rt_usbd_clear_feature(udevice_t device, rt_uint16_t value, rt_uint16_t
if (value == USB_FEATURE_DEV_REMOTE_WAKEUP)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("clear feature remote wakeup\n"));
LOG_D("clear feature remote wakeup");
}
else if (value == USB_FEATURE_ENDPOINT_HALT)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("clear feature stall\n"));
LOG_D("clear feature stall");
dcd_ep_clear_stall(device->dcd, (rt_uint32_t)(index & 0xFF));
}
@ -1897,7 +1901,7 @@ static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep)
ep->id = &device->dcd->ep_pool[i];
device->dcd->ep_pool[i].status = ID_ASSIGNED;
RT_DEBUG_LOG(RT_DEBUG_USB, ("assigned %d\n", device->dcd->ep_pool[i].addr));
LOG_D("assigned %d", device->dcd->ep_pool[i].addr);
return RT_EOK;
}
@ -2170,7 +2174,7 @@ static void rt_usbd_thread_entry(void* parameter)
continue;
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("message type %d\n", msg.type));
LOG_D("message type %d", msg.type);
switch (msg.type)
{
@ -2189,7 +2193,7 @@ static void rt_usbd_thread_entry(void* parameter)
_ep0_out_notify(device, &msg.content.ep_msg);
break;
case USB_MSG_RESET:
RT_DEBUG_LOG(RT_DEBUG_USB, ("reset %d\n", device->state));
LOG_D("reset %d", device->state);
if (device->state == USB_STATE_ADDRESS || device->state == USB_STATE_CONFIGURED)
_stop_notify(device);
device->state = USB_STATE_NOTATTACHED;

View File

@ -14,6 +14,10 @@
#ifdef RT_USBH_ADK
#define DBG_TAG "usbhost.adk"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static struct uclass_driver adk_driver;
static const char* _adk_manufacturer = RT_NULL;
static const char* _adk_model = RT_NULL;
@ -231,7 +235,7 @@ static rt_err_t rt_usbh_adk_enable(void* arg)
return -RT_EIO;
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_adk_run\n"));
LOG_D("rt_usbh_adk_run");
dev_desc = &intf->device->dev_desc;
if(dev_desc->idVendor == USB_ACCESSORY_VENDOR_ID &&
@ -240,11 +244,11 @@ static rt_err_t rt_usbh_adk_enable(void* arg)
{
if(intf->intf_desc->bInterfaceSubClass != 0xFF) return -RT_ERROR;
RT_DEBUG_LOG(RT_DEBUG_USB, ("found android accessory device\n"));
LOG_D("found android accessory device");
}
else
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("switch device\n"));
LOG_D("switch device");
if((ret = rt_usbh_adk_get_protocol(intf, &protocol)) != RT_EOK)
{
@ -271,12 +275,12 @@ static rt_err_t rt_usbh_adk_enable(void* arg)
rt_usbh_adk_send_string(intf,
ACCESSORY_STRING_SERIAL, _adk_serial);
RT_DEBUG_LOG(RT_DEBUG_USB, ("manufacturer %s\n", _adk_manufacturer));
RT_DEBUG_LOG(RT_DEBUG_USB, ("model %s\n", _adk_model));
RT_DEBUG_LOG(RT_DEBUG_USB, ("description %s\n", _adk_description));
RT_DEBUG_LOG(RT_DEBUG_USB, ("version %s\n", _adk_version));
RT_DEBUG_LOG(RT_DEBUG_USB, ("uri %s\n", _adk_uri));
RT_DEBUG_LOG(RT_DEBUG_USB, ("serial %s\n", _adk_serial));
LOG_D("manufacturer %s", _adk_manufacturer);
LOG_D("model %s", _adk_model);
LOG_D("description %s", _adk_description);
LOG_D("version %s", _adk_version);
LOG_D("uri %s", _adk_uri);
LOG_D("serial %s", _adk_serial);
if((ret = rt_usbh_adk_start(intf)) != RT_EOK)
{
@ -372,7 +376,7 @@ static rt_err_t rt_usbh_adk_disable(void* arg)
RT_ASSERT(intf != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_adk_stop\n"));
LOG_D("rt_usbh_adk_stop");
adk = (uadk_t)intf->user_data;
if(adk == RT_NULL)

View File

@ -15,6 +15,10 @@
#ifdef RT_USBH_HID
#define DBG_TAG "usbhost.hid"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static struct uclass_driver hid_driver;
static rt_list_t _protocal_list;
@ -304,8 +308,7 @@ static rt_err_t rt_usbh_hid_enable(void* arg)
pro_id = intf->intf_desc->bInterfaceProtocol;
RT_DEBUG_LOG(RT_DEBUG_USB,
("HID device enable, protocal id %d\n", pro_id));
LOG_D("HID device enable, protocal id %d", pro_id);
protocal = rt_usbh_hid_protocal_find(pro_id);
if(protocal == RT_NULL)
@ -367,7 +370,7 @@ static rt_err_t rt_usbh_hid_disable(void* arg)
RT_ASSERT(intf != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_hid_disable\n"));
LOG_D("rt_usbh_hid_disable");
hid = (struct uhid*)intf->user_data;
if(hid != RT_NULL)

View File

@ -14,6 +14,10 @@
#ifdef RT_USBH_MSTORAGE
#define DBG_TAG "usbhost.mass"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
extern rt_err_t rt_udisk_run(struct uhintf* intf);
extern rt_err_t rt_udisk_stop(struct uhintf* intf);
@ -70,7 +74,7 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe)
stor->pipe_in->status = UPIPE_STATUS_OK;
RT_DEBUG_LOG(RT_DEBUG_USB, ("clean storage in pipe stall\n"));
LOG_D("clean storage in pipe stall");
/* it should receive csw after clear the stall feature */
size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd,
@ -200,7 +204,7 @@ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun)
/* parameter check */
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_get_max_lun\n"));
LOG_D("rt_usbh_storage_get_max_lun");
/* get usb device instance from the interface instance */
device = intf->device;
@ -250,7 +254,7 @@ rt_err_t rt_usbh_storage_reset(struct uhintf* intf)
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_reset\n"));
LOG_D("rt_usbh_storage_reset");
/* get usb device instance from the interface instance */
device = intf->device;
@ -297,7 +301,7 @@ rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer,
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_read10\n"));
LOG_D("rt_usbh_storage_read10");
/* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
@ -343,7 +347,7 @@ rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer,
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_write10\n"));
LOG_D("rt_usbh_storage_write10");
/* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
@ -387,7 +391,7 @@ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer)
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_request_sense\n"));
LOG_D("rt_usbh_storage_request_sense");
/* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
@ -423,7 +427,7 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf)
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_test_unit_ready\n"));
LOG_D("rt_usbh_storage_test_unit_ready");
/* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
@ -459,7 +463,7 @@ rt_err_t rt_usbh_storage_inquiry(struct uhintf* intf, rt_uint8_t* buffer)
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_inquiry\n"));
LOG_D("rt_usbh_storage_inquiry");
/* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
@ -496,7 +500,7 @@ rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer)
}
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_get_capacity\n"));
LOG_D("rt_usbh_storage_get_capacity");
/* construct the command block wrapper */
rt_memset(&cmd, 0, sizeof(struct ustorage_cbw));
@ -534,11 +538,11 @@ static rt_err_t rt_usbh_storage_enable(void* arg)
return -RT_EIO;
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("subclass %d, protocal %d\n",
LOG_D("subclass %d, protocal %d",
intf->intf_desc->bInterfaceSubClass,
intf->intf_desc->bInterfaceProtocol));
intf->intf_desc->bInterfaceProtocol);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_run\n"));
LOG_D("rt_usbh_storage_run");
/* only support SCSI subclass and bulk only protocal */
@ -610,7 +614,7 @@ static rt_err_t rt_usbh_storage_disable(void* arg)
RT_ASSERT(intf->user_data != RT_NULL);
RT_ASSERT(intf->device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_stop\n"));
LOG_D("rt_usbh_storage_stop");
/* get storage instance from interface instance */
stor = (ustor_t)intf->user_data;

View File

@ -281,8 +281,8 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
stor->capicity[1] = uswap_32(stor->capicity[1]);
stor->capicity[0] += 1;
RT_DEBUG_LOG(RT_DEBUG_USB, ("capicity %d, block size %d\n",
stor->capicity[0], stor->capicity[1]));
LOG_D("capicity %d, block size %d",
stor->capicity[0], stor->capicity[1]);
/* get the first sector to read partition table */
sector = (rt_uint8_t*) rt_malloc (SECTOR_SIZE);
@ -294,7 +294,7 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
rt_memset(sector, 0, SECTOR_SIZE);
RT_DEBUG_LOG(RT_DEBUG_USB, ("read partition table\n"));
LOG_D("read partition table");
/* get the partition table */
ret = rt_usbh_storage_read10(intf, sector, 0, 1, USB_TIMEOUT_LONG);
@ -306,7 +306,7 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
return -RT_ERROR;
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("finished reading partition\n"));
LOG_D("finished reading partition");
for(i=0; i<MAX_PARTITION_COUNT; i++)
{
@ -346,11 +346,11 @@ rt_err_t rt_udisk_run(struct uhintf* intf)
if (dfs_mount(stor->dev[i].parent.name, UDISK_MOUNTPOINT, "elm",
0, 0) == 0)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("udisk part %d mount successfully\n", i));
LOG_D("udisk part %d mount successfully", i);
}
else
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("udisk part %d mount failed\n", i));
LOG_D("udisk part %d mount failed", i);
}
}
else

View File

@ -14,6 +14,10 @@
#if defined(RT_USBH_HID) && defined(RT_USBH_HID_KEYBOARD)
#define DBG_TAG "usbhost.ukbd"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static struct uprotocal kbd_protocal;
static rt_err_t rt_usbh_hid_kbd_callback(void* arg)
@ -28,7 +32,7 @@ static rt_err_t rt_usbh_hid_kbd_callback(void* arg)
if(int1 != 0 || int2 != 0)
{
RT_DEBUG_LOG(RT_DEBUG_USB, ("key down 0x%x, 0x%x\n", int1, int2));
LOG_D("key down 0x%x, 0x%x", int1, int2);
}
return RT_EOK;
@ -62,7 +66,7 @@ static rt_err_t rt_usbh_hid_kbd_init(void* arg)
rt_usbh_hid_set_idle(intf, 10, 0);
RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb keyboard\n"));
LOG_D("start usb keyboard");
kbd_thread = rt_thread_create("kbd0", kbd_task, intf, 1024, 8, 100);
rt_thread_startup(kbd_thread);

View File

@ -19,6 +19,11 @@
#endif
#if defined(RT_USBH_HID) && defined(RT_USBH_HID_MOUSE)
#define DBG_TAG "usbhost.umouse"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static struct uprotocal mouse_protocal;
#ifdef RT_USING_RTGUI
@ -42,9 +47,9 @@ static rt_err_t rt_usbh_hid_mouse_callback(void* arg)
#endif
hid = (struct uhid*)arg;
RT_DEBUG_LOG(RT_DEBUG_USB, ("hid 0x%x 0x%x\n",
LOG_D("hid 0x%x 0x%x",
*(rt_uint32_t*)hid->buffer,
*(rt_uint32_t*)(&hid->buffer[4])));
*(rt_uint32_t*)(&hid->buffer[4]));
#ifdef RT_USING_RTGUI
if(hid->buffer[1]!=0)
{
@ -157,7 +162,7 @@ static rt_err_t rt_usbh_hid_mouse_init(void* arg)
mouse_thread = rt_thread_create("mouse0", mouse_task, intf, 1024, 8, 100);
rt_thread_startup(mouse_thread);
RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb mouse\n"));
LOG_D("start usb mouse");
#ifdef RT_USING_RTGUI
RTGUI_EVENT_MOUSE_BUTTON_INIT(&emouse);
emouse.wid = RT_NULL;

View File

@ -405,7 +405,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub)
ret = rt_usbh_hub_get_port_status(hub, i + 1, &pstatus);
if(ret != RT_EOK) continue;
RT_DEBUG_LOG(RT_DEBUG_USB, ("port %d status 0x%x\n", i + 1, pstatus));
RT_DEBUG_LOG_D("port %d status 0x%x", i + 1, pstatus);
/* check port status change */
if (pstatus & PORT_CCSC)
@ -476,13 +476,13 @@ static void rt_usbh_hub_irq(void* context)
if(pipe->status != UPIPE_STATUS_OK)
{
RT_DEBUG_LOG(RT_DEBUG_USB,("hub irq error\n"));
LOG_D("hub irq error");
return;
}
rt_usbh_hub_port_change(hub);
RT_DEBUG_LOG(RT_DEBUG_USB,("hub int xfer...\n"));
LOG_D("hub int xfer...");
/* parameter check */
RT_ASSERT(pipe->inst->hcd != RT_NULL);
@ -512,7 +512,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg)
/* paremeter check */
RT_ASSERT(intf != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_hub_run\n"));
RT_DEBUG_LOG_D("rt_usbh_hub_run");
/* get usb device instance */
device = intf->device;
@ -613,7 +613,7 @@ static rt_err_t rt_usbh_hub_disable(void* arg)
/* paremeter check */
RT_ASSERT(intf != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_hub_stop\n"));
RT_DEBUG_LOG_D("rt_usbh_hub_stop");
hub = (uhub_t)intf->user_data;
for(i=0; i<hub->num_ports; i++)
@ -662,7 +662,7 @@ static void rt_usbh_hub_thread_entry(void* parameter)
if (rt_mq_recv(hcd->usb_mq, &msg, sizeof(struct uhost_msg), RT_WAITING_FOREVER) < 0)
continue;
//RT_DEBUG_LOG(RT_DEBUG_USB, ("msg type %d\n", msg.type));
//RT_DEBUG_LOG_D("msg type %d", msg.type);
switch (msg.type)
{

View File

@ -11,6 +11,10 @@
#include <rtthread.h>
#include <drivers/usb_host.h>
#define DBG_TAG "usbhost.core"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static struct uinstance dev[USB_MAX_DEVICE];
/**
@ -105,7 +109,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_out, device, &ep0_out_desc);
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_in, device, &ep0_in_desc);
RT_DEBUG_LOG(RT_DEBUG_USB, ("start enumnation\n"));
LOG_D("start enumnation");
/* get device descriptor head */
ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_DEVICE, (void*)dev_desc, 8);
@ -138,8 +142,8 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
/* alloc true address ep0 pipe*/
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_out, device, &ep0_out_desc);
rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_in, device, &ep0_in_desc);
RT_DEBUG_LOG(RT_DEBUG_USB, ("get device descriptor length %d\n",
dev_desc->bLength));
LOG_D("get device descriptor length %d",
dev_desc->bLength);
/* get full device descriptor again */
ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_DEVICE, (void*)dev_desc, dev_desc->bLength);
@ -149,8 +153,8 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
return ret;
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("Vendor ID 0x%x\n", dev_desc->idVendor));
RT_DEBUG_LOG(RT_DEBUG_USB, ("Product ID 0x%x\n", dev_desc->idProduct));
LOG_D("Vendor ID 0x%x", dev_desc->idVendor);
LOG_D("Product ID 0x%x", dev_desc->idProduct);
/* get configuration descriptor head */
ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_CONFIGURATION, &cfg_desc, 18);
@ -193,9 +197,9 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device)
return -RT_ERROR;
}
RT_DEBUG_LOG(RT_DEBUG_USB, ("interface class 0x%x, subclass 0x%x\n",
LOG_D("interface class 0x%x, subclass 0x%x",
intf_desc->bInterfaceClass,
intf_desc->bInterfaceSubClass));
intf_desc->bInterfaceSubClass);
/* alloc pipe*/
for(ep_index = 0; ep_index < intf_desc->bNumEndpoints; ep_index++)
{
@ -276,7 +280,7 @@ rt_err_t rt_usbh_detach_instance(uinst_t device)
RT_ASSERT(device->intf[i]->device == device);
RT_DEBUG_LOG(RT_DEBUG_USB, ("free interface instance %d\n", i));
LOG_D("free interface instance %d", i);
rt_usbh_class_driver_disable(device->intf[i]->drv, (void*)device->intf[i]);
rt_free(device->intf[i]);
}
@ -349,7 +353,7 @@ rt_err_t rt_usbh_set_address(uinst_t device)
RT_ASSERT(device != RT_NULL);
RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usb_set_address\n"));
LOG_D("rt_usb_set_address");
setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD |
USB_REQ_TYPE_DEVICE;
@ -499,8 +503,7 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num,
{
*intf_desc = (uintf_desc_t)desc;
RT_DEBUG_LOG(RT_DEBUG_USB,
("rt_usb_get_interface_descriptor: %d\n", num));
LOG_D("rt_usb_get_interface_descriptor: %d", num);
return RT_EOK;
}
}
@ -547,8 +550,7 @@ rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num,
{
*ep_desc = (uep_desc_t)desc;
RT_DEBUG_LOG(RT_DEBUG_USB,
("rt_usb_get_endpoint_descriptor: %d\n", num));
LOG_D("rt_usb_get_endpoint_descriptor: %d", num);
return RT_EOK;
}
else count++;
@ -568,7 +570,7 @@ int rt_usb_hcd_pipe_xfer(uhcd_t hcd, upipe_t pipe, void* buffer, int nbytes, int
rt_uint8_t * pbuffer = (rt_uint8_t *)buffer;
do
{
RT_DEBUG_LOG(RT_DEBUG_USB,("pipe transform remain size,: %d\n", remain_size));
LOG_D("pipe transform remain size,: %d", remain_size);
send_size = (remain_size > pipe->ep.wMaxPacketSize) ? pipe->ep.wMaxPacketSize : remain_size;
if(hcd->ops->pipe_xfer(pipe, USBH_PID_DATA, pbuffer, send_size, timeout) == send_size)
{

View File

@ -12,6 +12,15 @@
#include "../dlelf.h"
#ifdef __arm__
#define DBG_TAG "kernel.module"
#ifdef RT_DEBUG_MODULE
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_MODULE) */
#include <rtdbg.h>
int dlmodule_relocate(struct rt_dlmodule *module, Elf32_Rel *rel, Elf32_Addr sym_val)
{
Elf32_Addr *where, tmp;
@ -27,8 +36,8 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf32_Rel *rel, Elf32_Addr sym
break;
case R_ARM_ABS32:
*where += (Elf32_Addr)sym_val;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_ARM_ABS32: %x -> %x\n",
where, *where));
LOG_D("R_ARM_ABS32: %x -> %x",
where, *where);
break;
case R_ARM_PC24:
case R_ARM_PLT32:
@ -40,14 +49,13 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf32_Rel *rel, Elf32_Addr sym
tmp = sym_val - (Elf32_Addr)where + (addend << 2);
tmp >>= 2;
*where = (*where & 0xff000000) | (tmp & 0x00ffffff);
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_ARM_PC24: %x -> %x\n",
where, *where));
LOG_D("R_ARM_PC24: %x -> %x",
where, *where);
break;
case R_ARM_REL32:
*where += sym_val - (Elf32_Addr)where;
RT_DEBUG_LOG(RT_DEBUG_MODULE,
("R_ARM_REL32: %x -> %x, sym %x, offset %x\n",
where, *where, sym_val, rel->r_offset));
LOG_D("R_ARM_REL32: %x -> %x, sym %x, offset %x",
where, *where, sym_val, rel->r_offset);
break;
case R_ARM_V4BX:
*where &= 0xf000000f;
@ -57,22 +65,22 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf32_Rel *rel, Elf32_Addr sym
case R_ARM_GLOB_DAT:
case R_ARM_JUMP_SLOT:
*where = (Elf32_Addr)sym_val;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_ARM_JUMP_SLOT: 0x%x -> 0x%x 0x%x\n",
where, *where, sym_val));
LOG_D("R_ARM_JUMP_SLOT: 0x%x -> 0x%x 0x%x",
where, *where, sym_val);
break;
#if 0 /* To do */
case R_ARM_GOT_BREL:
temp = (Elf32_Addr)sym_val;
*where = (Elf32_Addr)&temp;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_ARM_GOT_BREL: 0x%x -> 0x%x 0x%x\n",
where, *where, sym_val));
LOG_D("R_ARM_GOT_BREL: 0x%x -> 0x%x 0x%x",
where, *where, sym_val);
break;
#endif
case R_ARM_RELATIVE:
*where = (Elf32_Addr)sym_val + *where;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_ARM_RELATIVE: 0x%x -> 0x%x 0x%x\n",
where, *where, sym_val));
LOG_D("R_ARM_RELATIVE: 0x%x -> 0x%x 0x%x",
where, *where, sym_val);
break;
case R_ARM_THM_CALL:
case R_ARM_THM_JUMP24:

View File

@ -26,6 +26,14 @@
#define R_RISCV_TLS_TPREL32 10
#define R_RISCV_TLS_TPREL64 11
#define DBG_TAG "kernel.module"
#ifdef RT_DEBUG_MODULE
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_MODULE) */
#include <rtdbg.h>
int dlmodule_relocate(struct rt_dlmodule *module, Elf_Rel *rel, Elf_Addr sym_val)
{
Elf64_Addr *where, tmp;
@ -41,18 +49,18 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf_Rel *rel, Elf_Addr sym_val
break;
case R_RISCV_64:
*where = (Elf64_Addr)(sym_val + rel->r_addend);
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_RISCV_64: %x -> %x\n",where, *where));
LOG_D("R_RISCV_64: %x -> %x",where, *where);
break;
case R_RISCV_RELATIVE:
*where = (Elf64_Addr)((rt_uint8_t *)module->mem_space - module->vstart_addr + rel->r_addend);
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_RISCV_RELATIVE: %x -> %x\n",where, *where));
LOG_D("R_RISCV_RELATIVE: %x -> %x",where, *where);
break;
case R_RISCV_JUMP_SLOT:
*where = (Elf64_Addr)sym_val;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_RISCV_JUMP_SLOT: %x -> %x\n",where, *where));
LOG_D("R_RISCV_JUMP_SLOT: %x -> %x",where, *where);
break;
default:
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("__riscv__ELF: invalid relocate TYPE %d\n", ELF64_R_TYPE(rel->r_info)));
LOG_D("__riscv__ELF: invalid relocate TYPE %d", ELF64_R_TYPE(rel->r_info));
return -1;
}
return 0;

View File

@ -13,6 +13,14 @@
#ifdef __i386__
#define DBG_TAG "kernel.module"
#ifdef RT_DEBUG_MODULE
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_MODULE) */
#include <rtdbg.h>
#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
#define R_X86_64_RELATIVE 8 /* Adjust by program base */
@ -32,16 +40,16 @@ int dlmodule_relocate(struct rt_dlmodule *module, Elf32_Rel *rel, Elf32_Addr sym
case R_X86_64_JUMP_SLOT:
*where = (Elf32_Addr)sym_val;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_X86_64_JUMP_SLOT: 0x%x -> 0x%x 0x%x\n",
(uint32_t)where, *where, sym_val));
LOG_D("R_X86_64_JUMP_SLOT: 0x%x -> 0x%x 0x%x",
(uint32_t)where, *where, sym_val);
break;
case R_X86_64_RELATIVE:
*where = (Elf32_Addr)sym_val + *where;
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("R_X86_64_RELATIVE: 0x%x -> 0x%x 0x%x\n",
(uint32_t)where, *where, sym_val));
LOG_D("R_X86_64_RELATIVE: 0x%x -> 0x%x 0x%x",
(uint32_t)where, *where, sym_val);
break;
default:
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("X86ELF: invalid relocate TYPE %d\n", ELF32_R_TYPE(rel->r_info)));
LOG_D("X86ELF: invalid relocate TYPE %d", ELF32_R_TYPE(rel->r_info));
return -1;
}

View File

@ -578,10 +578,11 @@ Configuration is mainly done by modifying the file under project directory - rtc
/* Define this macro to enable debug mode, if not defined, close. */
#define RT_DEBUG
/* When debug mode is enabled: When the macro is defined as 0, the print component initialization information is turned off. When it is defined as 1, it is enabled. */
#define RT_DEBUG_INIT 0
/* When debug mode is enabled: Define this macro to enable the print component initialization information, if not defined, close. */
#define RT_DEBUG_INIT
/* When debug mode is enabled: When the macro is defined as 0, the print thread switching information is turned off. When it is defined as 1, it is enabled. */
#define RT_DEBUG_THREAD 0
/* When debug mode is enabled: Define this macro to enable the print thread switching information. */
#define RT_DEBUG_THREAD
/* Defining this macro means the use of the hook function is started, if not defined, close. */
#define RT_USING_HOOK

View File

@ -15,64 +15,11 @@
/* Using this macro to control all kernel debug features. */
#ifdef RT_DEBUG
/* Turn on some of these (set to non-zero) to debug kernel */
#ifndef RT_DEBUG_MEM
#define RT_DEBUG_MEM 0
#endif
#ifndef RT_DEBUG_MEMHEAP
#define RT_DEBUG_MEMHEAP 0
#endif
#ifndef RT_DEBUG_MODULE
#define RT_DEBUG_MODULE 0
#endif
#ifndef RT_DEBUG_SCHEDULER
#define RT_DEBUG_SCHEDULER 0
#endif
#ifndef RT_DEBUG_SLAB
#define RT_DEBUG_SLAB 0
#endif
#ifndef RT_DEBUG_THREAD
#define RT_DEBUG_THREAD 0
#endif
#ifndef RT_DEBUG_TIMER
#define RT_DEBUG_TIMER 0
#endif
#ifndef RT_DEBUG_IRQ
#define RT_DEBUG_IRQ 0
#endif
#ifndef RT_DEBUG_IPC
#define RT_DEBUG_IPC 0
#endif
#ifndef RT_DEBUG_DEVICE
#define RT_DEBUG_DEVICE 1
#endif
#ifndef RT_DEBUG_INIT
#define RT_DEBUG_INIT 0
#endif
/* Turn on this to enable context check */
#ifndef RT_DEBUG_CONTEXT_CHECK
#define RT_DEBUG_CONTEXT_CHECK 1
#endif
#define RT_DEBUG_LOG(type, message) \
do \
{ \
if (type) \
rt_kprintf message; \
} \
while (0)
#define RT_ASSERT(EX) \
if (!(EX)) \
{ \
@ -156,7 +103,6 @@ while (0)
#else /* RT_DEBUG */
#define RT_ASSERT(EX)
#define RT_DEBUG_LOG(type, message)
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check)

View File

@ -270,7 +270,7 @@ typedef __gnuc_va_list va_list;
typedef int (*init_fn_t)(void);
#ifdef _MSC_VER
#pragma section("rti_fn$f",read)
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
struct rt_init_desc
{
const char* level;
@ -296,7 +296,7 @@ typedef int (*init_fn_t)(void);
{__rti_level_##fn, fn };
#endif
#else
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
struct rt_init_desc
{
const char* fn_name;

View File

@ -81,7 +81,7 @@ struct rt_init_tag
{
const char *level;
init_fn_t fn;
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
const char *fn_name;
#endif
};
@ -114,7 +114,7 @@ static int rt_init_objects_sort(void)
{
table->level = ((struct rt_init_desc *)ptr_begin)->level;
table->fn = ((struct rt_init_desc *)ptr_begin)->fn;
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
table->fn_name = ((struct rt_init_desc *)ptr_begin)->fn_name;
#endif
ptr_begin += sizeof(struct rt_init_desc) / sizeof(unsigned int);
@ -168,7 +168,7 @@ void rt_components_board_init(void)
{
break;
}
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
rt_kprintf("initialize %s", rt_init_table[index_i].fn_name);
result = rt_init_table[index_i].fn();
rt_kprintf(":%d done\n", result);
@ -203,7 +203,7 @@ void rt_components_init(void)
{
break;
}
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
rt_kprintf("initialize %s", rt_init_table[index_i].fn_name);
result = rt_init_table[index_i].fn();
rt_kprintf(":%d done\n", result);

View File

@ -13,6 +13,14 @@
#include <rthw.h>
#define DBG_TAG "kernel.irq"
#ifdef RT_DEBUG_IRQ
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_IRQ) */
#include <rtdbg.h>
extern volatile rt_uint8_t rt_interrupt_nest;
/* exception and interrupt handler table */
@ -174,14 +182,14 @@ void rt_interrupt_enter(void)
RT_OBJECT_HOOK_CALL(rt_interrupt_enter_hook,());
rt_hw_interrupt_enable(level);
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq current nest:%d\n",
(rt_int32_t)rt_interrupt_nest));
LOG_D("irq has come..., irq current nest:%d",
(rt_int32_t)rt_interrupt_nest);
}
void rt_interrupt_leave(void)
{
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq is going to leave, irq current nest:%d\n",
(rt_int32_t)rt_interrupt_nest));
LOG_D("irq is going to leave, irq current nest:%d",
(rt_int32_t)rt_interrupt_nest);
rt_hw_interrupt_disable();
RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,());

View File

@ -207,92 +207,52 @@ if RT_DEBUG
bool "Enable color debugging log"
default n
config RT_DEBUG_INIT_CONFIG
config RT_DEBUG_INIT
bool "Enable debugging of components initialization"
default n
config RT_DEBUG_INIT
int
default 1 if RT_DEBUG_INIT_CONFIG
config RT_DEBUG_THREAD_CONFIG
config RT_DEBUG_THREAD
bool "Enable debugging of Thread State Changes"
default n
config RT_DEBUG_THREAD
int
default 1 if RT_DEBUG_THREAD_CONFIG
config RT_DEBUG_SCHEDULER_CONFIG
config RT_DEBUG_SCHEDULER
bool "Enable debugging of Scheduler"
default n
config RT_DEBUG_SCHEDULER
int
default 1 if RT_DEBUG_SCHEDULER_CONFIG
config RT_DEBUG_IPC_CONFIG
config RT_DEBUG_IPC
bool "Enable debugging of IPC"
default n
config RT_DEBUG_IPC
int
default 1 if RT_DEBUG_IPC_CONFIG
config RT_DEBUG_TIMER_CONFIG
config RT_DEBUG_TIMER
bool "Enable debugging of Timer"
default n
config RT_DEBUG_TIMER
int
default 1 if RT_DEBUG_TIMER_CONFIG
config RT_DEBUG_IRQ_CONFIG
config RT_DEBUG_IRQ
bool "Enable debugging of IRQ(Interrupt Request)"
default n
config RT_DEBUG_IRQ
int
default 1 if RT_DEBUG_IRQ_CONFIG
config RT_DEBUG_MEM_CONFIG
config RT_DEBUG_MEM
bool "Enable debugging of Small Memory Algorithm"
default n
config RT_DEBUG_MEM
int
default 1 if RT_DEBUG_MEM_CONFIG
config RT_DEBUG_SLAB_CONFIG
config RT_DEBUG_SLAB
bool "Enable debugging of SLAB Memory Algorithm"
default n
config RT_DEBUG_SLAB
int
default 1 if RT_DEBUG_SLAB_CONFIG
config RT_DEBUG_MEMHEAP_CONFIG
config RT_DEBUG_MEMHEAP
bool "Enable debugging of Memory Heap Algorithm"
default n
config RT_DEBUG_MEMHEAP
int
default 1 if RT_DEBUG_MEMHEAP_CONFIG
if ARCH_MM_MMU
config RT_DEBUG_PAGE_LEAK
bool "Enable page leaking tracer"
default n
endif
config RT_DEBUG_MODULE_CONFIG
config RT_DEBUG_MODULE
bool "Enable debugging of Application Module"
default n
config RT_DEBUG_MODULE
int
default 1 if RT_DEBUG_MODULE_CONFIG
endif
menu "Inter-Thread communication"

View File

@ -84,7 +84,7 @@ INIT_EXPORT(rti_end, "6.end");
*/
void rt_components_board_init(void)
{
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
int result;
const struct rt_init_desc *desc;
for (desc = &__rt_init_desc_rti_board_start; desc < &__rt_init_desc_rti_board_end; desc ++)
@ -108,7 +108,7 @@ void rt_components_board_init(void)
*/
void rt_components_init(void)
{
#if RT_DEBUG_INIT
#ifdef RT_DEBUG_INIT
int result;
const struct rt_init_desc *desc;

View File

@ -50,6 +50,14 @@
#include <rtthread.h>
#include <rthw.h>
#define DBG_TAG "kernel.ipc"
#ifdef RT_DEBUG_IPC
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_IPC) */
#include <rtdbg.h>
#ifndef __on_rt_object_trytake_hook
#define __on_rt_object_trytake_hook(parent) __ON_HOOK_ARGS(rt_object_trytake_hook, (parent))
#endif
@ -211,7 +219,7 @@ rt_inline rt_err_t _ipc_list_resume(rt_list_t *list)
thread->error = RT_EOK;
RT_DEBUG_LOG(RT_DEBUG_IPC, ("resume thread:%s\n", thread->parent.name));
LOG_D("resume thread:%s\n", thread->parent.name);
/* resume it */
rt_thread_resume(thread);
@ -513,10 +521,10 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
/* disable interrupt */
level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s take sem:%s, which value is: %d\n",
LOG_D("thread %s take sem:%s, which value is: %d",
rt_thread_self()->parent.name,
sem->parent.parent.name,
sem->value));
sem->value);
if (sem->value > 0)
{
@ -544,7 +552,7 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
/* reset thread error number */
thread->error = -RT_EINTR;
RT_DEBUG_LOG(RT_DEBUG_IPC, ("sem take: suspend thread - %s\n", thread->parent.name));
LOG_D("sem take: suspend thread - %s", thread->parent.name);
/* suspend thread */
ret = _ipc_list_suspend(&(sem->parent.suspend_thread),
@ -560,7 +568,7 @@ static rt_err_t _rt_sem_take(rt_sem_t sem, rt_int32_t timeout, int suspend_flag)
/* has waiting time, start thread timer */
if (timeout > 0)
{
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", thread->parent.name));
LOG_D("set thread:%s to timer list", thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@ -654,10 +662,10 @@ rt_err_t rt_sem_release(rt_sem_t sem)
/* disable interrupt */
level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("thread %s releases sem:%s, which value is: %d\n",
LOG_D("thread %s releases sem:%s, which value is: %d",
rt_thread_self()->parent.name,
sem->parent.parent.name,
sem->value));
sem->value);
if (!rt_list_isempty(&sem->parent.suspend_thread))
{
@ -788,8 +796,7 @@ rt_inline rt_uint8_t _thread_get_mutex_priority(struct rt_thread* thread)
rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t priority, int suspend_flag)
{
rt_err_t ret;
RT_DEBUG_LOG(RT_DEBUG_IPC,
("thread:%s priority -> %d\n", thread->parent.name, priority));
LOG_D("thread:%s priority -> %d", thread->parent.name, priority);
/* change priority of the thread */
rt_thread_control(thread,
@ -822,9 +829,8 @@ rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t prio
/* update priority */
_mutex_update_priority(pending_mutex);
/* change the priority of mutex owner thread */
RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex: %s priority -> %d\n", pending_mutex->parent.parent.name,
pending_mutex->priority));
LOG_D("mutex: %s priority -> %d", pending_mutex->parent.parent.name,
pending_mutex->priority);
mutex_priority = _thread_get_mutex_priority(pending_mutex->owner);
if (mutex_priority != pending_mutex->owner->current_priority)
@ -1180,9 +1186,8 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(mutex->parent.parent)));
RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex_take: current thread %s, hold: %d\n",
thread->parent.name, mutex->hold));
LOG_D("mutex_take: current thread %s, hold: %d",
thread->parent.name, mutex->hold);
/* reset thread error */
thread->error = RT_EOK;
@ -1238,8 +1243,8 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
rt_uint8_t priority = thread->current_priority;
/* mutex is unavailable, push to suspend list */
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_take: suspend thread: %s\n",
thread->parent.name));
LOG_D("mutex_take: suspend thread: %s",
thread->parent.name);
/* suspend current thread */
ret = _ipc_list_suspend(&(mutex->parent.suspend_thread),
@ -1268,9 +1273,8 @@ static rt_err_t _rt_mutex_take(rt_mutex_t mutex, rt_int32_t timeout, int suspend
/* has waiting time, start thread timer */
if (timeout > 0)
{
RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex_take: start the timer of thread:%s\n",
thread->parent.name));
LOG_D("mutex_take: start the timer of thread:%s",
thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@ -1422,9 +1426,8 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
/* disable interrupt */
level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_IPC,
("mutex_release:current thread %s, hold: %d\n",
thread->parent.name, mutex->hold));
LOG_D("mutex_release:current thread %s, hold: %d",
thread->parent.name, mutex->hold);
RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(mutex->parent.parent)));
@ -1470,8 +1473,8 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
struct rt_thread,
tlist);
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release: resume thread: %s\n",
next_thread->parent.name));
LOG_D("mutex_release: resume thread: %s",
next_thread->parent.name);
/* remove the thread from the suspended list of mutex */
rt_list_remove(&(next_thread->tlist));
@ -2417,8 +2420,8 @@ static rt_err_t _rt_mb_send_wait(rt_mailbox_t mb,
/* get the start tick of timer */
tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_send_wait: start timer of thread:%s\n",
thread->parent.name));
LOG_D("mb_send_wait: start timer of thread:%s",
thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@ -2711,8 +2714,8 @@ static rt_err_t _rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeo
/* get the start tick of timer */
tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mb_recv: start timer of thread:%s\n",
thread->parent.name));
LOG_D("mb_recv: start timer of thread:%s",
thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@ -3256,8 +3259,8 @@ static rt_err_t _rt_mq_send_wait(rt_mq_t mq,
/* get the start tick of timer */
tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mq_send_wait: start timer of thread:%s\n",
thread->parent.name));
LOG_D("mq_send_wait: start timer of thread:%s",
thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),
@ -3649,8 +3652,8 @@ static rt_ssize_t _rt_mq_recv(rt_mq_t mq,
/* get the start tick of timer */
tick_delta = rt_tick_get();
RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n",
thread->parent.name));
LOG_D("set thread:%s to timer list",
thread->parent.name);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer),

View File

@ -17,6 +17,14 @@
#include <rthw.h>
#include <rtthread.h>
#define DBG_TAG "kernel.irq"
#ifdef RT_DEBUG_IRQ
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_IRQ) */
#include <rtdbg.h>
#ifndef __on_rt_interrupt_enter_hook
#define __on_rt_interrupt_enter_hook() __ON_HOOK_ARGS(rt_interrupt_enter_hook, ())
#endif
@ -87,8 +95,8 @@ rt_weak void rt_interrupt_enter(void)
RT_OBJECT_HOOK_CALL(rt_interrupt_enter_hook,());
rt_hw_interrupt_enable(level);
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq has come..., irq current nest:%d\n",
(rt_int32_t)rt_interrupt_nest));
LOG_D("irq has come..., irq current nest:%d",
(rt_int32_t)rt_interrupt_nest);
}
RTM_EXPORT(rt_interrupt_enter);
@ -104,8 +112,8 @@ rt_weak void rt_interrupt_leave(void)
{
rt_base_t level;
RT_DEBUG_LOG(RT_DEBUG_IRQ, ("irq is going to leave, irq current nest:%d\n",
(rt_int32_t)rt_interrupt_nest));
LOG_D("irq is going to leave, irq current nest:%d",
(rt_int32_t)rt_interrupt_nest);
level = rt_hw_interrupt_disable();
RT_OBJECT_HOOK_CALL(rt_interrupt_leave_hook,());

View File

@ -29,6 +29,14 @@
#include <rtthread.h>
#include <rthw.h>
#define DBG_TAG "kernel.device"
#ifdef RT_DEBUG_DEVICE
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_DEVICE) */
#include <rtdbg.h>
#ifdef RT_USING_MODULE
#include <dlmodule.h>
#endif /* RT_USING_MODULE */
@ -58,8 +66,8 @@ static rt_device_t _console_device = RT_NULL;
rt_weak void rt_hw_us_delay(rt_uint32_t us)
{
(void) us;
RT_DEBUG_LOG(RT_DEBUG_DEVICE, ("rt_hw_us_delay() doesn't support for this board."
"Please consider implementing rt_hw_us_delay() in another file.\n"));
LOG_D("rt_hw_us_delay() doesn't support for this board."
"Please consider implementing rt_hw_us_delay() in another file.");
}
rt_weak const char *rt_hw_cpu_arch(void)

View File

@ -54,6 +54,15 @@
/**
* memory item on the small mem
*/
#define DBG_TAG "kernel.mem"
#ifdef RT_DEBUG_MEM
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_MEM) */
#include <rtdbg.h>
struct rt_small_mem_item
{
rt_ubase_t pool_ptr; /**< small memory object addr */
@ -213,8 +222,8 @@ rt_smem_t rt_smem_init(const char *name,
/* point to begin address of heap */
small_mem->heap_ptr = (rt_uint8_t *)begin_align;
RT_DEBUG_LOG(RT_DEBUG_MEM, ("mem init, heap begin address 0x%x, size %d\n",
(rt_ubase_t)small_mem->heap_ptr, small_mem->mem_size_aligned));
LOG_D("mem init, heap begin address 0x%x, size %d",
(rt_ubase_t)small_mem->heap_ptr, small_mem->mem_size_aligned);
/* initialize the start of the heap */
mem = (struct rt_small_mem_item *)small_mem->heap_ptr;
@ -290,12 +299,12 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
if (size != RT_ALIGN(size, RT_ALIGN_SIZE))
{
RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %d\n",
size, RT_ALIGN(size, RT_ALIGN_SIZE)));
LOG_D("malloc size %d, but align to %d",
size, RT_ALIGN(size, RT_ALIGN_SIZE));
}
else
{
RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d\n", size));
LOG_D("malloc size %d", size);
}
small_mem = (struct rt_small_mem *)m;
@ -308,7 +317,7 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
if (size > small_mem->mem_size_aligned)
{
RT_DEBUG_LOG(RT_DEBUG_MEM, ("no memory\n"));
LOG_D("no memory");
return RT_NULL;
}
@ -393,10 +402,9 @@ void *rt_smem_alloc(rt_smem_t m, rt_size_t size)
RT_ASSERT((rt_ubase_t)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM) % RT_ALIGN_SIZE == 0);
RT_ASSERT((((rt_ubase_t)mem) & (RT_ALIGN_SIZE - 1)) == 0);
RT_DEBUG_LOG(RT_DEBUG_MEM,
("allocate memory at 0x%x, size: %d\n",
LOG_D("allocate memory at 0x%x, size: %d",
(rt_ubase_t)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM),
(rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
(rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr)));
/* return the memory data except mem struct */
return (rt_uint8_t *)mem + SIZEOF_STRUCT_MEM;
@ -435,7 +443,7 @@ void *rt_smem_realloc(rt_smem_t m, void *rmem, rt_size_t newsize)
newsize = RT_ALIGN(newsize, RT_ALIGN_SIZE);
if (newsize > small_mem->mem_size_aligned)
{
RT_DEBUG_LOG(RT_DEBUG_MEM, ("realloc: out of memory\n"));
LOG_D("realloc: out of memory");
return RT_NULL;
}
@ -534,10 +542,9 @@ void rt_smem_free(void *rmem)
(rt_uint8_t *)rmem < (rt_uint8_t *)small_mem->heap_end);
RT_ASSERT(MEM_POOL(&small_mem->heap_ptr[mem->next]) == small_mem);
RT_DEBUG_LOG(RT_DEBUG_MEM,
("release memory 0x%x, size: %d\n",
LOG_D("release memory 0x%x, size: %d",
(rt_ubase_t)rmem,
(rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
(rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr)));
/* ... and is now unused. */
mem->pool_ptr = MEM_FREED();

View File

@ -26,6 +26,14 @@
#ifdef RT_USING_MEMHEAP
#define DBG_TAG "kernel.memheap"
#ifdef RT_DEBUG_MEMHEAP
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_MEM) */
#include <rtdbg.h>
/* dynamic pool magic and mask */
#define RT_MEMHEAP_MAGIC 0x1ea01ea0
#define RT_MEMHEAP_MASK 0xFFFFFFFE
@ -143,9 +151,8 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap,
rt_sem_init(&(memheap->lock), name, 1, RT_IPC_FLAG_PRIO);
memheap->locked = RT_FALSE;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("memory heap: start addr 0x%08x, size %d, free list header 0x%08x\n",
start_addr, size, &(memheap->free_header)));
LOG_D("memory heap: start addr 0x%08x, size %d, free list header 0x%08x",
start_addr, size, &(memheap->free_header));
return RT_EOK;
}
@ -195,8 +202,8 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
if (size < RT_MEMHEAP_MINIALLOC)
size = RT_MEMHEAP_MINIALLOC;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("allocate %d on heap:%8.*s",
size, RT_NAME_MAX, heap->parent.name));
LOG_D("allocate %d on heap:%8.*s",
size, RT_NAME_MAX, heap->parent.name);
if (size < heap->available_size)
{
@ -242,12 +249,11 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
new_ptr = (struct rt_memheap_item *)
(((rt_uint8_t *)header_ptr) + size + RT_MEMHEAP_SIZE);
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]\n",
LOG_D("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]",
header_ptr,
header_ptr->next,
header_ptr->prev,
new_ptr));
new_ptr);
/* mark the new block as a memory block and freed. */
new_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED);
@ -276,9 +282,9 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
new_ptr->prev_free = heap->free_list;
heap->free_list->next_free->prev_free = new_ptr;
heap->free_list->next_free = new_ptr;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x\n",
LOG_D("new ptr: next_free 0x%08x, prev_free 0x%08x",
new_ptr->next_free,
new_ptr->prev_free));
new_ptr->prev_free);
/* decrement the available byte count. */
heap->available_size = heap->available_size -
@ -295,11 +301,10 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
heap->max_used_size = heap->pool_size - heap->available_size;
/* remove header_ptr from free list */
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("one block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x\n",
LOG_D("one block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x",
header_ptr,
header_ptr->next_free,
header_ptr->prev_free));
header_ptr->prev_free);
header_ptr->next_free->prev_free = header_ptr->prev_free;
header_ptr->prev_free->next_free = header_ptr->next_free;
@ -324,11 +329,10 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
}
/* Return a memory address to the caller. */
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("alloc mem: memory[0x%08x], heap[0x%08x], size: %d\n",
LOG_D("alloc mem: memory[0x%08x], heap[0x%08x], size: %d",
(void *)((rt_uint8_t *)header_ptr + RT_MEMHEAP_SIZE),
header_ptr,
size));
size);
return (void *)((rt_uint8_t *)header_ptr + RT_MEMHEAP_SIZE);
}
@ -340,7 +344,7 @@ void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
}
}
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("allocate memory: failed\n"));
LOG_D("allocate memory: failed");
/* Return the completion status. */
return RT_NULL;
@ -436,22 +440,20 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
heap->max_used_size = heap->pool_size - heap->available_size;
/* remove next_ptr from free list */
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("remove block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x",
LOG_D("remove block: block[0x%08x], next_free 0x%08x, prev_free 0x%08x",
next_ptr,
next_ptr->next_free,
next_ptr->prev_free));
next_ptr->prev_free);
_remove_next_ptr(next_ptr);
/* build a new one on the right place */
next_ptr = (struct rt_memheap_item *)((char *)ptr + newsize);
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("new free block: block[0x%08x] nextm[0x%08x] prevm[0x%08x]",
LOG_D("new free block: block[0x%08x] nextm[0x%08x] prevm[0x%08x]",
next_ptr,
next_ptr->next,
next_ptr->prev));
next_ptr->prev);
/* mark the new block as a memory block and freed. */
next_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED);
@ -473,9 +475,9 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
next_ptr->prev_free = heap->free_list;
heap->free_list->next_free->prev_free = (struct rt_memheap_item *)next_ptr;
heap->free_list->next_free = (struct rt_memheap_item *)next_ptr;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x",
LOG_D("new ptr: next_free 0x%08x, prev_free 0x%08x",
next_ptr->next_free,
next_ptr->prev_free));
next_ptr->prev_free);
if (heap->locked == RT_FALSE)
{
/* release lock */
@ -523,12 +525,11 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
new_ptr = (struct rt_memheap_item *)
(((rt_uint8_t *)header_ptr) + newsize + RT_MEMHEAP_SIZE);
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]\n",
LOG_D("split: block[0x%08x] nextm[0x%08x] prevm[0x%08x] to new[0x%08x]",
header_ptr,
header_ptr->next,
header_ptr->prev,
new_ptr));
new_ptr);
/* mark the new block as a memory block and freed. */
new_ptr->magic = (RT_MEMHEAP_MAGIC | RT_MEMHEAP_FREED);
@ -554,9 +555,8 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
free_ptr = new_ptr->next;
heap->available_size = heap->available_size - MEMITEM_SIZE(free_ptr);
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x\n",
header_ptr, header_ptr->next_free, header_ptr->prev_free));
LOG_D("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x",
header_ptr, header_ptr->next_free, header_ptr->prev_free);
free_ptr->next->prev = new_ptr;
new_ptr->next = free_ptr->next;
@ -571,9 +571,9 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
new_ptr->prev_free = heap->free_list;
heap->free_list->next_free->prev_free = new_ptr;
heap->free_list->next_free = new_ptr;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new free ptr: next_free 0x%08x, prev_free 0x%08x\n",
LOG_D("new free ptr: next_free 0x%08x, prev_free 0x%08x",
new_ptr->next_free,
new_ptr->prev_free));
new_ptr->prev_free);
/* increment the available byte count. */
heap->available_size = heap->available_size + MEMITEM_SIZE(new_ptr);
@ -611,15 +611,15 @@ void rt_memheap_free(void *ptr)
header_ptr = (struct rt_memheap_item *)
((rt_uint8_t *)ptr - RT_MEMHEAP_SIZE);
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("free memory: memory[0x%08x], block[0x%08x]\n",
ptr, header_ptr));
LOG_D("free memory: memory[0x%08x], block[0x%08x]",
ptr, header_ptr);
/* check magic */
if (header_ptr->magic != (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED) ||
(header_ptr->next->magic & RT_MEMHEAP_MASK) != RT_MEMHEAP_MAGIC)
{
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("bad magic:0x%08x @ memheap\n",
header_ptr->magic));
LOG_D("bad magic:0x%08x @ memheap",
header_ptr->magic);
RT_ASSERT(header_ptr->magic == (RT_MEMHEAP_MAGIC | RT_MEMHEAP_USED));
/* check whether this block of memory has been over-written. */
RT_ASSERT((header_ptr->next->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC);
@ -651,8 +651,8 @@ void rt_memheap_free(void *ptr)
/* Determine if the block can be merged with the previous neighbor. */
if (!RT_MEMHEAP_IS_USED(header_ptr->prev))
{
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("merge: left node 0x%08x\n",
header_ptr->prev));
LOG_D("merge: left node 0x%08x",
header_ptr->prev);
/* adjust the available number of bytes. */
heap->available_size += RT_MEMHEAP_SIZE;
@ -676,9 +676,8 @@ void rt_memheap_free(void *ptr)
/* merge block with next neighbor. */
new_ptr = header_ptr->next;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x\n",
new_ptr, new_ptr->next_free, new_ptr->prev_free));
LOG_D("merge: right node 0x%08x, next_free 0x%08x, prev_free 0x%08x",
new_ptr, new_ptr->next_free, new_ptr->prev_free);
new_ptr->next->prev = header_ptr;
header_ptr->next = new_ptr->next;
@ -708,9 +707,8 @@ void rt_memheap_free(void *ptr)
n->prev_free->next_free = header_ptr;
n->prev_free = header_ptr;
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
("insert to free list: next_free 0x%08x, prev_free 0x%08x\n",
header_ptr->next_free, header_ptr->prev_free));
LOG_D("insert to free list: next_free 0x%08x, prev_free 0x%08x",
header_ptr->next_free, header_ptr->prev_free);
}
#ifdef RT_USING_MEMTRACE

View File

@ -34,6 +34,14 @@
#include <rtthread.h>
#include <rthw.h>
#define DBG_TAG "kernel.scheduler"
#ifdef RT_DEBUG_SCHEDULER
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_SCHEDULER) */
#include <rtdbg.h>
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
rt_uint32_t rt_thread_ready_priority_group;
#if RT_THREAD_PRIORITY_MAX > 32
@ -180,8 +188,8 @@ void rt_system_scheduler_init(void)
int cpu;
rt_base_t offset;
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("start scheduler: max priority 0x%02x\n",
RT_THREAD_PRIORITY_MAX));
LOG_D("start scheduler: max priority 0x%02x",
RT_THREAD_PRIORITY_MAX);
for (offset = 0; offset < RT_THREAD_PRIORITY_MAX; offset ++)
{
@ -345,13 +353,12 @@ void rt_schedule(void)
to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK);
/* switch to new thread */
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER,
("[%d]switch to priority#%d "
LOG_D("[%d]switch to priority#%d "
"thread:%.*s(sp:0x%08x), "
"from thread:%.*s(sp: 0x%08x)\n",
"from thread:%.*s(sp: 0x%08x)",
pcpu->irq_nest, highest_ready_priority,
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
RT_NAME_MAX, current_thread->parent.name, current_thread->sp));
RT_NAME_MAX, current_thread->parent.name, current_thread->sp);
#ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread);
@ -482,7 +489,7 @@ void rt_scheduler_do_irq_switch(void *context)
#ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread);
#endif /* RT_USING_OVERFLOW_CHECK */
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
LOG_D("switch in interrupt");
RT_ASSERT(current_thread->cpus_lock_nest > 0);
current_thread->cpus_lock_nest--;
@ -584,8 +591,8 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
}
}
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n",
RT_NAME_MAX, thread->parent.name, thread->current_priority));
LOG_D("insert thread[%.*s], the priority: %d",
RT_NAME_MAX, thread->parent.name, thread->current_priority);
__exit:
/* enable interrupt */
@ -608,9 +615,9 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
/* disable interrupt */
level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n",
LOG_D("remove thread[%.*s], the priority: %d",
RT_NAME_MAX, thread->parent.name,
thread->current_priority));
thread->current_priority);
/* remove thread from ready list */
rt_list_remove(&(thread->tlist));

View File

@ -34,6 +34,14 @@
#include <rtthread.h>
#include <rthw.h>
#define DBG_TAG "kernel.scheduler"
#ifdef RT_DEBUG_SCHEDULER
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_SCHEDULER) */
#include <rtdbg.h>
rt_list_t rt_thread_priority_table[RT_THREAD_PRIORITY_MAX];
rt_uint32_t rt_thread_ready_priority_group;
#if RT_THREAD_PRIORITY_MAX > 32
@ -170,8 +178,8 @@ void rt_system_scheduler_init(void)
rt_base_t offset;
rt_scheduler_lock_nest = 0;
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("start scheduler: max priority 0x%02x\n",
RT_THREAD_PRIORITY_MAX));
LOG_D("start scheduler: max priority 0x%02x",
RT_THREAD_PRIORITY_MAX);
for (offset = 0; offset < RT_THREAD_PRIORITY_MAX; offset ++)
{
@ -277,13 +285,12 @@ void rt_schedule(void)
to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK);
/* switch to new thread */
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER,
("[%d]switch to priority#%d "
LOG_D("[%d]switch to priority#%d "
"thread:%.*s(sp:0x%08x), "
"from thread:%.*s(sp: 0x%08x)\n",
"from thread:%.*s(sp: 0x%08x)",
rt_interrupt_nest, highest_ready_priority,
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
RT_NAME_MAX, from_thread->parent.name, from_thread->sp));
RT_NAME_MAX, from_thread->parent.name, from_thread->sp);
#ifdef RT_USING_OVERFLOW_CHECK
_scheduler_stack_check(to_thread);
@ -324,7 +331,7 @@ void rt_schedule(void)
}
else
{
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
LOG_D("switch in interrupt");
rt_hw_context_switch_interrupt((rt_ubase_t)&from_thread->sp,
(rt_ubase_t)&to_thread->sp, from_thread, to_thread);
@ -384,8 +391,8 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
&(thread->tlist));
}
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n",
RT_NAME_MAX, thread->parent.name, thread->current_priority));
LOG_D("insert thread[%.*s], the priority: %d",
RT_NAME_MAX, thread->parent.name, thread->current_priority);
/* set priority mask */
#if RT_THREAD_PRIORITY_MAX > 32
@ -414,9 +421,9 @@ void rt_schedule_remove_thread(struct rt_thread *thread)
/* disable interrupt */
level = rt_hw_interrupt_disable();
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n",
LOG_D("remove thread[%.*s], the priority: %d",
RT_NAME_MAX, thread->parent.name,
thread->current_priority));
thread->current_priority);
/* remove thread from ready list */
rt_list_remove(&(thread->tlist));

View File

@ -56,6 +56,15 @@
#include <rtthread.h>
#if defined (RT_USING_SLAB)
#define DBG_TAG "kernel.slab"
#ifdef RT_DEBUG_SLAB
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_SLAB) */
#include <rtdbg.h>
/*
* slab allocator implementation
*
@ -336,8 +345,8 @@ rt_slab_t rt_slab_init(const char *name, void *begin_addr, rt_size_t size)
limsize = end_align - begin_align;
npages = limsize / RT_MM_PAGE_SIZE;
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("heap[0x%x - 0x%x], size 0x%x, 0x%x pages\n",
begin_align, end_align, limsize, npages));
LOG_D("heap[0x%x - 0x%x], size 0x%x, 0x%x pages",
begin_align, end_align, limsize, npages);
rt_memset(slab, 0, sizeof(*slab));
/* initialize slab memory object */
@ -364,16 +373,16 @@ rt_slab_t rt_slab_init(const char *name, void *begin_addr, rt_size_t size)
slab->zone_page_cnt = slab->zone_size / RT_MM_PAGE_SIZE;
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("zone size 0x%x, zone page count 0x%x\n",
slab->zone_size, slab->zone_page_cnt));
LOG_D("zone size 0x%x, zone page count 0x%x",
slab->zone_size, slab->zone_page_cnt);
/* allocate slab->memusage array */
limsize = npages * sizeof(struct rt_slab_memusage);
limsize = RT_ALIGN(limsize, RT_MM_PAGE_SIZE);
slab->memusage = rt_slab_page_alloc((rt_slab_t)(&slab->parent), limsize / RT_MM_PAGE_SIZE);
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("slab->memusage 0x%x, size 0x%x\n",
(rt_ubase_t)slab->memusage, limsize));
LOG_D("slab->memusage 0x%x, size 0x%x",
(rt_ubase_t)slab->memusage, limsize);
return &slab->parent;
}
RTM_EXPORT(rt_slab_init);
@ -511,11 +520,10 @@ void *rt_slab_alloc(rt_slab_t m, rt_size_t size)
kup->type = PAGE_TYPE_LARGE;
kup->size = size >> RT_MM_PAGE_BITS;
RT_DEBUG_LOG(RT_DEBUG_SLAB,
("alloc a large memory 0x%x, page cnt %d, kup %d\n",
LOG_D("alloc a large memory 0x%x, page cnt %d, kup %d",
size,
size >> RT_MM_PAGE_BITS,
((rt_ubase_t)chunk - slab->heap_start) >> RT_MM_PAGE_BITS));
((rt_ubase_t)chunk - slab->heap_start) >> RT_MM_PAGE_BITS);
/* mem stat */
slab->parent.used += size;
if (slab->parent.used > slab->parent.max)
@ -534,7 +542,7 @@ void *rt_slab_alloc(rt_slab_t m, rt_size_t size)
zi = zoneindex(&size);
RT_ASSERT(zi < RT_SLAB_NZONES);
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("try to alloc 0x%x on zone: %d\n", size, zi));
LOG_D("try to alloc 0x%x on zone: %d", size, zi);
if ((z = slab->zone_array[zi]) != RT_NULL)
{
@ -600,8 +608,8 @@ void *rt_slab_alloc(rt_slab_t m, rt_size_t size)
return RT_NULL;
}
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("alloc a new zone: 0x%x\n",
(rt_ubase_t)z));
LOG_D("alloc a new zone: 0x%x",
(rt_ubase_t)z);
/* set message usage */
for (off = 0, kup = btokup(z); off < slab->zone_page_cnt; off ++)
@ -743,14 +751,13 @@ void rt_slab_free(rt_slab_t m, void *ptr)
return ;
/* get memory usage */
#if RT_DEBUG_SLAB
#ifdef RT_DEBUG_SLAB
{
rt_ubase_t addr = ((rt_ubase_t)ptr & ~RT_MM_PAGE_MASK);
RT_DEBUG_LOG(RT_DEBUG_SLAB,
("free a memory 0x%x and align to 0x%x, kup index %d\n",
LOG_D("free a memory 0x%x and align to 0x%x, kup index %d",
(rt_ubase_t)ptr,
(rt_ubase_t)addr,
((rt_ubase_t)(addr) - slab->heap_start) >> RT_MM_PAGE_BITS));
((rt_ubase_t)(addr) - slab->heap_start) >> RT_MM_PAGE_BITS);
}
#endif /* RT_DEBUG_SLAB */
@ -766,9 +773,8 @@ void rt_slab_free(rt_slab_t m, void *ptr)
/* mem stats */
slab->parent.used -= size * RT_MM_PAGE_SIZE;
RT_DEBUG_LOG(RT_DEBUG_SLAB,
("free large memory block 0x%x, page count %d\n",
(rt_ubase_t)ptr, size));
LOG_D("free large memory block 0x%x, page count %d",
(rt_ubase_t)ptr, size);
/* free this page */
rt_slab_page_free(m, ptr, size);
@ -808,8 +814,8 @@ void rt_slab_free(rt_slab_t m, void *ptr)
{
struct rt_slab_zone **pz;
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("free zone 0x%x\n",
(rt_ubase_t)z, z->z_zoneindex));
LOG_D("free zone 0x%x",
(rt_ubase_t)z, z->z_zoneindex);
/* remove zone from zone array list */
for (pz = &slab->zone_array[z->z_zoneindex]; z != *pz; pz = &(*pz)->z_next)

View File

@ -38,6 +38,14 @@
#include <rtthread.h>
#include <stddef.h>
#define DBG_TAG "kernel.thread"
#ifdef RT_DEBUG_THREAD
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_THREAD) */
#include <rtdbg.h>
#ifndef __on_rt_thread_inited_hook
#define __on_rt_thread_inited_hook(thread) __ON_HOOK_ARGS(rt_thread_inited_hook, (thread))
#endif
@ -385,8 +393,8 @@ rt_err_t rt_thread_startup(rt_thread_t thread)
thread->number_mask = 1L << thread->current_priority;
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("startup a thread:%s with priority:%d\n",
thread->parent.name, thread->current_priority));
LOG_D("startup a thread:%s with priority:%d",
thread->parent.name, thread->current_priority);
/* change thread stat */
thread->stat = RT_THREAD_SUSPEND;
/* then resume it */
@ -983,12 +991,12 @@ rt_err_t rt_thread_suspend_with_flag(rt_thread_t thread, int suspend_flag)
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
RT_ASSERT(thread == rt_thread_self());
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->parent.name));
LOG_D("thread suspend: %s", thread->parent.name);
stat = thread->stat & RT_THREAD_STAT_MASK;
if ((stat != RT_THREAD_READY) && (stat != RT_THREAD_RUNNING))
{
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, 0x%2x\n", thread->stat));
LOG_D("thread suspend: thread disorder, 0x%2x", thread->stat);
return -RT_ERROR;
}
@ -1046,12 +1054,12 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
RT_ASSERT(thread != RT_NULL);
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: %s\n", thread->parent.name));
LOG_D("thread resume: %s", thread->parent.name);
if ((thread->stat & RT_THREAD_SUSPEND_MASK) != RT_THREAD_SUSPEND_MASK)
{
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread resume: thread disorder, %d\n",
thread->stat));
LOG_D("thread resume: thread disorder, %d",
thread->stat);
return -RT_ERROR;
}

View File

@ -24,6 +24,14 @@
#include <rtthread.h>
#include <rthw.h>
#define DBG_TAG "kernel.timer"
#ifdef RT_DEBUG_TIMER
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_WARNING
#endif /* defined (RT_DEBUG_TIMER) */
#include <rtdbg.h>
/* hard timer list */
static rt_list_t _timer_list[RT_TIMER_SKIP_LIST_LEVEL];
@ -195,7 +203,7 @@ rt_inline void _timer_remove(rt_timer_t timer)
}
}
#if RT_DEBUG_TIMER
#ifdef RT_DEBUG_TIMER
/**
* @brief The number of timer
*
@ -653,7 +661,7 @@ void rt_timer_check(void)
rt_list_init(&list);
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check enter\n"));
LOG_D("timer check enter");
current_tick = rt_tick_get();
@ -688,7 +696,7 @@ void rt_timer_check(void)
current_tick = rt_tick_get();
RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
LOG_D("current tick: %d", current_tick);
/* Check whether the timer object is detached or started again */
if (rt_list_isempty(&list))
@ -710,7 +718,7 @@ void rt_timer_check(void)
/* enable interrupt */
rt_hw_interrupt_enable(level);
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check leave\n"));
LOG_D("timer check leave");
}
/**
@ -739,7 +747,7 @@ void rt_soft_timer_check(void)
rt_list_init(&list);
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check enter\n"));
LOG_D("software timer check enter");
/* disable interrupt */
level = rt_hw_interrupt_disable();
@ -776,7 +784,7 @@ void rt_soft_timer_check(void)
t->timeout_func(t->parameter);
RT_OBJECT_HOOK_CALL(rt_timer_exit_hook, (t));
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
LOG_D("current tick: %d", current_tick);
/* disable interrupt */
level = rt_hw_interrupt_disable();
@ -801,7 +809,7 @@ void rt_soft_timer_check(void)
/* enable interrupt */
rt_hw_interrupt_enable(level);
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n"));
LOG_D("software timer check leave");
}
/**