Small improvement of using the compilation switches

This commit is contained in:
Vincent Barrilliot 2023-02-26 21:17:06 +01:00
parent e0c9e7d7c0
commit 600adcf406
5 changed files with 1130 additions and 1131 deletions

View file

@ -362,13 +362,7 @@ short chan_write(short channel, const uint8_t * buffer, short size) {
p_channel chan;
p_dev_chan cdev;
short res;
short test=0x1234;
log(LOG_TRACE,"chan_write(%d,%p,%x)", channel, buffer, test/*(int)size*/);
TRACE1("chan_write(%d)", (short)channel);
TRACE1("chan_write(,%p,)", buffer);
TRACE1("chan_write(,,%x)", (short)test/*(int)size*/);
// log_num(LOG_INFO, "chan_write: ", channel);
log(LOG_TRACE,"chan_write(%d,%p,%x)", channel, buffer, (int)size);
res = chan_get_records(channel, &chan, &cdev);
if (res == 0)

View file

@ -1,288 +1,288 @@
/**
* Definitions support low level channel device drivers
*
* A channel or stream is a sequence of bytes that may be read or written to.
*
* Examples include: console, serial port, an open file, etc.
*/
#ifndef __CHANNEL_H
#define __CHANNEL_H
#include "types.h"
/*
* Preset channel device numbers
*/
#define CDEV_DEVICES_MAX 8 // The maximum number of channel devices we will support
#define CHAN_MAX 16 // The maximum number of open channels we will support
#define CHAN_DATA_SIZE 32 // The number of bytes in the channel's data area
#define CDEV_CONSOLE 0
#define CDEV_EVID 1
#define CDEV_COM1 2
#define CDEV_COM2 3
#define CDEV_LPT 4
#define CDEV_MIDI 5
#define CDEV_FILE 6
/*
* Channel status bits
*/
#define CDEV_STAT_EOF 0x01 // The channel has reached the end of the data
#define CDEV_STAT_ERROR 0x02 // The channel has encountered some error
#define CDEV_STAT_READABLE 0x04 // The channel has data to read (read will not block)
#define CDEV_STAT_WRITABLE 0x08 // The channel can accept data (write will not block)
#define CDEV_SEEK_START 0 /* Seek from the start of the file */
#define CDEV_SEEK_RELATIVE 1 /* Seek from the current position */
#define CDEV_SEEK_END 2 /* Seek from teh end of the file */
/*
* Structure defining a channel
*/
typedef struct s_channel {
short number; // The number of the channel
short dev; // The number of the channel's device
uint8_t data[CHAN_DATA_SIZE]; // A block of state data that the channel code can use for its own purposes
} t_channel, *p_channel;
typedef short (*FUNC_CBS_2_S)(p_channel, uint8_t *, short);
typedef short (*FUNC_C_2_S)(p_channel);
typedef short (*FUNC_CcBS_2_S)(p_channel, const uint8_t *, short);
typedef short (*FUNC_CB_2_S)(p_channel, uint8_t);
typedef short (*FUNC_CLS_2_S)(p_channel, long, short);
typedef short (*FUNC_CSBS_2_S)(p_channel, short, uint8_t *, short);
/*
* Structure defining a channel device's functions
*/
typedef struct s_dev_chan {
short number; // The number of the device (assigned by registration)
char * name; // The name of the device
FUNC_V_2_S init; // short init() -- Initialize the device
FUNC_CcBS_2_S open; // short open(t_channel * chan, const uint8_t * path, short mode) -- open a channel for the device
FUNC_V_2_S close; // short close(t_channel * chan) -- called when a channel is closed
FUNC_CBS_2_S read; // short read(t_channel *, uint8_t * buffer, short size) -- Read a a buffer from the device
FUNC_CBS_2_S readline; // short readline(t_channel *, uint8_t * buffer, short size) -- Read a line of text from the device
FUNC_C_2_S read_b; // short read_b(t_channel *) -- read a single uint8_t from the device
FUNC_CcBS_2_S write; // short write(t_channel *, const uint8_t * buffer, short size) -- Write a buffer to the device
FUNC_CB_2_S write_b; // short write_b(t_channel *, const uint8_t b) -- Write a single uint8_t to the device
FUNC_C_2_S status; // short status(t_channel *) -- Get the status of the device
FUNC_C_2_S flush; // short flush(t_channel *) -- Ensure that any pending writes to teh device have been completed
FUNC_CLS_2_S seek; // short cdev_seek(t_channel *, long position, short base) -- attempt to move the "cursor" position in the channel
FUNC_CSBS_2_S ioctrl; // short ioctrl(t_channel *, short command, uint8_t * buffer, short size)) -- Issue a control command to the device
} t_dev_chan, *p_dev_chan;
/*
* Initialize the channel driver system
*/
extern void cdev_init_system();
/*
* Register a channel device driver
*
* Inputs:
* p_dev_chan = pointer to the description of the channel device
*/
extern short cdev_register(const p_dev_chan device);
/*
* Get a free channel
*
* Returns:
* A pointer to the free channel, 0 if none are available.
*/
extern p_channel chan_alloc();
/*
* Return a channel to the pool of unused channels
*
* Inputs:
* chan = a pointer to the channel record to return to the kernel
*/
extern void chan_free(p_channel chan);
/*
* Return a pointer to the channel record for a given channel handle.
*
* Inputs:
* c = the number of the channel
*
* Returns:
* a pointer to the channel record.
*/
extern p_channel chan_get_record(short c);
/*
* Initialize the device
*
* Inputs:
* dev = the number of the device
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern short cdev_init(short dev);
/*
* Open a channel
*
* Inputs:
* dev = the device number to have a channel opened
* path = a "path" describing how the device is to be open
* mode = is the device to be read, written, both?
*
* Returns:
* the number of the channel opened, negative number on error
*/
extern short chan_open(short dev, const uint8_t * path, short mode);
/*
* Close a channel
*
* Inputs:
* chan = the number of the channel to close
*
* Returns:
* nothing useful
*/
extern short chan_close(short chan);
/*
* Read bytes from the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer into which to copy the channel data
* size = the size of the buffer.
*
* Returns:
* number of bytes read, any negative number is an error code
*/
extern short chan_read(short channel, uint8_t * buffer, short size);
/*
* Read a line from the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer into which to copy the channel data
* size = the size of the buffer.
*
* Returns:
* number of bytes read, any negative number is an error code
*/
extern short chan_readline(short channel, uint8_t * buffer, short size);
/*
* Read a single uint8_t from the channel
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* the value read (if negative, error)
*/
extern short chan_read_b(short channel);
/*
* Write a bytes to the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer containing the data to write
* size = the size of the buffer.
*
* Returns:
* number of bytes written, any negative number is an error code
*/
extern short chan_write(short channel, const uint8_t * buffer, short size);
/*
* Write a single uint8_t to the device
*
* Inputs:
* channel = the number of the channel
* b = the uint8_t to write
*
* Returns:
* 0 on success, a negative value on error
*/
extern short chan_write_b(short channel, uint8_t b);
/*
* Return the status of the channel device
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* the status of the device
*/
extern short chan_status(short channel);
/*
* Ensure that any pending writes to teh device have been completed
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern short chan_flush(short channel);
/*
* Attempt to set the position of the channel cursor (if supported)
*
* Inputs:
* channel = the number of the channel
* position = the position of the cursor
* base = whether the position is from the beginning of the channel, relative to the current position,
* or relative to the end of the channel
*
* Returns:
* 0 = success, a negative number is an error.
*/
extern short chan_seek(short channel, long position, short base);
/*
* Issue a control command to the device
*
* Inputs:
* channel = the number of the channel
* command = the number of the command to send
* buffer = pointer to bytes of additional data for the command
* size = the size of the buffer
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern short chan_ioctrl(short channel, short command, uint8_t * buffer, short size);
/**
* Return the device associated with the channel
*
* @param channel the ID of the channel to query
* @return the ID of the device associated with the channel, negative number for error
*/
extern short chan_device(short channel);
/**
* Swap the channel ID assignments for two channels
*
* Before call: channel1 = "Channel A", channel2 = "Channel B"
* After call: channel1 = "Channel B", channel2 = "Channel A"
*
* @param channel1 the ID of one of the channels
* @param channel2 the ID of the other channel
* @return 0 on success, any other number is an error
*/
extern short chan_swap(short channel1, short channel2);
#endif
/**
* Definitions support low level channel device drivers
*
* A channel or stream is a sequence of bytes that may be read or written to.
*
* Examples include: console, serial port, an open file, etc.
*/
#ifndef __CHANNEL_H
#define __CHANNEL_H
#include "types.h"
/*
* Preset channel device numbers
*/
#define CDEV_DEVICES_MAX 8 // The maximum number of channel devices we will support
#define CHAN_MAX 16 // The maximum number of open channels we will support
#define CHAN_DATA_SIZE 32 // The number of bytes in the channel's data area
#define CDEV_CONSOLE 0
#define CDEV_EVID 1
#define CDEV_COM1 2
#define CDEV_COM2 3
#define CDEV_LPT 4
#define CDEV_MIDI 5
#define CDEV_FILE 6
/*
* Channel status bits
*/
#define CDEV_STAT_EOF 0x01 // The channel has reached the end of the data
#define CDEV_STAT_ERROR 0x02 // The channel has encountered some error
#define CDEV_STAT_READABLE 0x04 // The channel has data to read (read will not block)
#define CDEV_STAT_WRITABLE 0x08 // The channel can accept data (write will not block)
#define CDEV_SEEK_START 0 /* Seek from the start of the file */
#define CDEV_SEEK_RELATIVE 1 /* Seek from the current position */
#define CDEV_SEEK_END 2 /* Seek from teh end of the file */
/*
* Structure defining a channel
*/
typedef struct s_channel {
short number; // The number of the channel
short dev; // The number of the channel's device
uint8_t data[CHAN_DATA_SIZE]; // A block of state data that the channel code can use for its own purposes
} t_channel, *p_channel;
typedef short (*FUNC_CBS_2_S)(p_channel, uint8_t *, short);
typedef short (*FUNC_C_2_S)(p_channel);
typedef short (*FUNC_CcBS_2_S)(p_channel, const uint8_t *, short);
typedef short (*FUNC_CB_2_S)(p_channel, uint8_t);
typedef short (*FUNC_CLS_2_S)(p_channel, long, short);
typedef short (*FUNC_CSBS_2_S)(p_channel, short, uint8_t *, short);
/*
* Structure defining a channel device's functions
*/
typedef struct s_dev_chan {
short number; // The number of the device (assigned by registration)
char * name; // The name of the device
FUNC_V_2_S init; // short init() -- Initialize the device
FUNC_CcBS_2_S open; // short open(t_channel * chan, const uint8_t * path, short mode) -- open a channel for the device
FUNC_V_2_S close; // short close(t_channel * chan) -- called when a channel is closed
FUNC_CBS_2_S read; // short read(t_channel *, uint8_t * buffer, short size) -- Read a a buffer from the device
FUNC_CBS_2_S readline; // short readline(t_channel *, uint8_t * buffer, short size) -- Read a line of text from the device
FUNC_C_2_S read_b; // short read_b(t_channel *) -- read a single uint8_t from the device
FUNC_CcBS_2_S write; // short write(t_channel *, const uint8_t * buffer, short size) -- Write a buffer to the device
FUNC_CB_2_S write_b; // short write_b(t_channel *, const uint8_t b) -- Write a single uint8_t to the device
FUNC_C_2_S status; // short status(t_channel *) -- Get the status of the device
FUNC_C_2_S flush; // short flush(t_channel *) -- Ensure that any pending writes to teh device have been completed
FUNC_CLS_2_S seek; // short cdev_seek(t_channel *, long position, short base) -- attempt to move the "cursor" position in the channel
FUNC_CSBS_2_S ioctrl; // short ioctrl(t_channel *, short command, uint8_t * buffer, short size)) -- Issue a control command to the device
} t_dev_chan, *p_dev_chan;
/*
* Initialize the channel driver system
*/
extern void cdev_init_system();
/*
* Register a channel device driver
*
* Inputs:
* p_dev_chan = pointer to the description of the channel device
*/
extern short cdev_register(p_dev_chan device);
/*
* Get a free channel
*
* Returns:
* A pointer to the free channel, 0 if none are available.
*/
extern p_channel chan_alloc();
/*
* Return a channel to the pool of unused channels
*
* Inputs:
* chan = a pointer to the channel record to return to the kernel
*/
extern void chan_free(p_channel chan);
/*
* Return a pointer to the channel record for a given channel handle.
*
* Inputs:
* c = the number of the channel
*
* Returns:
* a pointer to the channel record.
*/
extern p_channel chan_get_record(short c);
/*
* Initialize the device
*
* Inputs:
* dev = the number of the device
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern short cdev_init(short dev);
/*
* Open a channel
*
* Inputs:
* dev = the device number to have a channel opened
* path = a "path" describing how the device is to be open
* mode = is the device to be read, written, both?
*
* Returns:
* the number of the channel opened, negative number on error
*/
extern short chan_open(short dev, const uint8_t * path, short mode);
/*
* Close a channel
*
* Inputs:
* chan = the number of the channel to close
*
* Returns:
* nothing useful
*/
extern short chan_close(short chan);
/*
* Read bytes from the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer into which to copy the channel data
* size = the size of the buffer.
*
* Returns:
* number of bytes read, any negative number is an error code
*/
extern short chan_read(short channel, uint8_t * buffer, short size);
/*
* Read a line from the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer into which to copy the channel data
* size = the size of the buffer.
*
* Returns:
* number of bytes read, any negative number is an error code
*/
extern short chan_readline(short channel, uint8_t * buffer, short size);
/*
* Read a single uint8_t from the channel
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* the value read (if negative, error)
*/
extern short chan_read_b(short channel);
/*
* Write a bytes to the channel
*
* Inputs:
* channel = the number of the channel
* buffer = the buffer containing the data to write
* size = the size of the buffer.
*
* Returns:
* number of bytes written, any negative number is an error code
*/
extern short chan_write(short channel, const uint8_t * buffer, short size);
/*
* Write a single uint8_t to the device
*
* Inputs:
* channel = the number of the channel
* b = the uint8_t to write
*
* Returns:
* 0 on success, a negative value on error
*/
extern short chan_write_b(short channel, uint8_t b);
/*
* Return the status of the channel device
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* the status of the device
*/
extern short chan_status(short channel);
/*
* Ensure that any pending writes to teh device have been completed
*
* Inputs:
* channel = the number of the channel
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern short chan_flush(short channel);
/*
* Attempt to set the position of the channel cursor (if supported)
*
* Inputs:
* channel = the number of the channel
* position = the position of the cursor
* base = whether the position is from the beginning of the channel, relative to the current position,
* or relative to the end of the channel
*
* Returns:
* 0 = success, a negative number is an error.
*/
extern short chan_seek(short channel, long position, short base);
/*
* Issue a control command to the device
*
* Inputs:
* channel = the number of the channel
* command = the number of the command to send
* buffer = pointer to bytes of additional data for the command
* size = the size of the buffer
*
* Returns:
* 0 on success, any negative number is an error code
*/
extern short chan_ioctrl(short channel, short command, uint8_t * buffer, short size);
/**
* Return the device associated with the channel
*
* @param channel the ID of the channel to query
* @return the ID of the device associated with the channel, negative number for error
*/
extern short chan_device(short channel);
/**
* Swap the channel ID assignments for two channels
*
* Before call: channel1 = "Channel A", channel2 = "Channel B"
* After call: channel1 = "Channel B", channel2 = "Channel A"
*
* @param channel1 the ID of one of the channels
* @param channel2 the ID of the other channel
* @return 0 on success, any other number is an error
*/
extern short chan_swap(short channel1, short channel2);
#endif

File diff suppressed because it is too large Load diff

View file

@ -15,19 +15,19 @@
#include "dev/kbd_mo.h"
#endif
#if (MODEL == MODEL_FOENIX_A2560K || MODEL == MODEL_FOENIX_GENX || MODEL == MODEL_FOENIX_A2560X)
#if ( MODEL == MODEL_FOENIX_A2560K || MODEL == MODEL_FOENIX_GENX || MODEL == MODEL_FOENIX_A2560X)
short ind_state_color(short state) {
switch (state) {
case IND_ON:
/* Green for on */
#if MODEL == MODEL_FOENIX_A2560K
#if MODEL == MODEL_FOENIX_A2560K
return 0x02;
#elif MODEL == MODEL_FOENIX_GENX
return 0x05;
#elif MODEL == MODEL_FOENIX_A2560X
return 0x06;
#else
return 0x03; // That is not possble because of the #if so why did Stefany mean ?
return 0x03;
#endif
case IND_ERROR:
/* Red for error */
@ -95,12 +95,15 @@ void ind_set_hdc(short state) {
}
#else
void ind_set_fdc(short state) {
}
void ind_set_sdc(short state) {
}
void ind_set_hdc(short state) {
}
#endif
@ -113,11 +116,10 @@ void ind_set_hdc(short state) {
*/
void ind_set(short ind_number, short state) {
switch (ind_number) {
#if (MODEL == MODEL_FOENIX_A2560K || MODEL == MODEL_FOENIX_GENX || MODEL == MODEL_FOENIX_A2560X)
case IND_POWER:
ind_set_power(state);
break;
#endif
case IND_FDC:
ind_set_fdc(state);
break;

View file

@ -2,6 +2,7 @@
* Master file for the Yamaha sound chips
*/
#include "features.h"
#include "sound_reg.h"
#include "snd/yamaha.h"
@ -16,7 +17,7 @@
*/
void ym_write(enum e_ym_snd_dev dev, enum e_ym_position position, short port, unsigned char value) {
switch (dev) {
#if MODEL == MODEL_FOENIX_A2560K
#if HAS_OPN
case SND_OPN2:
switch (position) {
case EXTERNAL:
@ -31,7 +32,8 @@ void ym_write(enum e_ym_snd_dev dev, enum e_ym_position position, short port, un
break;
}
break;
#endif
#if HAS_OPM
case SND_OPM:
switch (position) {
case EXTERNAL:
@ -63,22 +65,22 @@ void ym_init() {
short position;
short port;
#if MODEL == MODEL_FOENIX_A2560K
#if HAS_OPN
/* OPN */
for (position = EXTERNAL; position <= INTERNAL; position++) {
for (port = 0x40; port <= 0x4F; port++) {
ym_write(SND_OPN2, position, port, 0x7F); /* Maximum attentuation */
}
}
#endif
#if HAS_OPM
/* OPM */
for (position = EXTERNAL; position <= INTERNAL; position++) {
for (port = 0x60; port <= 0x6F; port++) {
ym_write(SND_OPM, position, port, 0x7F); /* Maximum attentuation */
}
}
#endif
/* OPL3 */