Example #1
0
/* testing
 */
void rtl8139_test(void)
{
  net_buf_t* nb_head;
  net_buf_t* nb_tail;
  net_buf_t* nb_pos;
  rtl8139_dev_t* dev;

  TRACE_ENTRY();

  dev = (rtl8139_dev_t*)g_device->priv;

  while (1)
    {
/*       icmp_ping(g_device, NET_REMOTE_ADDR); */
      cpu_hlt();
#if 0
      cpu_cli();
      arp_print_table();
      cpu_sti();
#endif
    }

  while (1)
    {
      nb_head = null;
      nb_tail = null;

      cpu_hlt();

      /* safely get the net buffers */
      cpu_cli();
      if (!is_null(dev->nb_head))
	{
	  for (nb_pos = dev->nb_head; nb_pos->next; nb_pos = nb_pos->next)
	    ;

	  if (!is_null(nb_tail))
	    nb_tail->next = dev->nb_head;
	  else
	    nb_head = dev->nb_head;
	  nb_tail = nb_pos;
	}
      dev->nb_head = null;
      cpu_sti();

      /* print and release net buffers */
      while (nb_head)
	{
	  nb_pos = nb_head;
	  nb_head = nb_head->next;
	  /* hexdump(nb_pos->buf, nb_pos->size); */
	  mm_free(nb_pos->buf);
	  mm_free(nb_pos);
	}

      arp_print_table();
    }
}
Example #2
0
// 调用中断处理函数
void isr_handler(pt_regs_t *regs)
{
        if (interrupt_handlers[regs->int_no]) {
              interrupt_handlers[regs->int_no](regs);
        } else {
                printk_color(rc_black, rc_blue, "Unhandled interrupt: %d %s\n", regs->int_no, intrname(regs->int_no));
                cpu_hlt();
        }
}
Example #3
0
void isr_handler(pt_regs_t *regs){
    
    if(interrupt_handlers[regs->int_no]){
        interrupt_handlers[regs->int_no](regs);
    }else{
        printk("unable interrupt %d %s\n",regs->int_no,intrname(regs->int_no));
        cpu_hlt();
    }
    return ;
}
Example #4
0
File: sched.c Project: texane/muk
error_t sched_yield(void)
{
    task_t* current;
    volatile uint32_t* timeslice;

    current = sched_get_current();
    timeslice = &current->timeslice;
    *timeslice = 0;

    /* fixme: race here
     */
    while (*timeslice == 0)
        cpu_hlt();

    return ERROR_SUCCESS;
}
Example #5
0
// 读取一个字符
char getchar(void)
{
    char ch;
    char_dev_t *kb_dev = &kboard_dev;

    if (!kb_dev->ops.device_valid()) {
        return 0;
    }

    while (kb_dev->ops.read(&ch, 1) == 1) {
        cpu_hlt();
        return ch;
    }

    return 0;
}
Example #6
0
static inline void stop_this_cpu(void)
{
	/* Called by an AP when it is ready to halt and wait for a new task */
	for (;;)
		cpu_hlt();
}
Example #7
0
File: kernel.c Project: Kloniks/muk
void kernel_main(unsigned long magic,
		 unsigned long addr)
{
  multiboot_info_t *mbi;

  if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
    return;

  mbi = (multiboot_info_t*)addr;

  /* kernel init
   */
  serial_init(DEBUG_SERIAL_PORT,
	      DEBUG_SERIAL_SPEED,
	      UART_8BITS_WORD,
	      UART_NO_PARITY,
	      UART_1_STOP_BIT);
  cls();

  cpu_cli();
  printf("[x] interrupts disabled\n");

  gdt_initialize();
  printf("[x] gdt initialized\n");

  idt_initialize();
  printf("[x] idt initialized\n");

  breakpoint_initialize();

#if defined(USE_APIC)
  apic_initialize();
  serial_printl("[x] apic initialized\n");
#else
  pic_initialize();
  serial_printl("[x] pic initialized\n");
#endif /* USE_APIC */

  /* initialize the kernel
   */
  {
    kernel_init(mbi);
  }

  /* memory initialization
   */
  {
    phys_init(mbi);
    phys_debug();
/*     vm_init(); */
/*     unit_test_vm(); */
/*     cpu_hlt(); */
  }

#if defined(USE_PCI)
  pci_initialize();
  pci_list();
#endif

  cpu_sti();

#if defined(USE_TASK)
 {
   /* subsystems
    */
   event_initialize();
   sched_initialize();
   task_initialize();

   /* tasks
    */
   idle_initialize();
   muksh_initialize();
   net_initialize();

/*    task_test(); */

   /* start scheduling
    */
   sched_start();
 }
#endif

 /* endless loop
  */
 serial_printl("[?] kernel loop\n");
 while (1)
   {
     serial_printl("k");
     cpu_hlt();
   }
}