📄 main.c
字号:
/* Copyright 2001, 2002 Georges Menie (www.menie.org) This file is part of Tftpnaive. Tftpnaive is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Tftpnaive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Tftpnaive; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include "tftpnaive.h"#include "68vz328.h"#include "io.h"#include "net.h"#include "baselib.h"#include "timer.h"#include "cs89x.h"#include "bootstd.h"int errno;_bsc1 (unsigned char *, gethwaddr, int, a)int netUp (void){ int error; timerInit (); memcpy (netif.IEEEIA, gethwaddr (0), sizeof netif.IEEEIA); netif.send = cs89xSend; /* disable IRQ */ orl (1 << IRQ_NUM, IMR); orb (0x01, PFSEL); /* output /sleep */ orw (0x0101, PFDIR); /* not sleeping */ andb (~0x02, PFSEL); /* input irq5 */ andw (~0x0202, PFDIR); /* irq5 fcn on */ writew (0x8000, CSGBB); /* 0x04000000 */ writew (0x01e1, CSB); /* read/write, 128k, 12ws, FLASH enable, 16 bits bus */ if (cs89xReset ()) { printf ("Network interface reset failed\n"); return 1; } /* set interrupt service routine: IRQ5 -> level 5 */ writel ((int) cs89xISR, ((readb (IVR) & 0xf8) + 5) << 2); /* IRQ 5 setup */ orw (0x0080, ICR); /* +ve pol irq */ /* network chip initialization * if there is a error other than a cable problem * the function returns to the caller. * if there is a cable problem, loop and try again after 1s */ error = cs89xSetup (); while (error) { if (error != ERR_LINK) { printf ("Network interface init failed: code %d\n", error); return 1; } printf ("No network, cable problem ?\n"); usleep (1000000); error = cs89xStatus (); } /* enable IRQ */ orl (1 << IRQ_NUM, ISR); andl (~(1 << IRQ_NUM), IMR); return 0;}int netDown (void){ /* disable IRQ */ orl (1 << IRQ_NUM, IMR); orl (1 << IRQ_NUM, ISR); if (cs89xReset ()) { printf ("Network interface reset failed\n"); return 1; } /* erase IP */ netif.ip = 0; return 0;}int main (void){ timerInit (); if (netUp ()) return 1; while (1) { netRequestIP (); if (netBoot () == 0) break; } netDown (); if (tftp_req && tftp_req->sts && tftp_req->strtf) { jump ((void *) tftp_req->strt); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -