Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

57 rindas
2.1 KiB

  1. /*
  2. * libcaca
  3. * libcaca Colour ASCII-Art library
  4. * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
  5. * 2009 Jean-Yves Lamoureux <jylam@lnxscene.org>
  6. * All Rights Reserved
  7. *
  8. * $Id: kernel.h 4154 2009-12-20 13:33:11Z jylam $
  9. *
  10. * This library is free software. It comes without any warranty, to
  11. * the extent permitted by applicable law. You can redistribute it
  12. * and/or modify it under the terms of the Do What The Fuck You Want
  13. * To Public License, Version 2, as published by Sam Hocevar. See
  14. * http://sam.zoy.org/wtfpl/COPYING for more details.
  15. */
  16. #include "kernel.h"
  17. #include "klibc.h"
  18. #include "timer.h"
  19. u32 ticks = 0;
  20. void timer_phase(int hz)
  21. {
  22. unsigned int divisor = 1193180 / hz; /* Calculate our divisor */
  23. /*
  24. 0x43 is the Mode/Command register
  25. From http://wiki.osdev.org/Programmable_Interval_Timer#Read_Back_Status_Byte :
  26. Bits Usage
  27. 6 and 7 Select channel :
  28. 0 0 = Channel 0
  29. 0 1 = Channel 1
  30. 1 0 = Channel 2
  31. 1 1 = Read-back command (8254 only)
  32. 4 and 5 Access mode :
  33. 0 0 = Latch count value command
  34. 0 1 = Access mode: lobyte only
  35. 1 0 = Access mode: hibyte only
  36. 1 1 = Access mode: lobyte/hibyte
  37. 1 to 3 Operating mode :
  38. 0 0 0 = Mode 0 (interrupt on terminal count)
  39. 0 0 1 = Mode 1 (hardware re-triggerable one-shot)
  40. 0 1 0 = Mode 2 (rate generator)
  41. 0 1 1 = Mode 3 (square wave generator)
  42. 1 0 0 = Mode 4 (software triggered strobe)
  43. 1 0 1 = Mode 5 (hardware triggered strobe)
  44. 1 1 0 = Mode 2 (rate generator, same as 010b)
  45. 1 1 1 = Mode 3 (square wave generator, same as 011b)
  46. 0 BCD/Binary mode: 0 = 16-bit binary, 1 = four-digit BCD
  47. */
  48. unsigned short command = 0b00110110;
  49. outb(0x43, command);
  50. outb(0x40, divisor & 0xFF); /* Set low byte of divisor */
  51. outb(0x40, divisor >> 8); /* Set high byte of divisor */
  52. }