Mercurial > ecos
comparison packages/hal/i386/pc/current/src/var_misc.c @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // var_misc.c | |
| 4 // | |
| 5 // HAL implementation miscellaneous functions | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://www.redhat.com/ | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): nickg | |
| 35 // Contributors: nickg, jlarmour, pjo | |
| 36 // Date: 1999-01-21 | |
| 37 // Purpose: HAL miscellaneous functions | |
| 38 // Description: This file contains miscellaneous functions provided by the | |
| 39 // HAL. | |
| 40 // | |
| 41 //####DESCRIPTIONEND#### | |
| 42 // | |
| 43 //========================================================================*/ | |
| 44 | |
| 45 #include <pkgconf/hal.h> | |
| 46 | |
| 47 #include <cyg/infra/cyg_type.h> // Base types | |
| 48 #include <cyg/infra/cyg_trac.h> // tracing macros | |
| 49 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 50 | |
| 51 #include <cyg/hal/hal_intr.h> | |
| 52 | |
| 53 #include <cyg/hal/plf_misc.h> | |
| 54 | |
| 55 /*------------------------------------------------------------------------*/ | |
| 56 // Array which stores the configured priority levels for the configured | |
| 57 // interrupts. | |
| 58 | |
| 59 volatile CYG_BYTE hal_interrupt_level[CYGNUM_HAL_ISR_COUNT]; | |
| 60 | |
| 61 /*------------------------------------------------------------------------*/ | |
| 62 | |
| 63 void hal_variant_init(void) | |
| 64 { | |
| 65 #ifdef CYGPKG_KERNEL | |
| 66 { int i ; | |
| 67 | |
| 68 // Write all of the interrupt vectors to point to us. | |
| 69 for (i = 0; i < CYGNUM_HAL_ISR_COUNT; i++) | |
| 70 { hal_pc_interrupt_attach(i, (CYG_ADDRESS)cyg_hal_default_isr, 0, 0) ; | |
| 71 } | |
| 72 } | |
| 73 #endif /* CYGPKG_KERNEL */ | |
| 74 } | |
| 75 | |
| 76 | |
| 77 // pjo, 5 oct 1999 | |
| 78 | |
| 79 void hal_pc_clock_initialize(cyg_uint32 period) | |
| 80 { | |
| 81 /* Select mode 3: square wave. Then we'll load LSB, and finally MSB. */ | |
| 82 pc_outb(PC_PIT_CONTROL, 0x36) ; | |
| 83 pc_outb(PC_PIT_CLOCK_0, period); /* Only the LSB makes it to the bus. */ | |
| 84 pc_outb(PC_PIT_CLOCK_0, period >> 8); /* Now the second 8 bits. */ | |
| 85 } | |
| 86 | |
| 87 | |
| 88 void hal_pc_clock_read(cyg_uint32 * count) | |
| 89 { | |
| 90 cyg_uint32 curr ; | |
| 91 cyg_uint32 interruptState ; | |
| 92 | |
| 93 /* Hold off on interrupts for a bit. */ | |
| 94 HAL_DISABLE_INTERRUPTS(interruptState) ; | |
| 95 | |
| 96 /* Latch counter 0. */ | |
| 97 pc_outb(PC_PIT_CONTROL, 0x00); | |
| 98 | |
| 99 /* Now get the value. */ | |
| 100 curr = pc_inb(PC_PIT_CLOCK_0) & 0xFF ; | |
| 101 curr |= ((pc_inb(PC_PIT_CLOCK_0) & 0xFF) << 8); | |
| 102 | |
| 103 /* (Maybe) restore interrupts. */ | |
| 104 HAL_RESTORE_INTERRUPTS(interruptState) ; | |
| 105 | |
| 106 count[0] = CYGNUM_HAL_RTC_PERIOD - curr ; | |
| 107 } | |
| 108 | |
| 109 #if 0 | |
| 110 void hal_idle_thread_action(cyg_uint32 loop_count) | |
| 111 { asm("hlt") ; | |
| 112 } | |
| 113 #endif | |
| 114 | |
| 115 void hal_ctrlc_isr_init(void) | |
| 116 { | |
| 117 } | |
| 118 | |
| 119 | |
| 120 /*------------------------------------------------------------------------*/ | |
| 121 /* End of var_misc.c */ |
