Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1429372
  • 博文数量: 286
  • 博客积分: 3713
  • 博客等级: 少校
  • 技术积分: 2275
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-11 09:47
个人简介

http://blog.chinaunix.net/uid/16979052.html

文章分类

全部博文(286)

文章存档

2018年(1)

2017年(16)

2016年(9)

2015年(17)

2014年(15)

2013年(112)

2012年(116)

分类: LINUX

2012-06-28 08:09:17

#ifndef __KERNEL_PRINTK_INCLUDED__
#define __KERNEL_PRINTK_INCLUDED__

#include
#include

int __printk(const char *file, int line, const char *fmt, ...);

#define printk(fmt, ...) __printk(__FUNCTION__, __LINE__, fmt, ## __VA_ARGS__)

#ifdef JOHNYIN_DBG
#define KPRINTF(fmt, ...) __printk(__FUNCTION__, __LINE__, fmt, ## __VA_ARGS__)
#else
#define KPRINTF(...)
#endif

void* kmalloc(uint32_t nbytes);
void kfree(void *pointer);
void kmemdump();

typedef enum states
{
INVALID=0,
CREATED,
READY,
RUNNING,
WAITING,
BLOCKED,
ZOMBIE,
FINISHED,
} states_t;
typedef enum priority
{
HIGH_PRIO=0,
NORM_PRIO,
LOW_PRIO,
IDLE_PRIO,
} priority_t;

#include
typedef struct thread_t
{
union
{
struct
{
struct list_t link;
uint8_t *stack_top; // top of the stack goes to esp
states_t state;
priority_t prio; /*priority*/
uint32_t id;      // threads id
uint32_t pid;     // parent id if it has one
int num_child;        // number of child threads of this thread
};
uint8_t stack[STACK_SIZE];// a static stack for the thread
};
} thread_t;
thread_t *create_thread(void (* entry)(uint32_t), uint32_t args, priority_t p, int detached);

static inline void dump_regs(struct pt_regs *r)
{
printk("=================CPU State==================\n");
printk("EAX= %x EBX= %x\n", r->eax, r->ebx);
printk("ECX= %x EDX= %x\n", r->ecx, r->edx);
printk("ESP= %x EBP= %x\n", r->esp, r->ebp);
printk("ESI= %x EDI= %x\n", r->esi, r->edi);
printk("EIP= %x CS = %x\n", r->eip, r->cs);
printk("DS = %x ES = %x\n", r->ds, r->es);
printk("FS = %x GS = %x\n", r->fs, r->gs);
printk("Interrupt# = %x\n", r->int_no);
printk("Err.Code   = %x\n", r->err_code);
printk("e-Flags    = %x\n", r->eflags);
printk("============================================\n");
}
static inline void dump_thread(struct thread_t *t)
{
char *msg[] = { "INVALID", "CREATED", "READY", "RUNNING", "WAITING", "BLOCKED", "ZOMBIE", "FINISHED", };
char *msg1[] = { "HIGH", "NORM", "LOW", "IDLE", };
printk("Thread ID  = %d(%s:[%s])\n", t->id, msg[t->state], msg1[t->prio]);
printk("Thread PID = %d\n", t->pid);
dump_regs((struct pt_regs *)t->stack_top);
printk("\n");
}

#endif

阅读(785) | 评论(0) | 转发(0) |
0

上一篇:include/platform.h

下一篇:include/types.h

给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册