Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

49 Zeilen
1.9 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
  26. http://wiki.osdev.org/Programmable_Interval_Timer#Read_Back_Status_Byte
  27. : Bits Usage 6 and 7 Select channel : 0 0 = Channel 0 0 1 = Channel 1
  28. 1 0 = Channel 2 1 1 = Read-back command (8254 only) 4 and 5 Access mode
  29. : 0 0 = Latch count value command 0 1 = Access mode: lobyte only 1 0 =
  30. Access mode: hibyte only 1 1 = Access mode: lobyte/hibyte 1 to 3
  31. Operating mode : 0 0 0 = Mode 0 (interrupt on terminal count) 0 0 1 =
  32. Mode 1 (hardware re-triggerable one-shot) 0 1 0 = Mode 2 (rate
  33. generator) 0 1 1 = Mode 3 (square wave generator) 1 0 0 = Mode 4
  34. (software triggered strobe) 1 0 1 = Mode 5 (hardware triggered strobe)
  35. 1 1 0 = Mode 2 (rate generator, same as 010b) 1 1 1 = Mode 3 (square
  36. wave generator, same as 011b) 0 BCD/Binary mode: 0 = 16-bit binary, 1 =
  37. four-digit BCD
  38. */
  39. unsigned short command = 0 b00110110;
  40. outb(0x43, command);
  41. outb(0x40, divisor & 0xFF); /* Set low byte of divisor */
  42. outb(0x40, divisor >> 8); /* Set high byte of divisor */
  43. }