123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #ifndef BOOTPARAMETERS1_SOURCE
- #define BOOTPARAMETERS1_SOURCE
- #include <stdint.h>
- #include <unistd.h>
- #include <memory.h>
- #include <errno.h>
- #include "../tools/files.h"
- #include "../tools/error.h"
- #include "../tools/flags.h"
- #include "../plc/plc.h"
- #include "../pib/pib.h"
- signed BootParameters1 (struct plc * plc)
- {
- struct pib_header pib_header;
- uint32_t offset;
- if (lseek (plc->PIB.file, 0, SEEK_SET))
- {
- error (PLC_EXIT (plc), errno, FILE_CANTHOME, plc->PIB.name);
- }
- if (read (plc->PIB.file, &pib_header, sizeof (pib_header)) != sizeof (pib_header))
- {
- error (PLC_EXIT (plc), errno, FILE_CANTREAD, plc->PIB.name);
- }
- if (lseek (plc->PIB.file, 0, SEEK_SET))
- {
- error (PLC_EXIT (plc), errno, FILE_CANTHOME, plc->PIB.name);
- }
- #if 1
- if (BE16TOH (*(uint16_t *)(&pib_header)) < 0x0305)
- {
- offset = LEGACY_PIBOFFSET;
- }
- else if (BE16TOH (*(uint16_t *)(&pib_header)) < 0x0500)
- {
- offset = INT6x00_PIBOFFSET;
- }
- else
- {
- offset = AR7x00_PIBOFFSET;
- }
- #endif
- if (plc->hardwareID < CHIPSET_AR7400)
- {
- if (WriteMEM (plc, &plc->PIB, 0, offset, LE16TOH (pib_header.PIBLENGTH)))
- {
- return (-1);
- }
- return (0);
- }
- if (WriteExecutePIB (plc, offset, &pib_header))
- {
- return (-1);
- }
- return (0);
- }
- #endif
|