arch/sim: Fix spacing/alignment issues

This commit is contained in:
Gregory Nutt 2015-10-14 07:14:28 -06:00
parent 4a46a872bd
commit c340185cb3
19 changed files with 101 additions and 94 deletions

View File

@ -196,20 +196,20 @@ static uint8_t g_runbuffer[FB_STRIDE];
static const struct fb_videoinfo_s g_videoinfo =
{
.fmt = FB_FMT, /* Color format: RGB16-565: RRRR RGGG GGGB BBBB */
.xres = CONFIG_SIM_FBWIDTH, /* Horizontal resolution in pixel columns */
.yres = CONFIG_SIM_FBHEIGHT, /* Vertical resolution in pixel rows */
.nplanes = 1, /* Number of color planes supported */
.fmt = FB_FMT, /* Color format: RGB16-565: RRRR RGGG GGGB BBBB */
.xres = CONFIG_SIM_FBWIDTH, /* Horizontal resolution in pixel columns */
.yres = CONFIG_SIM_FBHEIGHT, /* Vertical resolution in pixel rows */
.nplanes = 1, /* Number of color planes supported */
};
/* This is the standard, NuttX Plane information object */
static const struct lcd_planeinfo_s g_planeinfo =
{
.putrun = sim_putrun, /* Put a run into LCD memory */
.getrun = sim_getrun, /* Get a run from LCD memory */
.buffer = (uint8_t*)g_runbuffer, /* Run scratch buffer */
.bpp = CONFIG_SIM_FBBPP, /* Bits-per-pixel */
.putrun = sim_putrun, /* Put a run into LCD memory */
.getrun = sim_getrun, /* Get a run from LCD memory */
.buffer = (FAR uint8_t *)g_runbuffer, /* Run scratch buffer */
.bpp = CONFIG_SIM_FBBPP, /* Bits-per-pixel */
};
/* This is the standard, NuttX LCD driver object */

View File

@ -84,6 +84,6 @@
void up_registerblockdevice(void)
{
ramdisk_register(0, (uint8_t*)up_deviceimage(), NSECTORS,
ramdisk_register(0, (FAR uint8_t *)up_deviceimage(), NSECTORS,
LOGICAL_SECTOR_SIZE, RDFLAG_WRENABLED | RDFLAG_FUNLINK);
}

View File

@ -75,7 +75,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
bool switch_needed;
/* Verify that the context switch can be performed */
@ -126,7 +126,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
* of the g_readytorun task list.
*/
rtcb = (struct tcb_s*)g_readytorun.head;
rtcb = (FAR struct tcb_s *)g_readytorun.head;
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -107,7 +107,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
/* Allocate the memory for the stack */
stack_alloc_ptr = (uint32_t*)kumm_malloc(adj_stack_size);
stack_alloc_ptr = (FAR uint32_t *)kumm_malloc(adj_stack_size);
/* Was the allocation successful? */

View File

@ -56,11 +56,13 @@
* Private Function Prototypes
****************************************************************************/
static ssize_t devconsole_read(struct file *, char *, size_t);
static ssize_t devconsole_write(struct file *, const char *, size_t);
static ssize_t devconsole_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t devconsole_write(FAR struct file *filep,
FAR const char *buffer, size_t buflen);
#ifndef CONFIG_DISABLE_POLL
static int devconsole_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
bool setup);
#endif
/****************************************************************************

View File

@ -224,7 +224,7 @@ char *up_deviceimage(void)
if (ret != Z_OK)
{
sdbg("inflateInit FAILED: ret=%d msg=\"%s\"\n",
ret, strm.msg ? strm.msg : "No message" );
ret, strm.msg ? strm.msg : "No message");
return NULL;
}
@ -232,12 +232,12 @@ char *up_deviceimage(void)
* reallocate this a few times to get the size right.
*/
pbuffer = (char*)kmm_malloc(bufsize);
pbuffer = (char *)kmm_malloc(bufsize);
/* Set up the input buffer */
strm.avail_in = sizeof(g_vfatdata);
strm.next_in = (Bytef*)g_vfatdata;
strm.next_in = (Bytef *)g_vfatdata;
/* Run inflate() on input until output buffer not full */
@ -246,7 +246,7 @@ char *up_deviceimage(void)
/* Set up to catch the next output chunk in the output buffer */
strm.avail_out = bufsize - offset;
strm.next_out = (Bytef*)&pbuffer[offset];
strm.next_out = (Bytef *)&pbuffer[offset];
/* inflate */
@ -261,7 +261,7 @@ char *up_deviceimage(void)
case Z_MEM_ERROR:
case Z_STREAM_ERROR:
sdbg("inflate FAILED: ret=%d msg=\"%s\"\n",
ret, strm.msg ? strm.msg : "No message" );
ret, strm.msg ? strm.msg : "No message");
(void)inflateEnd(&strm);
kmm_free(pbuffer);
return NULL;
@ -274,7 +274,7 @@ char *up_deviceimage(void)
if (strm.avail_out == 0)
{
int newbufsize = bufsize + 128*1024;
int newbufsize = bufsize + 128 * 1024;
char *newbuffer = kmm_realloc(pbuffer, newbufsize);
if (!newbuffer)
{
@ -326,42 +326,43 @@ char *up_deviceimage(void)
#ifdef VFAT_STANDALONE
int main(int argc, char **argv, char **envp)
{
char *deviceimage;
int cmf;
int fdict;
int flg;
int check;
char *deviceimage;
int cmf;
int fdict;
int flg;
int check;
cmf = g_vfatdata[0];
printf("CMF=%02x: CM=%d CINFO=%d\n", cmf, cmf &0x0f, cmf >> 4);
cmf = g_vfatdata[0];
printf("CMF=%02x: CM=%d CINFO=%d\n", cmf, cmf &0x0f, cmf >> 4);
flg = g_vfatdata[1];
fdict = (flg >> 5) & 1;
flg = g_vfatdata[1];
fdict = (flg >> 5) & 1;
printf("FLG=%02x: FCHECK=%d FDICT=%d FLEVEL=%d\n", flg, flg &0x1f, fdict, flg >> 6);
printf("FLG=%02x: FCHECK=%d FDICT=%d FLEVEL=%d\n",
flg, flg &0x1f, fdict, flg >> 6);
/* The FCHECK value must be such that CMF and FLG, when viewed as
* a 16-bit unsigned integer stored in MSB order (CMF*256 + FLG),
* is a multiple of 31.
*/
/* The FCHECK value must be such that CMF and FLG, when viewed as
* a 16-bit unsigned integer stored in MSB order (CMF*256 + FLG),
* is a multiple of 31.
*/
check = cmf*256 + flg;
if (check % 31 != 0)
check = cmf*256 + flg;
if (check % 31 != 0)
{
printf("Fails check: %04x is not a multiple of 31\n", check);
printf("Fails check: %04x is not a multiple of 31\n", check);
}
deviceimage = up_deviceimage();
if (deviceimage)
deviceimage = up_deviceimage();
if (deviceimage)
{
printf("Inflate SUCCEEDED\n");
kmm_free(deviceimage);
return 0;
printf("Inflate SUCCEEDED\n");
kmm_free(deviceimage);
return 0;
}
else
else
{
printf("Inflate FAILED\n");
return 1;
printf("Inflate FAILED\n");
return 1;
}
}
#endif

View File

@ -77,7 +77,7 @@
void _exit(int status)
{
struct tcb_s* tcb;
FAR struct tcb_s *tcb;
sdbg("TCB=%p exiting\n", tcb);
@ -89,7 +89,7 @@ void _exit(int status)
* head of the list.
*/
tcb = (struct tcb_s*)g_readytorun.head;
tcb = (FAR struct tcb_s *)g_readytorun.head;
sdbg("New Active Task TCB=%p\n", tcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -68,7 +68,7 @@
* Public Functions
****************************************************************************/
unsigned long up_getwalltime( void )
unsigned long up_getwalltime(void)
{
struct timeval tm;
(void)gettimeofday(&tm, NULL);

View File

@ -166,11 +166,12 @@ static int sim_txpoll(struct net_driver_s *dev)
void netdriver_loop(void)
{
struct eth_hdr_s *eth;
FAR struct eth_hdr_s *eth;
/* netdev_read will return 0 on a timeout event and >0 on a data received event */
g_sim_dev.d_len = netdev_read((unsigned char*)g_sim_dev.d_buf, CONFIG_NET_ETH_MTU);
g_sim_dev.d_len = netdev_read((FAR unsigned char *)g_sim_dev.d_buf,
CONFIG_NET_ETH_MTU);
/* Disable preemption through to the following so that it behaves a little more
* like an interrupt (otherwise, the following logic gets pre-empted an behaves
@ -210,10 +211,10 @@ void netdriver_loop(void)
arp_ipin(&g_sim_dev);
ipv4_input(&g_sim_dev);
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
if (g_sim_dev.d_len > 0)
{
@ -248,10 +249,10 @@ void netdriver_loop(void)
ipv6_input(&g_sim_dev);
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
/* If the above function invocation resulted in data that
* should be sent out on the network, the global variable
* d_len is set to a value > 0.
*/
if (g_sim_dev.d_len > 0)
{

View File

@ -64,7 +64,7 @@
void up_release_pending(void)
{
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
sdbg("From TCB=%p\n", rtcb);
@ -92,7 +92,7 @@ void up_release_pending(void)
* of the g_readytorun task list.
*/
rtcb = (struct tcb_s*)g_readytorun.head;
rtcb = (FAR struct tcb_s *)g_readytorun.head;
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -92,7 +92,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
else
{
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
bool switch_needed;
sdbg("TCB=%p PRI=%d\n", tcb, priority);
@ -147,7 +147,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
* of the g_readytorun task list.
*/
rtcb = (struct tcb_s*)g_readytorun.head;
rtcb = (FAR struct tcb_s *)g_readytorun.head;
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -100,7 +100,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
{
/* We don't have to anything complex for the simulated target */
if (tcb == (struct tcb_s*)g_readytorun.head)
if (tcb == (FAR struct tcb_s *)g_readytorun.head)
{
sigdeliver(tcb);
}

View File

@ -132,7 +132,7 @@ static void *simuart_thread(void *arg)
/* Now loop, collecting a buffering data from stdin forever */
for (;;)
for (; ; )
{
/* Read one character from stdin */
@ -280,7 +280,7 @@ int simuart_getc(void)
*/
sched_lock();
for (;;)
for (; ; )
{
/* Wait for a byte to become available */

View File

@ -479,9 +479,9 @@ static void spiflash_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffe
/* 8-bit mode */
const uint8_t *src = (const uint8_t*)txbuffer;;
uint8_t *dest = (uint8_t*)rxbuffer;
uint8_t word;
FAR const uint8_t *src = (FAR const uint8_t *)txbuffer;
FAR uint8_t *dest = (FAR uint8_t *)rxbuffer;
uint8_t word;
while (nwords-- > 0)
{

View File

@ -189,18 +189,18 @@ void tapdev_init(void)
gtapdevfd = open(DEVTAP, O_RDWR, 0644);
if (gtapdevfd < 0)
{
syslog(LOG_ERR, "TAPDEV: open failed: %d\n", -gtapdevfd );
syslog(LOG_ERR, "TAPDEV: open failed: %d\n", -gtapdevfd);
return;
}
/* Configure the tap device */
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
ret = ioctl(gtapdevfd, TUNSETIFF, (unsigned long) &ifr);
if (ret < 0)
{
syslog(LOG_ERR, "TAPDEV: ioctl failed: %d\n", -ret );
syslog(LOG_ERR, "TAPDEV: ioctl failed: %d\n", -ret);
return;
}

View File

@ -243,7 +243,7 @@ static int up_sample(FAR struct up_dev_s *priv,
* sampled data.
*/
memcpy(sample, &priv->sample, sizeof(struct up_sample_s ));
memcpy(sample, &priv->sample, sizeof(struct up_sample_s));
/* Now manage state transitions */
@ -643,7 +643,7 @@ errout:
int board_tsc_setup(int minor)
{
FAR struct up_dev_s *priv = ( FAR struct up_dev_s *)&g_simtouchscreen;
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen;
char devname[DEV_NAMELEN];
int ret;
@ -703,7 +703,7 @@ errout_with_priv:
void board_tsc_teardown(void)
{
FAR struct up_dev_s *priv = ( FAR struct up_dev_s *)&g_simtouchscreen;
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen;
char devname[DEV_NAMELEN];
int ret;
@ -728,7 +728,7 @@ void board_tsc_teardown(void)
g_eventloop = 0;
/* Un-register the device*/
/* Un-register the device */
(void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, priv->minor);
ivdbg("Un-registering %s\n", devname);

View File

@ -68,9 +68,9 @@
*
****************************************************************************/
void up_unblock_task(struct tcb_s *tcb)
void up_unblock_task(FAR struct tcb_s *tcb)
{
struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
/* Verify that the context switch can be performed */
@ -110,7 +110,7 @@ void up_unblock_task(struct tcb_s *tcb)
* g_readytorun task list.
*/
rtcb = (struct tcb_s*)g_readytorun.head;
rtcb = (FAR struct tcb_s *)g_readytorun.head;
sdbg("New Active Task TCB=%p\n", rtcb);
/* The way that we handle signals in the simulation is kind of

View File

@ -96,7 +96,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
/* This is the address of the last word in the allocation */
size_t *adj_stack_ptr = &((size_t*)stack)[adj_stack_words - 1];
FAR size_t *adj_stack_ptr = &((FAR size_t *)stack)[adj_stack_words - 1];
/* Save the values in the TCB */

View File

@ -120,9 +120,9 @@ static inline int up_x11createframe(void)
XStringListToTextProperty(&winName, 1, &winprop);
XStringListToTextProperty(&iconName, 1, &iconprop);
hints.flags = PSize | PMinSize | PMaxSize;
hints.width = hints.min_width = hints.max_width = g_fbpixelwidth;
hints.height= hints.min_height = hints.max_height = g_fbpixelheight;
hints.flags = PSize | PMinSize | PMaxSize;
hints.width = hints.min_width = hints.max_width = g_fbpixelwidth;
hints.height = hints.min_height = hints.max_height = g_fbpixelheight;
XSetWMProperties(g_display, g_window, &winprop, &iconprop, argv, 1,
&hints, NULL, NULL);
@ -133,10 +133,11 @@ static inline int up_x11createframe(void)
#if defined(CONFIG_SIM_AJOYSTICK)
XSelectInput(g_display, g_window,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask);
ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
#else
XSelectInput(g_display, g_window,
ButtonPressMask|ButtonReleaseMask|PointerMotionMask|KeyPressMask);
ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
KeyPressMask);
#endif
/* Release queued events on the display */
@ -147,7 +148,7 @@ static inline int up_x11createframe(void)
/* Grab mouse button 1, enabling mouse-related events */
(void)XGrabButton(g_display, Button1, AnyModifier, g_window, 1,
ButtonPressMask|ButtonReleaseMask|ButtonMotionMask,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
GrabModeAsync, GrabModeAsync, None, None);
#endif
@ -188,7 +189,7 @@ static void up_x11traperrors(void)
#ifndef CONFIG_SIM_X11NOSHM
static int up_x11untraperrors(void)
{
XSync(g_display,0);
XSync(g_display, 0);
XSetErrorHandler(NULL);
return g_xerror;
}
@ -291,7 +292,7 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
}
if (!g_image)
{
fprintf(stderr,"Unable to create g_image.");
fprintf(stderr, "Unable to create g_image.");
return -1;
}
g_shmcheckpoint++;
@ -337,10 +338,10 @@ shmerror:
#endif
b_useshm = 0;
g_framebuffer = (unsigned char*)malloc(fblen);
g_framebuffer = (unsigned char *)malloc(fblen);
g_image = XCreateImage(g_display, DefaultVisual(g_display,g_screen), depth,
ZPixmap, 0, (char*)g_framebuffer, g_fbpixelwidth, g_fbpixelheight,
g_image = XCreateImage(g_display, DefaultVisual(g_display, g_screen), depth,
ZPixmap, 0, (char *)g_framebuffer, g_fbpixelwidth, g_fbpixelheight,
8, 0);
if (g_image == NULL)
@ -416,7 +417,7 @@ int up_x11initialize(unsigned short width, unsigned short height,
g_x11initialized = 1;
}
*fbmem = (void*)g_framebuffer;
*fbmem = (void *)g_framebuffer;
return 0;
}
@ -440,8 +441,9 @@ int up_x11cmap(unsigned short first, unsigned short len,
{
XColor color;
/* Convert to RGB. In the NuttX cmap, each component
* ranges from 0-255; for X11 the range is 0-65536 */
/* Convert to RGB. In the NuttX cmap, each component
* ranges from 0-255; for X11 the range is 0-65536
*/
color.red = (short)(*red++) << 8;
color.green = (short)(*green++) << 8;
@ -478,5 +480,6 @@ void up_x11update(void)
XPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0,
g_fbpixelwidth, g_fbpixelheight);
}
XSync(g_display, 0);
}