/drivers/video/drm/i915/Makefile |
---|
1,8 → 1,8 |
CC = kos32-gcc |
FASM = fasm.exe |
DEFINES = -DDRM_DEBUG_CODE=0 -D__KERNEL__ -DCONFIG_X86_32 -DCONFIG_PCI -DCONFIG_X86_CMPXCHG64 |
DEFINES += -DCONFIG_TINY_RCU -DCONFIG_X86_L1_CACHE_SHIFT=6 |
DEFINES = -DDRM_DEBUG_CODE=0 -D__KERNEL__ -DCONFIG_X86 -DCONFIG_X86_32 -DCONFIG_PCI |
DEFINES += -DCONFIG_X86_CMPXCHG64 -DCONFIG_TINY_RCU -DCONFIG_X86_L1_CACHE_SHIFT=6 |
DEFINES += -DCONFIG_DRM_FBDEV_EMULATION -DCONFIG_DMI |
DEFINES += -DKBUILD_MODNAME=\"i915.dll\" |
92,6 → 92,7 |
intel_frontbuffer.c \ |
intel_guc_loader.c \ |
intel_hdmi.c \ |
intel_hotplug.c \ |
intel_i2c.c \ |
intel_lrc.c \ |
intel_lvds.c \ |
/drivers/video/drm/i915/i915_dma.c |
---|
334,7 → 334,7 |
goto cleanup_gem; |
/* Only enable hotplug handling once the fbdev is fully set up. */ |
// intel_hpd_init(dev_priv); |
intel_hpd_init(dev_priv); |
/* |
* Some ports require correctly set-up hpd registers for detection to |
360,7 → 360,7 |
cleanup_irq: |
// drm_irq_uninstall(dev); |
cleanup_gem_stolen: |
// i915_gem_cleanup_stolen(dev); |
i915_gem_cleanup_stolen(dev); |
cleanup_vga_switcheroo: |
// vga_switcheroo_unregister_client(dev->pdev); |
cleanup_vga_client: |
900,7 → 900,7 |
* so there is no point in running more than one instance of the |
* workqueue at any time. Use an ordered one. |
*/ |
dev_priv->wq = (struct workqueue_struct *)alloc_ordered_workqueue("i915", 0); |
dev_priv->wq = alloc_ordered_workqueue("i915", 0); |
if (dev_priv->wq == NULL) { |
DRM_ERROR("Failed to create our workqueue.\n"); |
ret = -ENOMEM; |
908,6 → 908,12 |
} |
system_wq = dev_priv->wq; |
dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0); |
if (dev_priv->hotplug.dp_wq == NULL) { |
DRM_ERROR("Failed to create our dp workqueue.\n"); |
ret = -ENOMEM; |
goto out_freewq; |
} |
intel_irq_init(dev_priv); |
intel_uncore_sanitize(dev); |
971,8 → 977,10 |
return 0; |
out_power_well: |
drm_vblank_cleanup(dev); |
out_gem_unload: |
out_freewq: |
out_mtrrfree: |
out_gtt: |
i915_global_gtt_cleanup(dev); |
/drivers/video/drm/i915/i915_drv.h |
---|
53,15 → 53,6 |
#include <linux/spinlock.h> |
#include <linux/err.h> |
extern int i915_fbsize; |
extern struct drm_i915_gem_object *main_fb_obj; |
extern struct drm_framebuffer *main_framebuffer; |
static struct drm_i915_gem_object *get_fb_obj() |
{ |
return main_fb_obj; |
}; |
#define ioread32(addr) readl(addr) |
static inline u8 inb(u16 port) |
{ |
2692,7 → 2683,6 |
bool nuclear_pageflip; |
int edp_vswing; |
/* Kolibri related */ |
int fbsize; |
char *log_file; |
char *cmdline_mode; |
}; |
/drivers/video/drm/i915/i915_gem.c |
---|
173,6 → 173,128 |
return 0; |
} |
static int |
i915_gem_object_get_pages_phys(struct drm_i915_gem_object *obj) |
{ |
char *vaddr = obj->phys_handle->vaddr; |
struct sg_table *st; |
struct scatterlist *sg; |
int i; |
if (WARN_ON(i915_gem_object_needs_bit17_swizzle(obj))) |
return -EINVAL; |
st = kmalloc(sizeof(*st), GFP_KERNEL); |
if (st == NULL) |
return -ENOMEM; |
if (sg_alloc_table(st, 1, GFP_KERNEL)) { |
kfree(st); |
return -ENOMEM; |
} |
sg = st->sgl; |
sg->offset = 0; |
sg->length = obj->base.size; |
sg_dma_address(sg) = obj->phys_handle->busaddr; |
sg_dma_len(sg) = obj->base.size; |
obj->pages = st; |
return 0; |
} |
static void |
i915_gem_object_put_pages_phys(struct drm_i915_gem_object *obj) |
{ |
int ret; |
BUG_ON(obj->madv == __I915_MADV_PURGED); |
ret = i915_gem_object_set_to_cpu_domain(obj, true); |
if (ret) { |
/* In the event of a disaster, abandon all caches and |
* hope for the best. |
*/ |
WARN_ON(ret != -EIO); |
obj->base.read_domains = obj->base.write_domain = I915_GEM_DOMAIN_CPU; |
} |
if (obj->madv == I915_MADV_DONTNEED) |
obj->dirty = 0; |
if (obj->dirty) { |
obj->dirty = 0; |
} |
sg_free_table(obj->pages); |
kfree(obj->pages); |
} |
static void |
i915_gem_object_release_phys(struct drm_i915_gem_object *obj) |
{ |
drm_pci_free(obj->base.dev, obj->phys_handle); |
} |
static const struct drm_i915_gem_object_ops i915_gem_phys_ops = { |
.get_pages = i915_gem_object_get_pages_phys, |
.put_pages = i915_gem_object_put_pages_phys, |
.release = i915_gem_object_release_phys, |
}; |
static int |
drop_pages(struct drm_i915_gem_object *obj) |
{ |
struct i915_vma *vma, *next; |
int ret; |
drm_gem_object_reference(&obj->base); |
list_for_each_entry_safe(vma, next, &obj->vma_list, vma_link) |
if (i915_vma_unbind(vma)) |
break; |
ret = i915_gem_object_put_pages(obj); |
drm_gem_object_unreference(&obj->base); |
return ret; |
} |
int |
i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, |
int align) |
{ |
drm_dma_handle_t *phys; |
int ret; |
if (obj->phys_handle) { |
if ((unsigned long)obj->phys_handle->vaddr & (align -1)) |
return -EBUSY; |
return 0; |
} |
if (obj->madv != I915_MADV_WILLNEED) |
return -EFAULT; |
if (obj->base.filp == NULL) |
return -EINVAL; |
ret = drop_pages(obj); |
if (ret) |
return ret; |
/* create a new object */ |
phys = drm_pci_alloc(obj->base.dev, obj->base.size, align); |
if (!phys) |
return -ENOMEM; |
obj->phys_handle = phys; |
obj->ops = &i915_gem_phys_ops; |
return i915_gem_object_get_pages(obj); |
} |
void *i915_gem_object_alloc(struct drm_device *dev) |
{ |
struct drm_i915_private *dev_priv = dev->dev_private; |
633,7 → 755,6 |
return ret ? -EFAULT : 0; |
} |
#if 0 |
/* Only difference to the fast-path function is that this can handle bit17 |
* and uses non-atomic copy and kmap functions. */ |
668,9 → 789,7 |
return ret ? -EFAULT : 0; |
} |
#endif |
static int |
i915_gem_shmem_pwrite(struct drm_device *dev, |
struct drm_i915_gem_object *obj, |
757,13 → 876,11 |
hit_slowpath = 1; |
mutex_unlock(&dev->struct_mutex); |
dbgprintf("%s need shmem_pwrite_slow\n",__FUNCTION__); |
ret = shmem_pwrite_slow(page, shmem_page_offset, page_length, |
user_data, page_do_bit17_swizzling, |
partial_cacheline_write, |
needs_clflush_after); |
// ret = shmem_pwrite_slow(page, shmem_page_offset, page_length, |
// user_data, page_do_bit17_swizzling, |
// partial_cacheline_write, |
// needs_clflush_after); |
mutex_lock(&dev->struct_mutex); |
if (ret) |
862,8 → 979,9 |
* textures). Fallback to the shmem path in that case. */ |
} |
if (ret == -EFAULT || ret == -ENOSPC) |
if (ret == -EFAULT || ret == -ENOSPC) { |
ret = i915_gem_shmem_pwrite(dev, obj, args, file); |
} |
out: |
drm_gem_object_unreference(&obj->base); |
1747,6 → 1865,10 |
} |
i915_gem_gtt_finish_object(obj); |
if (i915_gem_object_needs_bit17_swizzle(obj)) |
i915_gem_object_save_bit_17_swizzle(obj); |
if (obj->madv == I915_MADV_DONTNEED) |
obj->dirty = 0; |
1859,6 → 1981,9 |
if (ret) |
goto err_pages; |
if (i915_gem_object_needs_bit17_swizzle(obj)) |
i915_gem_object_do_bit_17_swizzle(obj); |
if (obj->tiling_mode != I915_TILING_NONE && |
dev_priv->quirks & QUIRK_PIN_SWIZZLED_PAGES) |
i915_gem_object_pin_pages(obj); |
/drivers/video/drm/i915/i915_gem_execbuffer.c |
---|
40,13 → 40,6 |
#define BATCH_OFFSET_BIAS (256*1024) |
static unsigned long |
copy_from_user(void *to, const void __user *from, unsigned long n) |
{ |
memcpy(to, from, n); |
return 0; |
} |
struct eb_vmas { |
struct list_head vmas; |
int and; |
/drivers/video/drm/i915/i915_gem_fence.c |
---|
758,6 → 758,7 |
if ((new_bit_17 & 0x1) != |
(test_bit(i, obj->bit_17) != 0)) { |
i915_gem_swizzle_page(page); |
set_page_dirty(page); |
} |
i++; |
} |
/drivers/video/drm/i915/i915_irq.c |
---|
1445,7 → 1445,7 |
*pin_mask |= BIT(i); |
// if (!intel_hpd_pin_to_port(i, &port)) |
if (!intel_hpd_pin_to_port(i, &port)) |
continue; |
if (long_pulse_detect(port, dig_hotplug_reg)) |
1699,7 → 1699,7 |
hotplug_trigger, hpd_status_g4x, |
i9xx_port_hotplug_long_detect); |
// intel_hpd_irq_handler(dev, pin_mask, long_mask); |
intel_hpd_irq_handler(dev, pin_mask, long_mask); |
} |
if (hotplug_status & DP_AUX_CHANNEL_MASK_INT_STATUS_G4X) |
1711,7 → 1711,7 |
intel_get_hpd_pins(&pin_mask, &long_mask, hotplug_trigger, |
hotplug_trigger, hpd_status_i915, |
i9xx_port_hotplug_long_detect); |
// intel_hpd_irq_handler(dev, pin_mask, long_mask); |
intel_hpd_irq_handler(dev, pin_mask, long_mask); |
} |
} |
} |
1819,7 → 1819,7 |
dig_hotplug_reg, hpd, |
pch_port_hotplug_long_detect); |
// intel_hpd_irq_handler(dev, pin_mask, long_mask); |
intel_hpd_irq_handler(dev, pin_mask, long_mask); |
} |
static void ibx_irq_handler(struct drm_device *dev, u32 pch_iir) |
1984,6 → 1984,9 |
spt_port_hotplug2_long_detect); |
} |
if (pin_mask) |
intel_hpd_irq_handler(dev, pin_mask, long_mask); |
if (pch_iir & SDE_GMBUS_CPT) |
gmbus_irq_handler(dev); |
} |
2001,6 → 2004,7 |
dig_hotplug_reg, hpd, |
ilk_port_hotplug_long_detect); |
intel_hpd_irq_handler(dev, pin_mask, long_mask); |
} |
static void ilk_display_irq_handler(struct drm_device *dev, u32 de_iir) |
2009,8 → 2013,8 |
enum pipe pipe; |
u32 hotplug_trigger = de_iir & DE_DP_A_HOTPLUG; |
// if (hotplug_trigger) |
// ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_ilk); |
if (hotplug_trigger) |
ilk_hpd_irq_handler(dev, hotplug_trigger, hpd_ilk); |
if (de_iir & DE_AUX_CHANNEL_A) |
dp_aux_irq_handler(dev); |
2189,6 → 2193,7 |
dig_hotplug_reg, hpd, |
bxt_port_hotplug_long_detect); |
intel_hpd_irq_handler(dev, pin_mask, long_mask); |
} |
static irqreturn_t gen8_irq_handler(int irq, void *arg) |
4316,7 → 4321,7 |
{ |
struct drm_device *dev = dev_priv->dev; |
// intel_hpd_init_work(dev_priv); |
intel_hpd_init_work(dev_priv); |
INIT_WORK(&dev_priv->rps.work, gen6_pm_rps_work); |
INIT_WORK(&dev_priv->l3_parity.error_work, ivybridge_parity_work); |
/drivers/video/drm/i915/i915_params.c |
---|
55,7 → 55,6 |
.edp_vswing = 0, |
.enable_guc_submission = false, |
.guc_log_level = -1, |
.fbsize = 16, |
.log_file = NULL, |
.cmdline_mode = NULL, |
}; |
/drivers/video/drm/i915/intel_display.c |
---|
3301,7 → 3301,7 |
intel_display_resume(dev); |
// intel_hpd_init(dev_priv); |
intel_hpd_init(dev_priv); |
drm_modeset_unlock_all(dev); |
} |
14442,7 → 14442,6 |
return ret; |
} |
kolibri_framebuffer_init(intel_fb); |
return 0; |
} |
/drivers/video/drm/i915/intel_dp.c |
---|
4639,8 → 4639,23 |
{ |
struct intel_encoder *intel_encoder = &intel_dig_port->base; |
enum port port; |
u32 bit = 0; |
u32 bit; |
intel_hpd_pin_to_port(intel_encoder->hpd_pin, &port); |
switch (port) { |
case PORT_A: |
bit = BXT_DE_PORT_HP_DDIA; |
break; |
case PORT_B: |
bit = BXT_DE_PORT_HP_DDIB; |
break; |
case PORT_C: |
bit = BXT_DE_PORT_HP_DDIC; |
break; |
default: |
MISSING_CASE(port); |
return false; |
} |
return I915_READ(GEN8_DE_PORT_ISR) & bit; |
} |
6100,6 → 6115,8 |
I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd); |
} |
i915_debugfs_connector_add(connector); |
return true; |
} |
/drivers/video/drm/i915/intel_fbdev.c |
---|
44,32 → 44,6 |
#include <drm/i915_drm.h> |
#include "i915_drv.h" |
struct fb_info *framebuffer_alloc(size_t size, struct device *dev) |
{ |
#define BYTES_PER_LONG (BITS_PER_LONG/8) |
#define PADDING (BYTES_PER_LONG - (sizeof(struct fb_info) % BYTES_PER_LONG)) |
int fb_info_size = sizeof(struct fb_info); |
struct fb_info *info; |
char *p; |
if (size) |
fb_info_size += PADDING; |
p = kzalloc(fb_info_size + size, GFP_KERNEL); |
if (!p) |
return NULL; |
info = (struct fb_info *) p; |
if (size) |
info->par = p + fb_info_size; |
return info; |
#undef PADDING |
#undef BYTES_PER_LONG |
} |
static int intel_fbdev_set_par(struct fb_info *info) |
{ |
struct drm_fb_helper *fb_helper = info->par; |
267,6 → 241,8 |
info->apertures->ranges[0].base = dev->mode_config.fb_base; |
info->apertures->ranges[0].size = dev_priv->gtt.mappable_end; |
info->fix.smem_start = dev->mode_config.fb_base + i915_gem_obj_ggtt_offset(obj); |
info->fix.smem_len = size; |
info->screen_base = (void*) 0xFE000000; |
info->screen_size = size; |
526,6 → 502,19 |
.fb_probe = intelfb_create, |
}; |
static void intel_fbdev_destroy(struct drm_device *dev, |
struct intel_fbdev *ifbdev) |
{ |
drm_fb_helper_unregister_fbi(&ifbdev->helper); |
drm_fb_helper_release_fbi(&ifbdev->helper); |
drm_fb_helper_fini(&ifbdev->helper); |
drm_framebuffer_unregister_private(&ifbdev->fb->base); |
drm_framebuffer_remove(&ifbdev->fb->base); |
} |
/* |
* Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible. |
* The core display code will have read out the current plane configuration, |
/drivers/video/drm/i915/intel_runtime_pm.c |
---|
894,7 → 894,7 |
if (dev_priv->power_domains.initializing) |
return; |
// intel_hpd_init(dev_priv); |
intel_hpd_init(dev_priv); |
i915_redisable_vga_power_on(dev_priv->dev); |
} |
/drivers/video/drm/i915/kms_display.c |
---|
88,7 → 88,7 |
size = stride * ALIGN(mode->vdisplay, 2); |
} |
dbgprintf("size %x stride %x\n", size, stride); |
DRM_DEBUG_KMS("size %x stride %x\n", size, stride); |
if(intel_fb == NULL || size > intel_fb->obj->base.size) |
{ |
148,6 → 148,20 |
obj->stride = stride; |
}; |
if (obj->base.name == 0) |
{ |
int ret; |
mutex_lock(&dev->object_name_lock); |
idr_preload(GFP_KERNEL); |
ret = idr_alloc(&dev->object_name_idr, &obj->base, 1, 0, GFP_NOWAIT); |
idr_preload_end(); |
mutex_unlock(&dev->object_name_lock); |
obj->base.name = ret; |
obj->base.handle_count++; |
DRM_DEBUG_KMS("%s allocate fb name %d\n", __FUNCTION__, obj->base.name ); |
} |
fb->width = mode->hdisplay; |
fb->height = mode->vdisplay; |
561,19 → 575,6 |
return -1; |
}; |
/* |
mutex_lock(&dev->object_name_lock); |
idr_preload(GFP_KERNEL); |
if (!main_fb_obj->base.name) { |
ret = idr_alloc(&dev->object_name_idr, &main_fb_obj->base, 1, 0, GFP_NOWAIT); |
main_fb_obj->base.name = ret; |
main_fb_obj->base.handle_count++; |
DRM_DEBUG_KMS("%s allocate fb name %d\n", __FUNCTION__, main_fb_obj->base.name ); |
} |
idr_preload_end(); |
mutex_unlock(&dev->object_name_lock); |
*/ |
dummy_fb_page = AllocPage(); |
os_display = GetDisplay(); |
820,10 → 821,10 |
fb->pipe = crtc->pipe; |
} |
safe_sti(ifl); |
return 0; |
} |
int kolibri_framebuffer_init(struct intel_framebuffer *intel_fb) |
{ |
struct kos_framebuffer *kfb; |
830,7 → 831,7 |
addr_t dummy_table; |
addr_t *pt_addr = NULL; |
int pde; |
ENTER(); |
kfb = kzalloc(sizeof(struct kos_framebuffer),0); |
kfb->private = intel_fb; |
845,7 → 846,7 |
}; |
intel_fb->private = kfb; |
LEAVE(); |
return 0; |
#if 0 |
struct sg_page_iter sg_iter; |
/drivers/video/drm/i915/kos_cursor.c |
---|
71,7 → 71,8 |
static int init_cursor(cursor_t *cursor) |
{ |
display_t *display = GetDisplay(); |
struct drm_i915_private *dev_priv = display->ddev->dev_private; |
struct drm_device *dev = display->ddev; |
struct drm_i915_private *dev_priv = dev->dev_private; |
struct drm_i915_gem_object *obj; |
uint32_t *bits; |
uint32_t *src; |
80,11 → 81,16 |
int i,j; |
int ret; |
mutex_lock(&dev->struct_mutex); |
if (dev_priv->info.cursor_needs_physical) |
{ |
bits = (uint32_t*)KernelAlloc(KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*8); |
if (unlikely(bits == NULL)) |
return ENOMEM; |
{ |
ret = -ENOMEM; |
goto unlock; |
}; |
cursor->cobj = (struct drm_i915_gem_object *)GetPgAddr(bits); |
} |
else |
91,21 → 97,19 |
{ |
obj = i915_gem_alloc_object(display->ddev, KMS_CURSOR_WIDTH*KMS_CURSOR_HEIGHT*4); |
if (unlikely(obj == NULL)) |
return -ENOMEM; |
{ |
ret = -ENOMEM; |
goto unlock; |
}; |
ret = i915_gem_object_ggtt_pin(obj, &i915_ggtt_view_normal, 128*1024, PIN_GLOBAL); |
if (ret) { |
drm_gem_object_unreference(&obj->base); |
return ret; |
} |
if (ret) |
goto unref; |
ret = i915_gem_object_set_to_gtt_domain(obj, true); |
if (ret) |
{ |
i915_gem_object_ggtt_unpin(obj); |
drm_gem_object_unreference(&obj->base); |
return ret; |
} |
goto unpin; |
/* You don't need to worry about fragmentation issues. |
* GTT space is continuous. I guarantee it. */ |
114,13 → 118,14 |
if (unlikely(bits == NULL)) |
{ |
i915_gem_object_ggtt_unpin(obj); |
drm_gem_object_unreference(&obj->base); |
return -ENOMEM; |
ret = -ENOMEM; |
goto unpin; |
}; |
cursor->cobj = obj; |
}; |
mutex_unlock(&dev->struct_mutex); |
src = cursor->data; |
for(i = 0; i < 32; i++) |
139,6 → 144,14 |
cursor->header.destroy = destroy_cursor; |
return 0; |
unpin: |
i915_gem_object_ggtt_unpin(obj); |
unref: |
drm_gem_object_unreference(&obj->base); |
unlock: |
mutex_unlock(&dev->struct_mutex); |
return ret; |
} |
void init_system_cursors(struct drm_device *dev) |
150,7 → 163,6 |
display = GetDisplay(); |
mutex_init(&cursor_lock); |
mutex_lock(&dev->struct_mutex); |
ifl = safe_cli(); |
{ |
172,6 → 184,4 |
select_cursor_kms(display->cursor); |
}; |
safe_sti(ifl); |
mutex_unlock(&dev->struct_mutex); |
} |
/drivers/video/drm/i915/main.c |
---|
14,7 → 14,7 |
#include "bitmap.h" |
#include "i915_kos32.h" |
#define DRV_NAME "i915 v4.4.2-dbg2" |
#define DRV_NAME "i915 v4.4.3" |
#define I915_DEV_CLOSE 0 |
#define I915_DEV_INIT 1 |
60,7 → 60,6 |
}; |
dev_priv = main_device->dev_private; |
cwq = dev_priv->wq; |
asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(1),"c"(1)); |
asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(4),"c"(0x46),"d"(0x330)); |
92,9 → 91,9 |
else if(key.code == 0xC6) |
dpms_lock = 0; |
}; |
cwq = dev_priv->wq; |
spin_lock_irqsave(&cwq->lock, irqflags); |
while (!list_empty(&cwq->worklist)) |
{ |
struct work_struct *work = list_entry(cwq->worklist.next, |
106,8 → 105,23 |
f(work); |
spin_lock_irqsave(&cwq->lock, irqflags); |
} |
spin_unlock_irqrestore(&cwq->lock, irqflags); |
cwq = dev_priv->hotplug.dp_wq; |
spin_lock_irqsave(&cwq->lock, irqflags); |
while (!list_empty(&cwq->worklist)) |
{ |
struct work_struct *work = list_entry(cwq->worklist.next, |
struct work_struct, entry); |
work_func_t f = work->func; |
list_del_init(cwq->worklist.next); |
spin_unlock_irqrestore(&cwq->lock, irqflags); |
f(work); |
spin_lock_irqsave(&cwq->lock, irqflags); |
} |
spin_unlock_irqrestore(&cwq->lock, irqflags); |
delay(1); |
}; |
/drivers/video/drm/i915/utils.c |
---|
250,240 → 250,6 |
} |
//const char hex_asc[] = "0123456789abcdef"; |
/** |
* hex_to_bin - convert a hex digit to its real value |
* @ch: ascii character represents hex digit |
* |
* hex_to_bin() converts one hex digit to its actual value or -1 in case of bad |
* input. |
*/ |
int hex_to_bin(char ch) |
{ |
if ((ch >= '0') && (ch <= '9')) |
return ch - '0'; |
ch = tolower(ch); |
if ((ch >= 'a') && (ch <= 'f')) |
return ch - 'a' + 10; |
return -1; |
} |
EXPORT_SYMBOL(hex_to_bin); |
/** |
* hex2bin - convert an ascii hexadecimal string to its binary representation |
* @dst: binary result |
* @src: ascii hexadecimal string |
* @count: result length |
* |
* Return 0 on success, -1 in case of bad input. |
*/ |
int hex2bin(u8 *dst, const char *src, size_t count) |
{ |
while (count--) { |
int hi = hex_to_bin(*src++); |
int lo = hex_to_bin(*src++); |
if ((hi < 0) || (lo < 0)) |
return -1; |
*dst++ = (hi << 4) | lo; |
} |
return 0; |
} |
EXPORT_SYMBOL(hex2bin); |
/** |
* hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory |
* @buf: data blob to dump |
* @len: number of bytes in the @buf |
* @rowsize: number of bytes to print per line; must be 16 or 32 |
* @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1) |
* @linebuf: where to put the converted data |
* @linebuflen: total size of @linebuf, including space for terminating NUL |
* @ascii: include ASCII after the hex output |
* |
* hex_dump_to_buffer() works on one "line" of output at a time, i.e., |
* 16 or 32 bytes of input data converted to hex + ASCII output. |
* |
* Given a buffer of u8 data, hex_dump_to_buffer() converts the input data |
* to a hex + ASCII dump at the supplied memory location. |
* The converted output is always NUL-terminated. |
* |
* E.g.: |
* hex_dump_to_buffer(frame->data, frame->len, 16, 1, |
* linebuf, sizeof(linebuf), true); |
* |
* example output buffer: |
* 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO |
*/ |
int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize, |
char *linebuf, size_t linebuflen, bool ascii) |
{ |
const u8 *ptr = buf; |
int ngroups; |
u8 ch; |
int j, lx = 0; |
int ascii_column; |
int ret; |
if (rowsize != 16 && rowsize != 32) |
rowsize = 16; |
if (len > rowsize) /* limit to one line at a time */ |
len = rowsize; |
if (!is_power_of_2(groupsize) || groupsize > 8) |
groupsize = 1; |
if ((len % groupsize) != 0) /* no mixed size output */ |
groupsize = 1; |
ngroups = len / groupsize; |
ascii_column = rowsize * 2 + rowsize / groupsize + 1; |
if (!linebuflen) |
goto overflow1; |
if (!len) |
goto nil; |
if (groupsize == 8) { |
const u64 *ptr8 = buf; |
for (j = 0; j < ngroups; j++) { |
ret = snprintf(linebuf + lx, linebuflen - lx, |
"%s%16.16llx", j ? " " : "", |
(unsigned long long)*(ptr8 + j)); |
if (ret >= linebuflen - lx) |
goto overflow1; |
lx += ret; |
} |
} else if (groupsize == 4) { |
const u32 *ptr4 = buf; |
for (j = 0; j < ngroups; j++) { |
ret = snprintf(linebuf + lx, linebuflen - lx, |
"%s%8.8x", j ? " " : "", |
*(ptr4 + j)); |
if (ret >= linebuflen - lx) |
goto overflow1; |
lx += ret; |
} |
} else if (groupsize == 2) { |
const u16 *ptr2 = buf; |
for (j = 0; j < ngroups; j++) { |
ret = snprintf(linebuf + lx, linebuflen - lx, |
"%s%4.4x", j ? " " : "", |
*(ptr2 + j)); |
if (ret >= linebuflen - lx) |
goto overflow1; |
lx += ret; |
} |
} else { |
for (j = 0; j < len; j++) { |
if (linebuflen < lx + 3) |
goto overflow2; |
ch = ptr[j]; |
linebuf[lx++] = hex_asc_hi(ch); |
linebuf[lx++] = hex_asc_lo(ch); |
linebuf[lx++] = ' '; |
} |
if (j) |
lx--; |
} |
if (!ascii) |
goto nil; |
while (lx < ascii_column) { |
if (linebuflen < lx + 2) |
goto overflow2; |
linebuf[lx++] = ' '; |
} |
for (j = 0; j < len; j++) { |
if (linebuflen < lx + 2) |
goto overflow2; |
ch = ptr[j]; |
linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.'; |
} |
nil: |
linebuf[lx] = '\0'; |
return lx; |
overflow2: |
linebuf[lx++] = '\0'; |
overflow1: |
return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1; |
} |
/** |
* print_hex_dump - print a text hex dump to syslog for a binary blob of data |
* @level: kernel log level (e.g. KERN_DEBUG) |
* @prefix_str: string to prefix each line with; |
* caller supplies trailing spaces for alignment if desired |
* @prefix_type: controls whether prefix of an offset, address, or none |
* is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE) |
* @rowsize: number of bytes to print per line; must be 16 or 32 |
* @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1) |
* @buf: data blob to dump |
* @len: number of bytes in the @buf |
* @ascii: include ASCII after the hex output |
* |
* Given a buffer of u8 data, print_hex_dump() prints a hex + ASCII dump |
* to the kernel log at the specified kernel log level, with an optional |
* leading prefix. |
* |
* print_hex_dump() works on one "line" of output at a time, i.e., |
* 16 or 32 bytes of input data converted to hex + ASCII output. |
* print_hex_dump() iterates over the entire input @buf, breaking it into |
* "line size" chunks to format and print. |
* |
* E.g.: |
* print_hex_dump(KERN_DEBUG, "raw data: ", DUMP_PREFIX_ADDRESS, |
* 16, 1, frame->data, frame->len, true); |
* |
* Example output using %DUMP_PREFIX_OFFSET and 1-byte mode: |
* 0009ab42: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO |
* Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode: |
* ffffffff88089af0: 73727170 77767574 7b7a7978 7f7e7d7c pqrstuvwxyz{|}~. |
*/ |
void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, |
int rowsize, int groupsize, |
const void *buf, size_t len, bool ascii) |
{ |
const u8 *ptr = buf; |
int i, linelen, remaining = len; |
unsigned char linebuf[32 * 3 + 2 + 32 + 1]; |
if (rowsize != 16 && rowsize != 32) |
rowsize = 16; |
for (i = 0; i < len; i += rowsize) { |
linelen = min(remaining, rowsize); |
remaining -= rowsize; |
hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize, |
linebuf, sizeof(linebuf), ascii); |
switch (prefix_type) { |
case DUMP_PREFIX_ADDRESS: |
printk("%s%s%p: %s\n", |
level, prefix_str, ptr + i, linebuf); |
break; |
case DUMP_PREFIX_OFFSET: |
printk("%s%s%.8x: %s\n", level, prefix_str, i, linebuf); |
break; |
default: |
printk("%s%s%s\n", level, prefix_str, linebuf); |
break; |
} |
} |
} |
void print_hex_dump_bytes(const char *prefix_str, int prefix_type, |
const void *buf, size_t len) |
{ |
print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, 16, 1, |
buf, len, true); |
} |
void *kmemdup(const void *src, size_t len, gfp_t gfp) |
{ |
void *p; |
783,43 → 549,6 |
return 0; |
} |
signed long |
fence_wait_timeout(struct fence *fence, bool intr, signed long timeout) |
{ |
signed long ret; |
if (WARN_ON(timeout < 0)) |
return -EINVAL; |
// trace_fence_wait_start(fence); |
ret = fence->ops->wait(fence, intr, timeout); |
// trace_fence_wait_end(fence); |
return ret; |
} |
void fence_release(struct kref *kref) |
{ |
struct fence *fence = |
container_of(kref, struct fence, refcount); |
// trace_fence_destroy(fence); |
BUG_ON(!list_empty(&fence->cb_list)); |
if (fence->ops->release) |
fence->ops->release(fence); |
else |
fence_free(fence); |
} |
void fence_free(struct fence *fence) |
{ |
kfree_rcu(fence, rcu); |
} |
EXPORT_SYMBOL(fence_free); |
ktime_t ktime_get(void) |
{ |
ktime_t t; |