/* Copyright 1999 Pace Micro Technology plc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *  AsmUtils (irqs.h)
 *
 * Copyright (C) Pace Micro Technology plc. 1999
 *
 */
#ifndef asmutils_irqs_h_inluded
#define asmutils_irqs_h_inluded

#ifdef __cplusplus
extern "C" {
#endif

/* Support for interrupt status management */

/* Firstly, the Acorn Network Computing way of doing it
 * irqs_off returns a value which is to be passed to irqs_on to restore
 * the state that existed before irqs_off was called.  The value is
 * opaque (and WILL differ depending on the No32bitCode/No26bitCode macros)
 * and may not be inspected - even to determine whether it is zero or not -
 * as it may contain further information.
 */
extern int irqs_off(void);
extern void irqs_on(int);

/* Secondly, the other common method which provides an extra alternative:
 * ensure_irqs_off forces IRQs to be disabled, restore_irqs takes the
 * return value from the former and restores the IRQ state, ensure_irqs_on
 * always enables IRQs and returns a value that can be passed to
 * restore_irqs later to restore the state.
 *
 * As for the ANC veneers, the value returned is opaque and must not be
 * interpreted in any way.
 */
extern int ensure_irqs_off(void);
extern int ensure_irqs_on(void);
extern void restore_irqs(int);

#ifdef __cplusplus
}
#endif

#endif
