From: Chuck McManis <cmcmanis@mcmanis.com>
To: ecos-discuss@ecos.sourceware.org
Cc: Gary Thomas <gary@mlbassoc.com>
Subject: [ECOS] Proper Thread Environment (was Re: [ECOS] SPI usage)
Date: Tue, 27 Feb 2007 04:56:00 -0000 [thread overview]
Message-ID: <6.1.2.0.2.20070226203615.0447f8b8@192.168.110.40> (raw)
In-Reply-To: <45E2F53A.7090403@mlbassoc.com>
At 06:56 AM 2/26/2007, Gary Thomas wrote:
> Try putting these functions into 'main()', which is called
> with a proper thread environment and the kernel+interrupts
> running.
I read this and it reminded me of a question I had, if you have a pointer
I'd be grateful for it.
Basically when I got the HTTP server to run I did so by loading and running
the httpd1 test program and noting that it worked fine. Then I tried to run
a "main" program and the web server simultaneously. Basically I added:
So I had this simple bit of code:
----------------------- bit of lame included code ------------------------
#include <stdio.h>
#include <network.h>
/*
* Note this is for backward compatibility we don't really
* think that ECOS will call main, it calls cyg_start and
* that function will call main.
*/
int
main(int argc, char *argv[]) {
char buf[2048];
printf("Welcome to the ECOS world!\n");
while (1) {
printf("Enter some text: ");
gets(buf);
printf("'%s'\n", buf);
}
exit (0);
}
/*
* This was mostly stolen from the HTTPD test
*/
#define STACK_SIZE (8192 + 0x1000)
static char stack[STACK_SIZE];
static cyg_thread thread_data;
static cyg_handle_t thread_handle;
void
user_thread(cyg_addrword_t p) {
diag_printf("Startup code for ECOS is running...\n");
init_all_network_interfaces();
/*
main(1, aa);
*/
}
void
cyg_user_start(void) {
cyg_thread_create(10, // Priority - just a number
user_thread, // entry
0, // entry parameter
"simple httpd", // Name
&stack[0], // Stack
STACK_SIZE, // Size
&thread_handle, // Handle
&thread_data // Thread data structure
);
cyg_thread_resume(thread_handle); // Start it
cyg_scheduler_start();
}
----------------------- end of lame included code ---------------------------
And it has a really weird way of working. Basically what happens is that
somehow, main() gets called anyway and runs. And frankly I can't figure out
how it gets called, but even stranger, its interaction with the console
blocks the networking stack's attempt to print the result of running DHCP
which keeps the web server from running. (it nicely demonstrates the Rhine
"feature" of resetting CR0 however if you don't service received packets ;-)
So what I was looking for, and could not find, was sort of a crt0 type file
which would provide "the proper thread environment + kernel and interrupts
running" which would include starting a thread by calling 'main()'. That
way I could keep eCos code fairly segregated from my "application" which
normally would run as a process on a UNIX or Linux machine.
Thoughts? Should I just create two threads? Will they still interfere with
each other's use of the console?
--Chuck
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next prev parent reply other threads:[~2007-02-27 4:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-26 14:51 [ECOS] SPI usage Julien Stéphane
2007-02-26 14:57 ` Gary Thomas
2007-02-26 15:01 ` [ECOS] RE : " Julien Stéphane
2007-02-27 4:56 ` Chuck McManis [this message]
2007-02-27 12:06 ` [ECOS] Proper Thread Environment (was Re: [ECOS] SPI usage) Gary Thomas
2007-03-01 6:08 ` Chuck McManis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6.1.2.0.2.20070226203615.0447f8b8@192.168.110.40 \
--to=cmcmanis@mcmanis.com \
--cc=ecos-discuss@ecos.sourceware.org \
--cc=gary@mlbassoc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).